2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("AttributeLimitEffect", test => {
|
2017-11-14 00:07:06 +00:00
|
|
|
test.case("applies cumulatively on attribute", check => {
|
2017-06-22 23:04:54 +00:00
|
|
|
let battle = new Battle();
|
|
|
|
let ship = battle.fleets[0].addShip();
|
2017-11-14 00:07:06 +00:00
|
|
|
ship.attributes.precision.addModifier(12);
|
|
|
|
check.equals(ship.getAttribute("precision"), 12, "initial");
|
2017-06-22 23:04:54 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
let effect1 = new AttributeLimitEffect("precision", 5);
|
|
|
|
battle.applyDiffs(effect1.getOnDiffs(ship, ship));
|
|
|
|
check.equals(ship.getAttribute("precision"), 5, "applied 1");
|
2017-06-22 23:04:54 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
let effect2 = new AttributeLimitEffect("precision", 3);
|
|
|
|
battle.applyDiffs(effect2.getOnDiffs(ship, ship));
|
|
|
|
check.equals(ship.getAttribute("precision"), 3, "applied 2");
|
2017-06-22 23:04:54 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.applyDiffs(effect1.getOffDiffs(ship, ship));
|
|
|
|
check.equals(ship.getAttribute("precision"), 3, "reverted 1");
|
2017-06-22 23:04:54 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.applyDiffs(effect2.getOffDiffs(ship, ship));
|
|
|
|
check.equals(ship.getAttribute("precision"), 12, "reverted 2");
|
|
|
|
});
|
2017-06-22 23:04:54 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
test.case("has a description", check => {
|
|
|
|
let effect = new AttributeLimitEffect("power_capacity", 4);
|
|
|
|
check.equals(effect.getDescription(), "limit power capacity to 4");
|
2017-06-22 23:04:54 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|