1
0
Fork 0

Fix AI not playing after game loading

This commit is contained in:
Michaël Lemaire 2017-07-20 17:49:47 +02:00
parent 18853f0588
commit cb138eaa20
4 changed files with 24 additions and 5 deletions

View file

@ -37,9 +37,7 @@ Battle
------
* Add a voluntary retreat option
* Fix AI not playing after loading a game where the next ship to play is AI
* Remove dead ships from ship list and play order
* Fix "thinking" rotating icon sometimes not rotating (after loading a game where AI plays for example)
* Add quick animation of playing ship indicator, on ship change
* Display effects description instead of attribute changes
* Display radius and power usage hints for area effects on action icon hover + add confirmation ?

View file

@ -367,5 +367,19 @@ module TS.SpaceTac {
new DamageEffect(12), new AttributeEffect("maneuvrability", 1)
]);
});
it("is serializable", function () {
let battle = Battle.newQuickRandom();
battle.ai_playing = true;
let serializer = new Serializer(TS.SpaceTac);
let data = serializer.serialize(battle);
let loaded = serializer.unserialize(data);
expect(loaded.ai_playing).toBe(false);
battle.ai_playing = false;
expect(loaded).toEqual(battle);
});
});
}

View file

@ -57,10 +57,14 @@ module TS.SpaceTac {
});
}
postUnserialize() {
this.ai_playing = false;
}
// Create a quick random battle, for testing purposes
static newQuickRandom(start = true, level = 1, shipcount = 5): Battle {
var player1 = Player.newQuickRandom("John", level, shipcount, true);
var player2 = Player.newQuickRandom("Carl", level, shipcount, true);
var player1 = Player.newQuickRandom("Player", level, shipcount, true);
var player2 = Player.newQuickRandom("Enemy", level, shipcount, true);
var result = new Battle(player1.fleet, player2.fleet);
if (start) {

View file

@ -20,7 +20,7 @@ module TS.SpaceTac.UI {
ship_power_value: number;
// Interactivity
interactive = false;
interactive = true;
// Create an empty action bar
constructor(battleview: BattleView) {
@ -94,6 +94,8 @@ module TS.SpaceTac.UI {
}
return 0;
});
this.setInteractive(false);
}
/**
@ -111,6 +113,7 @@ module TS.SpaceTac.UI {
this.interactive = interactive;
this.game.tweens.removeFrom(this.icon_waiting);
this.icon_waiting.angle = 0;
this.battleview.animations.setVisible(this.icon_waiting, !this.interactive, 100);
this.game.tweens.create(this.icon_waiting).to({ "angle": 360 }, 3000).loop().start();