1
0
Fork 0

Changed ship initiative to be a proper Attribute

This commit is contained in:
Michaël Lemaire 2015-01-23 01:00:00 +01:00 committed by Michaël Lemaire
parent 04035cce8c
commit caf4e82515
5 changed files with 14 additions and 13 deletions

View file

@ -53,7 +53,7 @@ module SpaceTac.Game {
// Sort by throw result
play_order.sort(function (ship1: Ship, ship2: Ship) {
return (ship2.initative_throw - ship1.initative_throw);
return (ship2.initiative.current - ship1.initiative.current);
});
this.play_order = play_order;
}

View file

@ -25,11 +25,8 @@ module SpaceTac.Game {
// Facing direction in the arena
arena_angle: number;
// Current initiative level (high numbers will allow this ship to play sooner)
initiative_level: number;
// Last initiative throw
initative_throw: number;
// Initiative (high numbers will allow this ship to play sooner)
initiative: Attribute;
// Current number of action points
ap_current: Attribute;
@ -54,7 +51,8 @@ module SpaceTac.Game {
this.attributes = new AttributeCollection();
this.fleet = fleet;
this.name = name;
this.initiative_level = 1;
this.initiative = this.newAttribute(AttributeCode.Initiative);
this.initiative.setMaximal(1);
this.ap_current = this.newAttribute(AttributeCode.AP);
this.ap_initial = this.newAttribute(AttributeCode.AP_Initial);
this.ap_recover = this.newAttribute(AttributeCode.AP_Recovery);
@ -90,7 +88,7 @@ module SpaceTac.Game {
// Make an initiative throw, to resolve play order in a battle
throwInitiative(gen: RandomGenerator): void {
this.initative_throw = gen.throw(this.initiative_level);
this.initiative.set(gen.throw(this.initiative.maximal));
}
// Return the player owning this ship
@ -227,6 +225,7 @@ module SpaceTac.Game {
this.collectEffects("attrmax").forEach((effect: AttributeMaxEffect) => {
new_attrs.addValue(effect.attrcode, effect.value);
});
this.initiative.setMaximal(new_attrs.getValue(AttributeCode.Initiative));
this.ap_current.setMaximal(new_attrs.getValue(AttributeCode.AP));
// Compute new current values for attributes

View file

@ -9,6 +9,7 @@ module SpaceTac.Game.Equipments {
this.min_level = new IntegerRange(1, 1);
this.addPermanentAttributeMaxEffect(AttributeCode.Initiative, 1);
this.addPermanentAttributeMaxEffect(AttributeCode.AP, 8);
this.addPermanentAttributeValueEffect(AttributeCode.AP_Initial, 5);
this.addPermanentAttributeValueEffect(AttributeCode.AP_Recovery, 4);

View file

@ -9,6 +9,7 @@ module SpaceTac.Game.Equipments {
super(SlotType.Engine, "Conventional Engine");
this.min_level = new IntegerRange(1, 1);
this.addPermanentAttributeMaxEffect(AttributeCode.Initiative, 1);
}
protected getActionForEquipment(equipment: Equipment): BaseAction {

View file

@ -9,15 +9,15 @@ module SpaceTac.Game {
var fleet2 = new Fleet(null);
var ship1 = new Ship(fleet1, "F1S1");
ship1.initiative_level = 2;
ship1.initiative.setMaximal(2);
var ship2 = new Ship(fleet1, "F1S2");
ship2.initiative_level = 4;
ship2.initiative.setMaximal(4);
var ship3 = new Ship(fleet1, "F1S3");
ship3.initiative_level = 1;
ship3.initiative.setMaximal(1);
var ship4 = new Ship(fleet2, "F2S1");
ship4.initiative_level = 8;
ship4.initiative.setMaximal(8);
var ship5 = new Ship(fleet2, "F2S2");
ship5.initiative_level = 2;
ship5.initiative.setMaximal(2);
var battle = new Battle(fleet1, fleet2);
expect(battle.play_order.length).toBe(0);