Fixed endTurn not being called by AI and ships with no AP
This commit is contained in:
parent
125ed792fb
commit
a4649d696f
1
TODO
1
TODO
|
@ -1,5 +1,4 @@
|
|||
* Add auto-move to attack
|
||||
* Fix energy depleter effect not fading after one turn
|
||||
* Add equipment info (or summary) in ship tooltip
|
||||
* Handle effects overflowing ship tooltip when too numerous
|
||||
* Proper arena scaling (not graphical, only space coordinates)
|
||||
|
|
|
@ -166,6 +166,10 @@ module SpaceTac.Game {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.playing_ship && this.playing_ship.playing) {
|
||||
this.playing_ship.endTurn();
|
||||
}
|
||||
|
||||
if (this.play_order.length === 0) {
|
||||
this.playing_ship_index = null;
|
||||
this.playing_ship = null;
|
||||
|
@ -196,6 +200,7 @@ module SpaceTac.Game {
|
|||
if (!this.playing_ship.isAbleToPlay()) {
|
||||
// If the ship is not able to play, wait a little, then advance to the next one
|
||||
setTimeout(() => {
|
||||
this.playing_ship.endTurn();
|
||||
this.advanceToNextShip(log);
|
||||
}, 2000);
|
||||
} else if (this.playing_ship.getPlayer().ai) {
|
||||
|
|
|
@ -132,6 +132,7 @@ module SpaceTac.Game.Specs {
|
|||
new EffectAddedEvent(ship, effect)
|
||||
]);
|
||||
|
||||
ship.startTurn();
|
||||
battle.log.clear();
|
||||
ship.endTurn();
|
||||
|
||||
|
@ -140,6 +141,7 @@ module SpaceTac.Game.Specs {
|
|||
new EffectDurationChangedEvent(ship, new TemporaryEffect("test", 1), 2)
|
||||
]);
|
||||
|
||||
ship.startTurn();
|
||||
battle.log.clear();
|
||||
ship.endTurn();
|
||||
|
||||
|
@ -148,6 +150,7 @@ module SpaceTac.Game.Specs {
|
|||
new EffectRemovedEvent(ship, new TemporaryEffect("test", 1))
|
||||
]);
|
||||
|
||||
ship.startTurn();
|
||||
battle.log.clear();
|
||||
ship.endTurn();
|
||||
|
||||
|
@ -247,9 +250,9 @@ module SpaceTac.Game.Specs {
|
|||
expect(ship.ap_current.current).toBe(5);
|
||||
ship.ap_current.set(2);
|
||||
expect(ship.ap_current.current).toBe(2);
|
||||
ship.endTurn();
|
||||
ship.recoverActionPoints();
|
||||
expect(ship.ap_current.current).toBe(6);
|
||||
ship.endTurn();
|
||||
ship.recoverActionPoints();
|
||||
expect(ship.ap_current.current).toBe(8);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -60,6 +60,9 @@ module SpaceTac.Game {
|
|||
// Collection of available attributes
|
||||
attributes: AttributeCollection;
|
||||
|
||||
// Boolean set to true if the ship is currently playing its turn
|
||||
playing = false;
|
||||
|
||||
// Create a new ship inside a fleet
|
||||
constructor(fleet: Fleet = null, name: string = null) {
|
||||
super();
|
||||
|
@ -222,6 +225,12 @@ module SpaceTac.Game {
|
|||
|
||||
// Method called at the start of this ship turn
|
||||
startTurn(): void {
|
||||
if (this.playing) {
|
||||
console.error("startTurn called twice", this);
|
||||
return;
|
||||
}
|
||||
this.playing = true;
|
||||
|
||||
// Recompute attributes
|
||||
this.updateAttributes();
|
||||
|
||||
|
@ -233,6 +242,12 @@ module SpaceTac.Game {
|
|||
|
||||
// Method called at the end of this ship turn
|
||||
endTurn(): void {
|
||||
if (!this.playing) {
|
||||
console.error("endTurn called before startTurn", this);
|
||||
return;
|
||||
}
|
||||
this.playing = false;
|
||||
|
||||
// Recover action points for next turn
|
||||
this.recoverActionPoints();
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ module SpaceTac.Game.AI {
|
|||
return;
|
||||
}
|
||||
}
|
||||
this.ship.endTurn();
|
||||
this.ship = null;
|
||||
this.fleet.battle.advanceToNextShip();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue