diff --git a/TODO b/TODO index a62ebac..b589cef 100644 --- a/TODO +++ b/TODO @@ -16,7 +16,6 @@ * Controls: Do not focus on ship while targetting for area effects (dissociate hover and target) * Active effects are not enough visible in ship list (maybe better in arena ?) * All things displayed in battle should be updated from LogProcess forwarding, not from current game state -* Drones: add tooltip * Drones: add hull points and take area damage * Show power usage/recovery in action bar, on action hover * More sound effects (but battle sounds should be vibration only, we are in space !) diff --git a/src/core/Drone.spec.ts b/src/core/Drone.spec.ts index d853017..5ef6f0a 100644 --- a/src/core/Drone.spec.ts +++ b/src/core/Drone.spec.ts @@ -140,5 +140,18 @@ module TS.SpaceTac { new DroneAppliedEvent(drone, [other]) ]); }); + + it("builds a textual description", function () { + let drone = new Drone(new Ship()); + drone.duration = 1; + expect(drone.getDescription()).toEqual("For 1 turn:\n• do nothing"); + + drone.duration = 3; + drone.effects = [ + new DamageEffect(5), + new AttributeEffect("skill_human", 1) + ] + expect(drone.getDescription()).toEqual("For 3 turns:\n• do 5 damage\n• human skill +1"); + }); }); } diff --git a/src/core/Drone.ts b/src/core/Drone.ts index 31c9f83..6561222 100644 --- a/src/core/Drone.ts +++ b/src/core/Drone.ts @@ -31,6 +31,17 @@ module TS.SpaceTac { this.code = code; } + /** + * Get a textual description of this drone + */ + getDescription(): string { + let effects = this.effects.map(effect => "• " + effect.getDescription()).join("\n"); + if (effects.length == 0) { + effects = "• do nothing"; + } + return `For ${this.duration} turn${this.duration > 1 ? "s" : ""}:\n${effects}`; + } + /** * Filter the list of ships in radius. */ diff --git a/src/core/Equipment.spec.ts b/src/core/Equipment.spec.ts index 1b4b21a..1a95bcc 100644 --- a/src/core/Equipment.spec.ts +++ b/src/core/Equipment.spec.ts @@ -51,14 +51,14 @@ module TS.SpaceTac.Specs { new DamageEffect(50) ]); equipment.action = action; - expect(equipment.getEffectsDescription()).toEqual("Fire (power usage 1, max range 200km):\n- do 50 damage on target"); + expect(equipment.getEffectsDescription()).toEqual("Fire (power usage 1, max range 200km):\n• do 50 damage on target"); action.blast = 20; - expect(equipment.getEffectsDescription()).toEqual("Fire (power usage 1, max range 200km):\n- do 50 damage in 20km radius"); + expect(equipment.getEffectsDescription()).toEqual("Fire (power usage 1, max range 200km):\n• do 50 damage in 20km radius"); action.blast = 0; action.effects.push(new StickyEffect(new AttributeLimitEffect("shield_capacity", 200), 3)); - expect(equipment.getEffectsDescription()).toEqual("Fire (power usage 1, max range 200km):\n- do 50 damage on target\n- limit shield capacity to 200 for 3 turns on target"); + expect(equipment.getEffectsDescription()).toEqual("Fire (power usage 1, max range 200km):\n• do 50 damage on target\n• limit shield capacity to 200 for 3 turns on target"); }); it("gets a minimal level, based on skills requirements", function () { @@ -106,7 +106,7 @@ module TS.SpaceTac.Specs { equipment.wear = 50; let result = equipment.getFullDescription(); - expect(result).toEqual("Second hand\n\nRequires:\n- gravity skill 2\n\nWhen equipped:\n- time skill +3"); + expect(result).toEqual("Second hand\n\nRequires:\n• gravity skill 2\n\nWhen equipped:\n• time skill +3"); }); }); } diff --git a/src/core/Equipment.ts b/src/core/Equipment.ts index a011da2..780c48d 100644 --- a/src/core/Equipment.ts +++ b/src/core/Equipment.ts @@ -77,7 +77,7 @@ module TS.SpaceTac { let requirements: string[] = []; iteritems(this.requirements, (skill: keyof ShipAttributes, value) => { if (value > 0) { - requirements.push(`- ${SHIP_ATTRIBUTES[skill].name} ${value}`); + requirements.push(`• ${SHIP_ATTRIBUTES[skill].name} ${value}`); } }); @@ -149,7 +149,7 @@ module TS.SpaceTac { let parts: string[] = []; if (this.effects.length > 0) { - parts.push(["When equipped:"].concat(this.effects.map(effect => "- " + effect.getDescription())).join("\n")); + parts.push(["When equipped:"].concat(this.effects.map(effect => "• " + effect.getDescription())).join("\n")); } let action_desc = this.action.getEffectsDescription(); diff --git a/src/core/actions/DeployDroneAction.ts b/src/core/actions/DeployDroneAction.ts index 70b5212..b275cc0 100644 --- a/src/core/actions/DeployDroneAction.ts +++ b/src/core/actions/DeployDroneAction.ts @@ -72,7 +72,7 @@ module TS.SpaceTac { if (effect instanceof StickyEffect) { suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`; } - return "- " + effect.getDescription() + " " + suffix; + return "• " + effect.getDescription() + " " + suffix; }); return `${desc}:\n${effects.join("\n")}`; } diff --git a/src/core/actions/FireWeaponAction.ts b/src/core/actions/FireWeaponAction.ts index 23b6b1a..dca79ff 100644 --- a/src/core/actions/FireWeaponAction.ts +++ b/src/core/actions/FireWeaponAction.ts @@ -103,7 +103,7 @@ module TS.SpaceTac { if (effect instanceof StickyEffect) { suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`; } - return "- " + effect.getDescription() + " " + suffix; + return "• " + effect.getDescription() + " " + suffix; }); return `${desc}:\n${effects.join("\n")}`; } diff --git a/src/ui/battle/ActionTooltip.spec.ts b/src/ui/battle/ActionTooltip.spec.ts index 41d565a..ae34030 100644 --- a/src/ui/battle/ActionTooltip.spec.ts +++ b/src/ui/battle/ActionTooltip.spec.ts @@ -30,7 +30,7 @@ module TS.SpaceTac.UI.Specs { expect(tooltip.main_title.text).toEqual("Weapon"); expect(tooltip.sub_title.text).toEqual("Fire"); expect(tooltip.shortcut.text).toEqual("[ 2 ]"); - expect(tooltip.description.text).toEqual("Fire (power usage 2, max range 50km):\n- do 12 damage on target"); + expect(tooltip.description.text).toEqual("Fire (power usage 2, max range 50km):\n• do 12 damage on target"); tooltip.setAction(a3); expect(tooltip.main_title.text).toEqual("End turn"); diff --git a/src/ui/battle/ArenaDrone.ts b/src/ui/battle/ArenaDrone.ts index 486053a..f54bc0e 100644 --- a/src/ui/battle/ArenaDrone.ts +++ b/src/ui/battle/ArenaDrone.ts @@ -3,11 +3,14 @@ module TS.SpaceTac.UI { * Drone sprite in the arena */ export class ArenaDrone extends Phaser.Group { + // Link to view + view: BattleView; + // Link to displayed drone drone: Drone; // Sprite - sprite: Phaser.Image; + sprite: Phaser.Button; // Radius radius: Phaser.Graphics; @@ -18,6 +21,7 @@ module TS.SpaceTac.UI { constructor(battleview: BattleView, drone: Drone) { super(battleview.game); + this.view = battleview; this.drone = drone; this.radius = new Phaser.Graphics(this.game, 0, 0); @@ -35,10 +39,11 @@ module TS.SpaceTac.UI { this.activation.visible = false; this.addChild(this.activation); - this.sprite = new Phaser.Image(this.game, 0, 0, `battle-actions-deploy-${drone.code}`); + this.sprite = new Phaser.Button(this.game, 0, 0, `battle-actions-deploy-${drone.code}`); this.sprite.anchor.set(0.5, 0.5); this.sprite.scale.set(0.1, 0.1); this.addChild(this.sprite); + this.view.tooltip.bindDynamicText(this.sprite, () => this.drone.getDescription()); } /**