2017-10-02 16:02:30 +00:00
|
|
|
module TK.SpaceTac {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("CooldownEffect", test => {
|
|
|
|
test.case("cools down equipment", check => {
|
2017-11-14 00:07:06 +00:00
|
|
|
let battle = new Battle();
|
|
|
|
let ship = battle.fleets[0].addShip();
|
2017-10-02 16:02:30 +00:00
|
|
|
let weapons = [TestTools.addWeapon(ship), TestTools.addWeapon(ship), TestTools.addWeapon(ship)];
|
|
|
|
weapons.forEach(weapon => weapon.cooldown.configure(1, 3));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(weapons.map(weapon => weapon.cooldown.heat), [0, 0, 0]);
|
2017-10-02 16:02:30 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
let effect = new CooldownEffect(0, 0);
|
|
|
|
battle.applyDiffs(effect.getOnDiffs(ship, ship));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(weapons.map(weapon => weapon.cooldown.heat), [0, 0, 0]);
|
2017-10-02 16:02:30 +00:00
|
|
|
|
|
|
|
weapons.forEach(weapon => weapon.cooldown.use());
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(weapons.map(weapon => weapon.cooldown.heat), [3, 3, 3]);
|
2017-10-02 16:02:30 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.applyDiffs(effect.getOnDiffs(ship, ship));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(weapons.map(weapon => weapon.cooldown.heat), [0, 0, 0]);
|
2017-10-02 16:02:30 +00:00
|
|
|
|
|
|
|
weapons.forEach(weapon => weapon.cooldown.use());
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(weapons.map(weapon => weapon.cooldown.heat), [3, 3, 3]);
|
2017-10-02 16:02:30 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
effect = new CooldownEffect(1, 0);
|
|
|
|
battle.applyDiffs(effect.getOnDiffs(ship, ship));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(weapons.map(weapon => weapon.cooldown.heat), [2, 2, 2]);
|
2017-10-02 16:02:30 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
effect = new CooldownEffect(1, 2);
|
|
|
|
battle.applyDiffs(effect.getOnDiffs(ship, ship));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(weapons.map(weapon => weapon.cooldown.heat).sort(), [1, 1, 2]);
|
2017-10-02 16:02:30 +00:00
|
|
|
})
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("builds a textual description", check => {
|
|
|
|
check.equals(new CooldownEffect(0, 0).getDescription(), "Full cooling (all equipments)");
|
|
|
|
check.equals(new CooldownEffect(1, 1).getDescription(), "1 cooling (1 equipment)");
|
|
|
|
check.equals(new CooldownEffect(2, 2).getDescription(), "2 cooling (2 equipments)");
|
2017-10-02 16:02:30 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|