1
0
Fork 0
spacetac/src/scripts/game/actions/MoveAction.ts

24 lines
824 B
TypeScript
Raw Normal View History

module SpaceTac.Game {
2014-12-31 00:00:00 +00:00
// Action to move to a given location
export class MoveAction extends BaseAction {
constructor() {
2015-01-06 00:00:00 +00:00
super("move", true);
2014-12-31 00:00:00 +00:00
}
canBeUsed(battle: Battle, ship: Ship): boolean {
return ship.ap_current > 0;
}
checkLocationTarget(battle: Battle, ship: Ship, target: Target): Target {
// TODO Should forbid to move too much near another ship
var coords = ship.getLongestMove(target.x, target.y);
return Target.newFromLocation(coords[0], coords[1]);
}
protected customApply(battle: Battle, ship: Ship, target: Target): boolean {
ship.moveTo(target.x, target.y);
battle.log.add(new MoveEvent(ship, target.x, target.y));
return true;
}
2014-12-31 00:00:00 +00:00
}
}