ai: Guess area effects at the final ship location
This commit is contained in:
parent
ff5ded689b
commit
c7799ce1e3
1
TODO
1
TODO
|
@ -45,7 +45,6 @@
|
|||
* AI: add combination of random small move and actual maneuver, as producer
|
||||
* AI: new duel page with producers/evaluators tweaking
|
||||
* AI: work in a dedicated process
|
||||
* AI: evaluate area effects at ship location
|
||||
* Map: remove jump links that cross the radius of other systems
|
||||
* Map: disable interaction (zoom, selection) while moving/jumping
|
||||
* Tutorial
|
||||
|
|
|
@ -38,5 +38,25 @@ module TS.SpaceTac.Specs {
|
|||
[ship2, new ValueEffect("shield", 10)]
|
||||
]);
|
||||
});
|
||||
|
||||
it("guesses area effects on final location", function () {
|
||||
let battle = new Battle();
|
||||
let ship = battle.fleets[0].addShip();
|
||||
TestTools.addEngine(ship, 500);
|
||||
let drone = new Drone(ship);
|
||||
drone.effects = [new AttributeEffect("initiative", 1)];
|
||||
drone.x = 100;
|
||||
drone.y = 0;
|
||||
drone.radius = 50;
|
||||
battle.addDrone(drone);
|
||||
|
||||
let maneuver = new Maneuver(ship, new MoveAction(new Equipment()), Target.newFromLocation(40, 30));
|
||||
expect(maneuver.getFinalLocation()).toEqual(jasmine.objectContaining({ x: 40, y: 30 }));
|
||||
expect(maneuver.effects).toEqual([]);
|
||||
|
||||
maneuver = new Maneuver(ship, new MoveAction(new Equipment()), Target.newFromLocation(100, 30));
|
||||
expect(maneuver.getFinalLocation()).toEqual(jasmine.objectContaining({ x: 100, y: 30 }));
|
||||
expect(maneuver.effects).toEqual([[ship, new AttributeEffect("initiative", 1)]]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ module TS.SpaceTac {
|
|||
guessEffects(): [Ship, BaseEffect][] {
|
||||
let result: [Ship, BaseEffect][] = [];
|
||||
|
||||
// Effects of weapon
|
||||
if (this.action instanceof FireWeaponAction) {
|
||||
result = result.concat(this.action.getEffects(this.ship, this.target));
|
||||
} else if (this.action instanceof DeployDroneAction) {
|
||||
|
@ -92,6 +93,14 @@ module TS.SpaceTac {
|
|||
});
|
||||
}
|
||||
|
||||
// Area effects on final location
|
||||
let location = this.getFinalLocation();
|
||||
let effects = this.battle.drones.forEach(drone => {
|
||||
if (Target.newFromLocation(location.x, location.y).isInRange(drone.x, drone.y, drone.radius)) {
|
||||
result = result.concat(drone.effects.map(effect => <[Ship, BaseEffect]>[this.ship, effect]));
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue