1
0
Fork 0

arena: Add tooltip on deployed drones

This commit is contained in:
Michaël Lemaire 2017-05-10 19:48:28 +02:00
parent 35d48eef4f
commit f60bbf6e39
9 changed files with 40 additions and 12 deletions

1
TODO
View file

@ -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 !)

View file

@ -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");
});
});
}

View file

@ -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.
*/

View file

@ -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");
});
});
}

View file

@ -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();

View file

@ -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")}`;
}

View file

@ -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")}`;
}

View file

@ -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");

View file

@ -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());
}
/**