Don't early return if no myPlayer, so we can still play nuke sounds in a replay (and possibly others in the future that are not local-player bound)

This commit is contained in:
VariableVince
2026-05-23 22:56:22 +02:00
parent 8991b80dae
commit 2f3abfdae3
+10 -7
View File
@@ -28,19 +28,22 @@ export class SoundController implements Controller {
if ((gu.pendingTurns ?? 0) > 1 || this.view.ticks() <= 0) return;
const myPlayer = this.view.myPlayer();
if (!myPlayer) return;
// 1. Process Conquests
gu.updates[GameUpdateType.ConquestEvent]?.forEach((cu: ConquestUpdate) => {
if (cu.conquerorId === myPlayer.id()) {
this.eventBus.emit(new PlaySoundEffectEvent(SoundEffect.KaChing));
}
});
if (myPlayer) {
gu.updates[GameUpdateType.ConquestEvent]?.forEach(
(cu: ConquestUpdate) => {
if (cu.conquerorId === myPlayer.id()) {
this.eventBus.emit(new PlaySoundEffectEvent(SoundEffect.KaChing));
}
},
);
}
// 2. Process Units
gu.updates[GameUpdateType.Unit]?.forEach((u: UnitUpdate) => {
const existingUnit = this.view.unit(u.id);
const isMine = u.ownerID === myPlayer.smallID();
const isMine = myPlayer ? u.ownerID === myPlayer.smallID() : false;
if (!existingUnit) {
this.handleNewUnitSounds(u.unitType, isMine);