1
0
Fork 0
spacetac/src/core/effects/AttributeLimitEffect.spec.ts

33 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac {
2017-10-26 21:47:13 +00:00
testing("AttributeLimitEffect", test => {
test.case("limits an attribute", check => {
let battle = new Battle();
let ship = battle.fleets[0].addShip();
2017-10-26 21:47:13 +00:00
check.equals(ship.getAttribute("shield_capacity"), 0);
check.equals(ship.getValue("shield"), 0);
TestTools.setShipHP(ship, 100, 50);
ship.setValue("shield", 40);
2017-10-26 21:47:13 +00:00
check.equals(ship.getAttribute("shield_capacity"), 50);
check.equals(ship.getValue("shield"), 40);
battle.log.clear();
let effect = new StickyEffect(new AttributeLimitEffect("shield_capacity", 30));
ship.addStickyEffect(effect);
2017-10-26 21:47:13 +00:00
check.equals(ship.getAttribute("shield_capacity"), 30);
check.equals(ship.getValue("shield"), 30);
check.equals(battle.log.events, [
new ActiveEffectsEvent(ship, [new AttributeEffect("hull_capacity", 100), new AttributeEffect("shield_capacity", 50)], [effect]),
new ValueChangeEvent(ship, new ShipValue("shield", 30, 50), -10),
new ValueChangeEvent(ship, new ShipAttribute("shield capacity", 30), -20),
]);
ship.cleanStickyEffects();
2017-10-26 21:47:13 +00:00
check.equals(ship.getAttribute("shield_capacity"), 50);
check.equals(ship.getValue("shield"), 30);
});
});
}