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 => {
|
2017-06-22 23:04:54 +00:00
|
|
|
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);
|
2017-06-22 23:04:54 +00:00
|
|
|
|
|
|
|
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);
|
2017-06-22 23:04:54 +00:00
|
|
|
|
|
|
|
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, [
|
2017-06-22 23:04:54 +00:00
|
|
|
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);
|
2017-06-22 23:04:54 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|