1
0
Fork 0

Fixed personality reaction not working

This commit is contained in:
Michaël Lemaire 2019-05-23 18:34:24 +02:00
parent bc32e7d81a
commit 77582d0be7

View file

@ -21,6 +21,9 @@ module TK.SpaceTac.UI {
private speed = 1 private speed = 1
private temp_speed?: number private temp_speed?: number
// Currently playing ship
playing_ship: Ship | null = null
// Debug indicators // Debug indicators
private debug = false private debug = false
private ai_disabled = false private ai_disabled = false
@ -43,11 +46,19 @@ module TK.SpaceTac.UI {
}); });
// Internal subscribers // Internal subscribers
this.register((diff) => this.checkReaction(diff)); this.register(diff => {
this.register((diff) => this.checkControl(diff)); if (diff instanceof ShipActionUsedDiff) {
this.register((diff) => this.checkProjectileFired(diff)); this.playing_ship = this.view.battle.getShip(diff.ship_id);
this.register((diff) => this.checkShipDeath(diff)); } else if (diff instanceof ShipActionEndedDiff) {
this.register((diff) => this.checkBattleEnded(diff)); 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 { private checkReaction(diff: BaseBattleDiff): LogProcessorDelegate {
if (this.log.isPlaying()) { if (this.log.isPlaying()) {
let playing_ship = null; // FIXME let reaction = this.view.session.reactions.check(this.view.player, this.view.battle, this.playing_ship, diff);
let reaction = this.view.session.reactions.check(this.view.player, this.view.battle, playing_ship, diff);
if (reaction) { if (reaction) {
return { return {
foreground: async () => { foreground: async () => {