2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("AttributeEffect", test => {
|
2017-11-14 00:07:06 +00:00
|
|
|
test.case("applies cumulatively on attribute", check => {
|
|
|
|
let battle = new Battle();
|
|
|
|
let ship = battle.fleets[0].addShip();
|
|
|
|
check.equals(ship.getAttribute("maneuvrability"), 0, "initial");
|
2017-04-18 22:55:59 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
let effect1 = new AttributeEffect("maneuvrability", 20);
|
2018-03-20 23:23:00 +00:00
|
|
|
battle.applyDiffs(effect1.getOnDiffs(ship, ship));
|
2017-11-14 00:07:06 +00:00
|
|
|
check.equals(ship.getAttribute("maneuvrability"), 20, "applied 1");
|
2017-04-18 22:55:59 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
let effect2 = new AttributeEffect("maneuvrability", 10);
|
2018-03-20 23:23:00 +00:00
|
|
|
battle.applyDiffs(effect2.getOnDiffs(ship, ship));
|
2017-11-14 00:07:06 +00:00
|
|
|
check.equals(ship.getAttribute("maneuvrability"), 30, "applied 2");
|
|
|
|
|
2017-11-29 22:03:58 +00:00
|
|
|
battle.applyDiffs(effect1.getOffDiffs(ship));
|
2017-11-14 00:07:06 +00:00
|
|
|
check.equals(ship.getAttribute("maneuvrability"), 10, "reverted 1");
|
|
|
|
|
2017-11-29 22:03:58 +00:00
|
|
|
battle.applyDiffs(effect2.getOffDiffs(ship));
|
2017-11-14 00:07:06 +00:00
|
|
|
check.equals(ship.getAttribute("maneuvrability"), 0, "reverted 2");
|
2017-04-18 22:55:59 +00:00
|
|
|
});
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("has a description", check => {
|
2017-06-11 20:44:12 +00:00
|
|
|
let effect = new AttributeEffect("maneuvrability", 12);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(effect.getDescription(), "maneuvrability +12");
|
2017-04-18 22:55:59 +00:00
|
|
|
|
|
|
|
effect = new AttributeEffect("shield_capacity", -4);
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(effect.getDescription(), "shield capacity -4");
|
2017-04-18 22:55:59 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|