From 77582d0be7002abc345061303f45f08e71dc033e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Thu, 23 May 2019 18:34:24 +0200 Subject: [PATCH] Fixed personality reaction not working --- src/ui/battle/LogProcessor.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ui/battle/LogProcessor.ts b/src/ui/battle/LogProcessor.ts index ab1965d..99b6618 100644 --- a/src/ui/battle/LogProcessor.ts +++ b/src/ui/battle/LogProcessor.ts @@ -21,6 +21,9 @@ module TK.SpaceTac.UI { private speed = 1 private temp_speed?: number + // Currently playing ship + playing_ship: Ship | null = null + // Debug indicators private debug = false private ai_disabled = false @@ -43,11 +46,19 @@ module TK.SpaceTac.UI { }); // Internal subscribers - this.register((diff) => this.checkReaction(diff)); - this.register((diff) => this.checkControl(diff)); - this.register((diff) => this.checkProjectileFired(diff)); - this.register((diff) => this.checkShipDeath(diff)); - this.register((diff) => this.checkBattleEnded(diff)); + this.register(diff => { + if (diff instanceof ShipActionUsedDiff) { + this.playing_ship = this.view.battle.getShip(diff.ship_id); + } else if (diff instanceof ShipActionEndedDiff) { + this.playing_ship = null; + } + return {}; + }); + this.register(diff => this.checkReaction(diff)); + this.register(diff => this.checkControl(diff)); + this.register(diff => this.checkProjectileFired(diff)); + this.register(diff => this.checkShipDeath(diff)); + this.register(diff => this.checkBattleEnded(diff)); } /** @@ -164,8 +175,7 @@ module TK.SpaceTac.UI { */ private checkReaction(diff: BaseBattleDiff): LogProcessorDelegate { if (this.log.isPlaying()) { - let playing_ship = null; // FIXME - let reaction = this.view.session.reactions.check(this.view.player, this.view.battle, playing_ship, diff); + let reaction = this.view.session.reactions.check(this.view.player, this.view.battle, this.playing_ship, diff); if (reaction) { return { foreground: async () => {