diff --git a/src/scripts/game/Battle.ts b/src/scripts/game/Battle.ts index d2852cb..663d2e2 100644 --- a/src/scripts/game/Battle.ts +++ b/src/scripts/game/Battle.ts @@ -105,6 +105,10 @@ module SpaceTac.Game { }); this.placeShips(); this.throwInitiative(); + this.play_order.forEach((ship: Ship) => { + ship.updateAttributes(); + ship.restoreHealth(); + }); this.advanceToNextShip(false); } diff --git a/src/scripts/game/equipments/GatlingGun.ts b/src/scripts/game/equipments/GatlingGun.ts index de806e3..c7e3353 100644 --- a/src/scripts/game/equipments/GatlingGun.ts +++ b/src/scripts/game/equipments/GatlingGun.ts @@ -6,9 +6,9 @@ module SpaceTac.Game.Equipments { // Equipment: Gatling Gun export class GatlingGun extends AbstractWeapon { constructor() { - super("Gatling Gun", 10, 20); + super("Gatling Gun", 50, 100); - this.setRange(80, 150, false); + this.setRange(300, 300, false); this.ap_usage = new Range(3, 4); this.min_level = new IntegerRange(1, 3); diff --git a/src/scripts/game/events/AttributeChangeEvent.ts b/src/scripts/game/events/AttributeChangeEvent.ts index c1618b6..80cf2be 100644 --- a/src/scripts/game/events/AttributeChangeEvent.ts +++ b/src/scripts/game/events/AttributeChangeEvent.ts @@ -5,8 +5,13 @@ module SpaceTac.Game { // Event logged when a ship moves export class AttributeChangeEvent extends BaseLogEvent { + // Saved version of the attribute + attribute: Attribute; + constructor(ship: Ship, attribute: Attribute) { super("attr", ship); + + this.attribute = Tools.copyObject(attribute); } } } diff --git a/src/scripts/view/battle/LogProcessor.ts b/src/scripts/view/battle/LogProcessor.ts index b795563..f7acfea 100644 --- a/src/scripts/view/battle/LogProcessor.ts +++ b/src/scripts/view/battle/LogProcessor.ts @@ -40,12 +40,18 @@ module SpaceTac.View { this.view.action_bar.setShip(event.target.ship); break; case "move": - var move_event: Game.MoveEvent = event; + var move_event = event; var sprite = this.view.arena.findShipSprite(move_event.ship); if (sprite) { sprite.moveTo(move_event.target.x, move_event.target.y, move_event.facing_angle, true); } break; + case "attr": + var attr_event = event; + var item = this.view.ship_list.findItem(attr_event.ship); + if (item) { + item.attributeChanged(attr_event.attribute); + } } } diff --git a/src/scripts/view/battle/ShipList.ts b/src/scripts/view/battle/ShipList.ts index 2803e81..5e365d9 100644 --- a/src/scripts/view/battle/ShipList.ts +++ b/src/scripts/view/battle/ShipList.ts @@ -54,5 +54,17 @@ module SpaceTac.View { this.add(result); return result; } + + // Find an item for a ship + // Returns null if not found + findItem(ship: Game.Ship): ShipListItem { + var found: ShipListItem = null; + this.ships.forEach((item: ShipListItem) => { + if (item.ship === ship) { + found = item; + } + }); + return found; + } } } diff --git a/src/scripts/view/battle/ShipListItem.ts b/src/scripts/view/battle/ShipListItem.ts index 4acb96b..7eb5834 100644 --- a/src/scripts/view/battle/ShipListItem.ts +++ b/src/scripts/view/battle/ShipListItem.ts @@ -4,7 +4,13 @@ module SpaceTac.View { // One item in a ship list (used in BattleView) export class ShipListItem extends Phaser.Button { // Reference to the ship game object - private ship: Game.Ship; + ship: Game.Ship; + + // Hull display + hull: ValueBar; + + // Shield display + shield: ValueBar; // Create a ship button for the battle ship list constructor(list: ShipList, x: number, y: number, ship: Game.Ship, owned: boolean) { @@ -19,6 +25,23 @@ module SpaceTac.View { this.onInputOut.add(() => { list.battleview.cursorOffShip(ship); }); + + this.hull = ValueBar.newStandard(list.battleview.game, 40, 0); + this.hull.scale.set(0.1, 0.1); + this.addChild(this.hull); + + this.shield = ValueBar.newStandard(list.battleview.game, 40, 20); + this.shield.scale.set(0.1, 0.1); + this.addChild(this.shield); + } + + // Called when an attribute for this ship changed through the battle log + attributeChanged(attribute: Game.Attribute): void { + if (attribute.code === Game.AttributeCode.Hull) { + this.hull.setValue(attribute.current, attribute.maximal); + } else if (attribute.code === Game.AttributeCode.Shield) { + this.shield.setValue(attribute.current, attribute.maximal); + } } } }