Fixed targetting hints
This commit is contained in:
parent
355ee74026
commit
1ca152358c
|
@ -1 +1 @@
|
||||||
Subproject commit 9b05b53c998b177a49a3dd43542bfa3cb1874af1
|
Subproject commit fea005d01bbaad19c42bf5d446a7cfaa1ee977a6
|
|
@ -90,7 +90,7 @@ module TK.SpaceTac.Specs {
|
||||||
|
|
||||||
cooldown.cool();
|
cooldown.cool();
|
||||||
check.equals(action.checkCannotBeApplied(ship), null);
|
check.equals(action.checkCannotBeApplied(ship), null);
|
||||||
})
|
});
|
||||||
|
|
||||||
test.case("helps applying a targetting filter", check => {
|
test.case("helps applying a targetting filter", check => {
|
||||||
let fleet1 = new Fleet();
|
let fleet1 = new Fleet();
|
||||||
|
@ -112,5 +112,37 @@ module TK.SpaceTac.Specs {
|
||||||
check.equals(BaseAction.filterTargets(ship1a, ships, ActionTargettingFilter.ENEMIES),
|
check.equals(BaseAction.filterTargets(ship1a, ships, ActionTargettingFilter.ENEMIES),
|
||||||
[ship2a, ship2b], "ENEMIES");
|
[ship2a, ship2b], "ENEMIES");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.case("applies targetting mode when checking targets", check => {
|
||||||
|
let ship1 = new Ship();
|
||||||
|
let ship2 = new Ship();
|
||||||
|
let action = ship1.actions.addCustom(new BaseAction());
|
||||||
|
|
||||||
|
let mode = ActionTargettingMode.SELF;
|
||||||
|
check.patch(action, "getTargettingMode", () => mode);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship1)), true);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship2)), false);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromLocation(0, 0)), false);
|
||||||
|
|
||||||
|
mode = ActionTargettingMode.SELF_CONFIRM;
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship1)), true);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship2)), false);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromLocation(0, 0)), false);
|
||||||
|
|
||||||
|
mode = ActionTargettingMode.SHIP;
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship1)), true);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship2)), true);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromLocation(0, 0)), false);
|
||||||
|
|
||||||
|
mode = ActionTargettingMode.SPACE;
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship1)), false);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship2)), false);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromLocation(0, 0)), true);
|
||||||
|
|
||||||
|
mode = ActionTargettingMode.SURROUNDINGS;
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship1)), true);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromShip(ship2)), false);
|
||||||
|
check.equals(action.checkTarget(ship1, Target.newFromLocation(0, 0)), false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,10 +264,19 @@ module TK.SpaceTac.UI {
|
||||||
let grid = this.ship.grid;
|
let grid = this.ship.grid;
|
||||||
let action = this.action;
|
let action = this.action;
|
||||||
let simulator = new MoveFireSimulator(this.ship, grid);
|
let simulator = new MoveFireSimulator(this.ship, grid);
|
||||||
this.grid_work = imap(grid.iterate(this.ship.location), (loc): [IArenaLocation, MoveFireResult] => {
|
let mode = action.getTargettingMode(this.ship);
|
||||||
let target = Target.newFromLocation(loc.x, loc.y);
|
if (mode == ActionTargettingMode.SPACE || mode == ActionTargettingMode.SURROUNDINGS) {
|
||||||
return [loc, simulator.simulateAction(action, target)];
|
this.grid_work = imap(grid.iterate(this.ship.location), (loc): [IArenaLocation, MoveFireResult] => {
|
||||||
})[Symbol.iterator]();
|
let target = (mode == ActionTargettingMode.SURROUNDINGS) ? new Target(loc.x, loc.y, this.ship) : Target.newFromLocation(loc.x, loc.y);
|
||||||
|
return [loc, simulator.simulateAction(action, target)];
|
||||||
|
})[Symbol.iterator]();
|
||||||
|
} else {
|
||||||
|
let battle = nn(this.ship.getBattle());
|
||||||
|
this.grid_work = imap(battle.iships(true), (iship): [IArenaLocation, MoveFireResult] => {
|
||||||
|
let target = Target.newFromShip(iship);
|
||||||
|
return [iship.location, simulator.simulateAction(action, target)];
|
||||||
|
})[Symbol.iterator]();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.grid_work = IATEND;
|
this.grid_work = IATEND;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue