Fixed some active effects display issues
This commit is contained in:
parent
1649096209
commit
d4ae153685
1
TODO
1
TODO
|
@ -15,6 +15,7 @@
|
|||
* Equipment: add critical hit/miss
|
||||
* Equipment: add damage over time effect
|
||||
* Menu: allow to delete cloud saves
|
||||
* Fix cloud save games with "Level 0 - 0 ships"
|
||||
* Arena: display effects description instead of attribute changes
|
||||
* Arena: display radius for area effects (both on action hover, and while action is active)
|
||||
* Arena: any displayed info should be based on a ship copy stored in ArenaShip, and in sync with current log index (not the game state ship)
|
||||
|
|
|
@ -298,6 +298,15 @@ module TS.SpaceTac {
|
|||
result.push(event);
|
||||
});
|
||||
|
||||
// Simulate active effects
|
||||
this.play_order.forEach(ship => {
|
||||
if (ship.alive) {
|
||||
let event = ship.getActiveEffects();
|
||||
event.initial = true;
|
||||
result.push(event);
|
||||
}
|
||||
});
|
||||
|
||||
// Indicate emergency stasis
|
||||
this.play_order.forEach(ship => {
|
||||
if (!ship.alive) {
|
||||
|
|
|
@ -27,7 +27,7 @@ module TS.SpaceTac {
|
|||
} else {
|
||||
expect(got.target.y).toBeCloseTo(target_y, 0.000001);
|
||||
}
|
||||
} else {
|
||||
} else if (target_ship || target_x || target_y) {
|
||||
fail("Got no target");
|
||||
}
|
||||
}
|
||||
|
@ -76,12 +76,15 @@ module TS.SpaceTac {
|
|||
let playing = nn(battle.playing_ship);
|
||||
|
||||
let result = battle.getBootstrapEvents();
|
||||
expect(result.length).toBe(9);
|
||||
expect(result.length).toBe(17);
|
||||
for (var i = 0; i < 8; i++) {
|
||||
checkEvent(result[i], battle.play_order[i], "move", null,
|
||||
battle.play_order[i].arena_x, battle.play_order[i].arena_y);
|
||||
}
|
||||
checkEvent(result[8], playing, "ship_change", playing);
|
||||
for (var i = 0; i < 8; i++) {
|
||||
checkEvent(result[8 + i], battle.play_order[i], "activeeffects");
|
||||
}
|
||||
checkEvent(result[16], playing, "ship_change", playing);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -298,10 +298,11 @@ module TS.SpaceTac.Specs {
|
|||
ship.addDamage(5, 0);
|
||||
|
||||
expect(ship.alive).toBe(false);
|
||||
expect(battle.log.events.length).toBe(3);
|
||||
expect(battle.log.events.length).toBe(4);
|
||||
expect(battle.log.events[0].code).toEqual("value");
|
||||
expect(battle.log.events[1].code).toEqual("damage");
|
||||
expect(battle.log.events[2].code).toEqual("death");
|
||||
expect(battle.log.events[2].code).toEqual("activeeffects");
|
||||
expect(battle.log.events[3].code).toEqual("death");
|
||||
});
|
||||
|
||||
it("checks if a ship is able to play", function () {
|
||||
|
|
|
@ -237,7 +237,7 @@ module TS.SpaceTac {
|
|||
diff = val.set(value);
|
||||
}
|
||||
|
||||
if (log && diff != 0) {
|
||||
if (log && diff != 0 && this.alive) {
|
||||
this.addBattleEvent(new ValueChangeEvent(this, val, diff));
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ module TS.SpaceTac {
|
|||
this.setValueCapacity("hull", attr.get());
|
||||
}
|
||||
|
||||
if (log && diff != 0) {
|
||||
if (log && diff != 0 && this.alive) {
|
||||
this.addBattleEvent(new ValueChangeEvent(this, attr, diff));
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ module TS.SpaceTac {
|
|||
* Clean sticky effects that are no longer active
|
||||
*/
|
||||
cleanStickyEffects() {
|
||||
let [active, ended] = binpartition(this.sticky_effects, effect => effect.duration > 0);
|
||||
let [active, ended] = binpartition(this.sticky_effects, effect => this.alive && effect.duration > 0);
|
||||
this.sticky_effects = active;
|
||||
if (ended.length) {
|
||||
this.setActiveEffectsChanged();
|
||||
|
@ -486,12 +486,18 @@ module TS.SpaceTac {
|
|||
}
|
||||
}
|
||||
|
||||
// Set the death status on this ship
|
||||
/**
|
||||
* Set the death status on this ship
|
||||
*/
|
||||
setDead(log: boolean = true): void {
|
||||
this.alive = false;
|
||||
this.values.hull.set(0);
|
||||
this.values.shield.set(0);
|
||||
this.values.power.set(0);
|
||||
|
||||
this.sticky_effects = [];
|
||||
this.setActiveEffectsChanged();
|
||||
|
||||
if (log) {
|
||||
this.addBattleEvent(new DeathEvent(this));
|
||||
}
|
||||
|
@ -672,9 +678,9 @@ module TS.SpaceTac {
|
|||
|
||||
// Update attributes, taking into account attached equipment and active effects
|
||||
updateAttributes(): void {
|
||||
if (this.alive) {
|
||||
var new_attrs = new ShipAttributes();
|
||||
let new_attrs = new ShipAttributes();
|
||||
|
||||
if (this.alive) {
|
||||
// TODO better typing for iteritems
|
||||
|
||||
// Apply base skills
|
||||
|
@ -691,12 +697,12 @@ module TS.SpaceTac {
|
|||
this.collectEffects("attrlimit").forEach((effect: AttributeLimitEffect) => {
|
||||
new_attrs[effect.attrcode].setMaximal(effect.value);
|
||||
});
|
||||
|
||||
// Set final attributes
|
||||
iteritems(<any>new_attrs, (key, value) => {
|
||||
this.setAttribute(<keyof ShipAttributes>key, (<ShipAttribute>value).get());
|
||||
});
|
||||
}
|
||||
|
||||
// Set final attributes
|
||||
iteritems(<any>new_attrs, (key, value) => {
|
||||
this.setAttribute(<keyof ShipAttributes>key, (<ShipAttribute>value).get());
|
||||
});
|
||||
}
|
||||
|
||||
// Fully restore hull and shield
|
||||
|
@ -717,10 +723,12 @@ module TS.SpaceTac {
|
|||
*/
|
||||
getActiveEffects(): ActiveEffectsEvent {
|
||||
let result = new ActiveEffectsEvent(this);
|
||||
result.equipment = flatten(this.slots.map(slot => slot.attached ? slot.attached.effects : []));
|
||||
result.sticky = this.sticky_effects;
|
||||
let battle = this.getBattle();
|
||||
result.area = battle ? imaterialize(battle.iAreaEffects(this.arena_x, this.arena_y)) : [];
|
||||
if (this.alive) {
|
||||
result.equipment = flatten(this.slots.map(slot => slot.attached ? slot.attached.effects : []));
|
||||
result.sticky = this.sticky_effects;
|
||||
let battle = this.getBattle();
|
||||
result.area = battle ? imaterialize(battle.iAreaEffects(this.arena_x, this.arena_y)) : [];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue