arena: Add tooltip on deployed drones
This commit is contained in:
parent
35d48eef4f
commit
f60bbf6e39
1
TODO
1
TODO
|
@ -16,7 +16,6 @@
|
||||||
* Controls: Do not focus on ship while targetting for area effects (dissociate hover and target)
|
* 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 ?)
|
* 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
|
* 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
|
* Drones: add hull points and take area damage
|
||||||
* Show power usage/recovery in action bar, on action hover
|
* Show power usage/recovery in action bar, on action hover
|
||||||
* More sound effects (but battle sounds should be vibration only, we are in space !)
|
* More sound effects (but battle sounds should be vibration only, we are in space !)
|
||||||
|
|
|
@ -140,5 +140,18 @@ module TS.SpaceTac {
|
||||||
new DroneAppliedEvent(drone, [other])
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,17 @@ module TS.SpaceTac {
|
||||||
this.code = code;
|
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.
|
* Filter the list of ships in radius.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,14 +51,14 @@ module TS.SpaceTac.Specs {
|
||||||
new DamageEffect(50)
|
new DamageEffect(50)
|
||||||
]);
|
]);
|
||||||
equipment.action = action;
|
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;
|
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.blast = 0;
|
||||||
action.effects.push(new StickyEffect(new AttributeLimitEffect("shield_capacity", 200), 3));
|
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 () {
|
it("gets a minimal level, based on skills requirements", function () {
|
||||||
|
@ -106,7 +106,7 @@ module TS.SpaceTac.Specs {
|
||||||
equipment.wear = 50;
|
equipment.wear = 50;
|
||||||
|
|
||||||
let result = equipment.getFullDescription();
|
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");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ module TS.SpaceTac {
|
||||||
let requirements: string[] = [];
|
let requirements: string[] = [];
|
||||||
iteritems(this.requirements, (skill: keyof ShipAttributes, value) => {
|
iteritems(this.requirements, (skill: keyof ShipAttributes, value) => {
|
||||||
if (value > 0) {
|
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[] = [];
|
let parts: string[] = [];
|
||||||
|
|
||||||
if (this.effects.length > 0) {
|
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();
|
let action_desc = this.action.getEffectsDescription();
|
||||||
|
|
|
@ -72,7 +72,7 @@ module TS.SpaceTac {
|
||||||
if (effect instanceof StickyEffect) {
|
if (effect instanceof StickyEffect) {
|
||||||
suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`;
|
suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`;
|
||||||
}
|
}
|
||||||
return "- " + effect.getDescription() + " " + suffix;
|
return "• " + effect.getDescription() + " " + suffix;
|
||||||
});
|
});
|
||||||
return `${desc}:\n${effects.join("\n")}`;
|
return `${desc}:\n${effects.join("\n")}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ module TS.SpaceTac {
|
||||||
if (effect instanceof StickyEffect) {
|
if (effect instanceof StickyEffect) {
|
||||||
suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`;
|
suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`;
|
||||||
}
|
}
|
||||||
return "- " + effect.getDescription() + " " + suffix;
|
return "• " + effect.getDescription() + " " + suffix;
|
||||||
});
|
});
|
||||||
return `${desc}:\n${effects.join("\n")}`;
|
return `${desc}:\n${effects.join("\n")}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ module TS.SpaceTac.UI.Specs {
|
||||||
expect(tooltip.main_title.text).toEqual("Weapon");
|
expect(tooltip.main_title.text).toEqual("Weapon");
|
||||||
expect(tooltip.sub_title.text).toEqual("Fire");
|
expect(tooltip.sub_title.text).toEqual("Fire");
|
||||||
expect(tooltip.shortcut.text).toEqual("[ 2 ]");
|
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);
|
tooltip.setAction(a3);
|
||||||
expect(tooltip.main_title.text).toEqual("End turn");
|
expect(tooltip.main_title.text).toEqual("End turn");
|
||||||
|
|
|
@ -3,11 +3,14 @@ module TS.SpaceTac.UI {
|
||||||
* Drone sprite in the arena
|
* Drone sprite in the arena
|
||||||
*/
|
*/
|
||||||
export class ArenaDrone extends Phaser.Group {
|
export class ArenaDrone extends Phaser.Group {
|
||||||
|
// Link to view
|
||||||
|
view: BattleView;
|
||||||
|
|
||||||
// Link to displayed drone
|
// Link to displayed drone
|
||||||
drone: Drone;
|
drone: Drone;
|
||||||
|
|
||||||
// Sprite
|
// Sprite
|
||||||
sprite: Phaser.Image;
|
sprite: Phaser.Button;
|
||||||
|
|
||||||
// Radius
|
// Radius
|
||||||
radius: Phaser.Graphics;
|
radius: Phaser.Graphics;
|
||||||
|
@ -18,6 +21,7 @@ module TS.SpaceTac.UI {
|
||||||
constructor(battleview: BattleView, drone: Drone) {
|
constructor(battleview: BattleView, drone: Drone) {
|
||||||
super(battleview.game);
|
super(battleview.game);
|
||||||
|
|
||||||
|
this.view = battleview;
|
||||||
this.drone = drone;
|
this.drone = drone;
|
||||||
|
|
||||||
this.radius = new Phaser.Graphics(this.game, 0, 0);
|
this.radius = new Phaser.Graphics(this.game, 0, 0);
|
||||||
|
@ -35,10 +39,11 @@ module TS.SpaceTac.UI {
|
||||||
this.activation.visible = false;
|
this.activation.visible = false;
|
||||||
this.addChild(this.activation);
|
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.anchor.set(0.5, 0.5);
|
||||||
this.sprite.scale.set(0.1, 0.1);
|
this.sprite.scale.set(0.1, 0.1);
|
||||||
this.addChild(this.sprite);
|
this.addChild(this.sprite);
|
||||||
|
this.view.tooltip.bindDynamicText(this.sprite, () => this.drone.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue