diff --git a/.husky/pre-commit b/.husky/pre-commit index a282f31f5..8f6c78dab 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -5,4 +5,4 @@ export PATH="/usr/local/bin:$HOME/.npm-global/bin:$HOME/.nvm/versions/node/$(node -v)/bin:$PATH" # Then run lint-staged if tests pass -npx lint-staged +npx.cmd lint-staged diff --git a/proprietary/sounds/effects/Atom_Hit.mp3 b/proprietary/sounds/effects/Atom_Hit.mp3 new file mode 100644 index 000000000..895969d79 Binary files /dev/null and b/proprietary/sounds/effects/Atom_Hit.mp3 differ diff --git a/proprietary/sounds/effects/atom_launch.mp3 b/proprietary/sounds/effects/atom_launch.mp3 new file mode 100644 index 000000000..f33c149e8 Binary files /dev/null and b/proprietary/sounds/effects/atom_launch.mp3 differ diff --git a/proprietary/sounds/effects/click.mp3 b/proprietary/sounds/effects/click.mp3 new file mode 100644 index 000000000..92cf4b718 Binary files /dev/null and b/proprietary/sounds/effects/click.mp3 differ diff --git a/proprietary/sounds/effects/hydrogen_hit.mp3 b/proprietary/sounds/effects/hydrogen_hit.mp3 new file mode 100644 index 000000000..d56bedf06 Binary files /dev/null and b/proprietary/sounds/effects/hydrogen_hit.mp3 differ diff --git a/proprietary/sounds/effects/hydrogen_launch.mp3 b/proprietary/sounds/effects/hydrogen_launch.mp3 new file mode 100644 index 000000000..ebff2748a Binary files /dev/null and b/proprietary/sounds/effects/hydrogen_launch.mp3 differ diff --git a/proprietary/sounds/effects/mirv_launch.mp3 b/proprietary/sounds/effects/mirv_launch.mp3 new file mode 100644 index 000000000..5764c95e9 Binary files /dev/null and b/proprietary/sounds/effects/mirv_launch.mp3 differ diff --git a/src/client/LocalServer.ts b/src/client/LocalServer.ts index 09f71e66f..e03065235 100644 --- a/src/client/LocalServer.ts +++ b/src/client/LocalServer.ts @@ -109,7 +109,9 @@ export class LocalServer { if (!this.lobbyConfig.gameRecord) { if (clientMsg.turnNumber % 100 === 0) { // In singleplayer, only store hash every 100 turns to reduce size of game record. - this.turns[clientMsg.turnNumber].hash = clientMsg.hash; + if (this.turns[clientMsg.turnNumber]) { + this.turns[clientMsg.turnNumber].hash = clientMsg.hash; + } } return; } diff --git a/src/client/graphics/layers/FxLayer.ts b/src/client/graphics/layers/FxLayer.ts index 731976f9a..6cd650bc3 100644 --- a/src/client/graphics/layers/FxLayer.ts +++ b/src/client/graphics/layers/FxLayer.ts @@ -19,6 +19,7 @@ import { TextFx } from "../fx/TextFx"; import { UnitExplosionFx } from "../fx/UnitExplosionFx"; import { Layer } from "./Layer"; export class FxLayer implements Layer { + private seenNukes: Set = new Set(); private canvas: HTMLCanvasElement; private context: CanvasRenderingContext2D; @@ -141,10 +142,26 @@ export class FxLayer implements Layer { break; } case UnitType.AtomBomb: + if (!this.seenNukes.has(unit.id())) { + SoundManager.playSoundEffect(SoundEffect.AtomLaunch); + this.seenNukes.add(unit.id()); + } + this.onNukeEvent(unit, 70); + break; + case UnitType.MIRV: + if (!this.seenNukes.has(unit.id())) { + SoundManager.playSoundEffect(SoundEffect.MirvLaunch); + this.seenNukes.add(unit.id()); + } + break; case UnitType.MIRVWarhead: this.onNukeEvent(unit, 70); break; case UnitType.HydrogenBomb: + if (!this.seenNukes.has(unit.id())) { + SoundManager.playSoundEffect(SoundEffect.HydroLaunch); + this.seenNukes.add(unit.id()); + } this.onNukeEvent(unit, 160); break; case UnitType.Warship: @@ -263,6 +280,14 @@ export class FxLayer implements Layer { } handleNukeExplosion(unit: UnitView, radius: number) { + if (unit.type() === UnitType.AtomBomb) { + SoundManager.playSoundEffect(SoundEffect.AtomHit); + } else if (unit.type() === UnitType.HydrogenBomb) { + SoundManager.playSoundEffect(SoundEffect.HydroHit); + } else if (unit.type() === UnitType.MIRVWarhead) { + SoundManager.playSoundEffect(SoundEffect.MirvHit); + } + const x = this.game.x(unit.lastTile()); const y = this.game.y(unit.lastTile()); const nukeFx = nukeFxFactory( diff --git a/src/client/sound/SoundManager.ts b/src/client/sound/SoundManager.ts index 053b84c34..666ce8109 100644 --- a/src/client/sound/SoundManager.ts +++ b/src/client/sound/SoundManager.ts @@ -1,4 +1,9 @@ import { Howl } from "howler"; +import atomHitSound from "../../../proprietary/sounds/effects/atom_hit.mp3"; +import atomLaunchSound from "../../../proprietary/sounds/effects/atom_launch.mp3"; +import hydroHitSound from "../../../proprietary/sounds/effects/hydrogen_hit.mp3"; +import hydroLaunchSound from "../../../proprietary/sounds/effects/hydrogen_launch.mp3"; +import mirvLaunchSound from "../../../proprietary/sounds/effects/mirv_launch.mp3"; import of4 from "../../../proprietary/sounds/music/of4.mp3"; import openfront from "../../../proprietary/sounds/music/openfront.mp3"; import war from "../../../proprietary/sounds/music/war.mp3"; @@ -6,6 +11,12 @@ import kaChingSound from "../../../resources/sounds/effects/ka-ching.mp3"; export enum SoundEffect { KaChing = "ka-ching", + AtomLaunch = "atom_launch", + AtomHit = "atom_hit", + HydroLaunch = "hydro_launch", + HydroHit = "hydro_hit", + MirvHit = "mirv_hit", + MirvLaunch = "mirv_launch", } class SoundManager { @@ -37,6 +48,12 @@ class SoundManager { }), ]; this.loadSoundEffect(SoundEffect.KaChing, kaChingSound); + this.loadSoundEffect(SoundEffect.AtomLaunch, atomLaunchSound); + this.loadSoundEffect(SoundEffect.AtomHit, atomHitSound); + this.loadSoundEffect(SoundEffect.HydroLaunch, hydroLaunchSound); + this.loadSoundEffect(SoundEffect.HydroHit, hydroHitSound); + this.loadSoundEffect(SoundEffect.MirvHit, atomHitSound); + this.loadSoundEffect(SoundEffect.MirvLaunch, mirvLaunchSound); } public playBackgroundMusic(): void {