Added effect description on action tooltip
This commit is contained in:
parent
da0b8dc870
commit
77326ed22c
1
TODO
1
TODO
|
@ -4,7 +4,6 @@
|
|||
* Fix "thinking" icon in actionbar not rotating
|
||||
* Add equipment info (or summary) in ship tooltip
|
||||
* Handle effects overflowing ship tooltip when too numerous
|
||||
* Add effect description on action tooltip
|
||||
* Mobile: display tooltips on hold
|
||||
* Mobile: targetting in two times, using a draggable target indicator
|
||||
* Add a defeat screen (game over for now)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module SpaceTac.Game.Specs {
|
||||
describe("Equipment", () => {
|
||||
it("checks capabilities requirements", () => {
|
||||
it("checks capabilities requirements", function () {
|
||||
var equipment = new Equipment();
|
||||
var ship = new Ship();
|
||||
|
||||
|
@ -31,5 +31,21 @@ module SpaceTac.Game.Specs {
|
|||
|
||||
expect(equipment.canBeEquipped(ship)).toBe(true);
|
||||
});
|
||||
|
||||
it("generates a description of the effects", function () {
|
||||
var equipment = new Equipment();
|
||||
equipment.distance = 3;
|
||||
expect(equipment.getActionDescription()).toEqual("does nothing");
|
||||
|
||||
equipment.target_effects.push(new DamageEffect(50));
|
||||
expect(equipment.getActionDescription()).toEqual("- 50 damage on target");
|
||||
|
||||
equipment.blast = 20;
|
||||
expect(equipment.getActionDescription()).toEqual("- 50 damage on all ships in 20km of impact");
|
||||
|
||||
equipment.blast = 0;
|
||||
equipment.target_effects.push(new AttributeLimitEffect(AttributeCode.Shield, 3, 200));
|
||||
expect(equipment.getActionDescription()).toEqual("- 50 damage on target\n- limit shield to 200 for 3 turns on target");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -77,5 +77,22 @@ module SpaceTac.Game {
|
|||
this.attached_to = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Get a human readable description of the effects of this equipment
|
||||
getActionDescription(): string {
|
||||
if (this.permanent_effects.length == 0 && this.target_effects.length == 0) {
|
||||
return "does nothing";
|
||||
} else {
|
||||
var result: string[] = [];
|
||||
this.target_effects.forEach(effect => {
|
||||
let suffix = this.blast ? `on all ships in ${this.blast}km of impact` : "on target";
|
||||
if (effect instanceof TemporaryEffect) {
|
||||
suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`;
|
||||
}
|
||||
result.push("- " + effect.getDescription() + " " + suffix);
|
||||
});
|
||||
return result.join("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,5 +37,9 @@ module SpaceTac.Game {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
return `${this.value} damage`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ module SpaceTac.Game.Equipments {
|
|||
|
||||
this.can_target_space = false;
|
||||
|
||||
this.addDamageOnTargetEffect(min_damage, max_damage);
|
||||
if (min_damage > 0 || (max_damage != null && max_damage > 0)) {
|
||||
this.addDamageOnTargetEffect(min_damage, max_damage);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the range for this weapon
|
||||
|
@ -23,7 +25,7 @@ module SpaceTac.Game.Equipments {
|
|||
|
||||
// Set the effect radius (blast) for this weapon
|
||||
setBlast(min_blast: number, max_blast: number = null): void {
|
||||
this.blast = new Range(min_blast, max_blast);
|
||||
this.blast = new IntegerRange(min_blast, max_blast);
|
||||
}
|
||||
|
||||
protected getActionForEquipment(equipment: Equipment): BaseAction {
|
||||
|
|
|
@ -5,6 +5,7 @@ module SpaceTac.View {
|
|||
main_title: Phaser.Text;
|
||||
sub_title: Phaser.Text;
|
||||
cost: Phaser.Text;
|
||||
description: Phaser.Text;
|
||||
|
||||
constructor(parent: ActionBar) {
|
||||
super(parent.game, 0, 0, "battle-action-tooltip");
|
||||
|
@ -23,6 +24,11 @@ module SpaceTac.View {
|
|||
this.cost = new Phaser.Text(this.game, 325, 100, "", { font: "20pt Arial", fill: "#ffff00" });
|
||||
this.cost.anchor.set(0.5, 0);
|
||||
this.addChild(this.cost);
|
||||
|
||||
this.description = new Phaser.Text(this.game, 21, 144, "", { font: "14pt Arial", fill: "#ffffff" });
|
||||
this.description.wordWrap = true;
|
||||
this.description.wordWrapWidth = 476;
|
||||
this.addChild(this.description);
|
||||
}
|
||||
|
||||
// Set current action to display, null to hide
|
||||
|
@ -40,6 +46,7 @@ module SpaceTac.View {
|
|||
this.main_title.setText(action.action.equipment ? action.action.equipment.name : action.action.name);
|
||||
this.sub_title.setText(action.action.equipment ? action.action.name : "");
|
||||
this.cost.setText(action.action.equipment ? `Cost: ${action.action.equipment.ap_usage} power` : "");
|
||||
this.description.setText(action.action.equipment ? action.action.equipment.getActionDescription() : "");
|
||||
|
||||
Animation.fadeIn(this.game, this, 200, 0.9);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue