2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("StarLocation", test => {
|
|
|
|
test.case("removes generated encounters that lose", check => {
|
2017-03-09 17:11:00 +00:00
|
|
|
var location = new StarLocation(undefined, StarLocationType.PLANET, 0, 0);
|
2015-04-21 22:17:00 +00:00
|
|
|
var fleet = new Fleet();
|
2017-07-10 21:40:52 +00:00
|
|
|
fleet.addShip();
|
2017-03-14 22:28:07 +00:00
|
|
|
location.encounter_random = new SkewedRandomGenerator([0]);
|
2017-11-14 00:07:06 +00:00
|
|
|
var battle = nn(location.enterLocation(fleet));
|
2015-04-21 22:17:00 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
check.notequals(location.encounter, null);
|
|
|
|
check.notequals(battle, null);
|
2015-04-21 22:17:00 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.endBattle(fleet);
|
|
|
|
check.notequals(location.encounter, null);
|
2015-04-21 22:17:00 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
location.resolveEncounter(nn(battle.outcome));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(location.encounter, null);
|
2015-04-21 22:17:00 +00:00
|
|
|
});
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("leaves generated encounters that win", check => {
|
2017-03-09 17:11:00 +00:00
|
|
|
var location = new StarLocation(undefined, StarLocationType.PLANET, 0, 0);
|
2015-04-21 22:17:00 +00:00
|
|
|
var fleet = new Fleet();
|
2017-07-10 21:40:52 +00:00
|
|
|
fleet.addShip();
|
2017-03-14 22:28:07 +00:00
|
|
|
location.encounter_random = new SkewedRandomGenerator([0]);
|
2017-11-14 00:07:06 +00:00
|
|
|
var battle = nn(location.enterLocation(fleet));
|
2015-04-21 22:17:00 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
check.notequals(location.encounter, null);
|
|
|
|
check.notequals(battle, null);
|
2015-04-21 22:17:00 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
battle.endBattle(location.encounter);
|
|
|
|
check.notequals(location.encounter, null);
|
2015-04-21 22:17:00 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
location.resolveEncounter(nn(battle.outcome));
|
2017-10-26 21:47:13 +00:00
|
|
|
check.notequals(location.encounter, null);
|
2015-04-21 22:17:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|