2017-02-09 00:00:35 +00:00
|
|
|
module TS.SpaceTac.UI {
|
2017-05-16 23:12:05 +00:00
|
|
|
/**
|
|
|
|
* Tooltip displaying action information
|
|
|
|
*/
|
|
|
|
export class ActionTooltip {
|
|
|
|
/**
|
|
|
|
* Fill the tooltip
|
|
|
|
*/
|
|
|
|
static fill(filler: TooltipFiller, ship: Ship, action: BaseAction, position: number) {
|
2017-07-26 22:54:56 +00:00
|
|
|
let icon = filler.view.getFirstImage(`equipment-${action.equipment ? action.equipment.code : "---"}`, `action-${action.code}`);
|
|
|
|
filler.addImage(0, 0, icon.key, icon.frame, 0.5);
|
2015-03-03 00:00:00 +00:00
|
|
|
|
2017-05-16 23:12:05 +00:00
|
|
|
filler.addText(150, 0, action.equipment ? action.equipment.name : action.name, "#ffffff", 24);
|
2015-03-03 00:00:00 +00:00
|
|
|
|
2017-05-16 23:12:05 +00:00
|
|
|
let cost = "";
|
|
|
|
if (action instanceof MoveAction) {
|
|
|
|
if (ship.getValue("power") == 0) {
|
|
|
|
cost = "Not enough power";
|
2017-04-18 19:51:23 +00:00
|
|
|
} else {
|
2017-08-17 22:53:21 +00:00
|
|
|
cost = `Cost: 1 power per ${action.getDistanceByActionPoint(ship)}km`;
|
2017-05-16 23:12:05 +00:00
|
|
|
}
|
|
|
|
} else if (action.equipment) {
|
|
|
|
let power_usage = action.getActionPointsUsage(ship, null);
|
|
|
|
if (power_usage) {
|
|
|
|
if (ship.getValue("power") < power_usage) {
|
|
|
|
cost = "Not enough power";
|
|
|
|
} else {
|
|
|
|
cost = `Cost: ${power_usage} power`;
|
|
|
|
}
|
2017-01-19 18:33:56 +00:00
|
|
|
}
|
2017-05-16 23:12:05 +00:00
|
|
|
}
|
|
|
|
if (cost) {
|
2017-05-28 22:15:24 +00:00
|
|
|
filler.addText(150, 40, cost, "#ffdd4b", 20);
|
2017-05-16 23:12:05 +00:00
|
|
|
}
|
2017-01-08 22:42:53 +00:00
|
|
|
|
2017-05-16 23:12:05 +00:00
|
|
|
if (action.equipment && action.equipment.cooldown.overheat) {
|
|
|
|
let cooldown = action.equipment.cooldown;
|
2017-05-22 16:29:04 +00:00
|
|
|
if (cooldown.heat > 0) {
|
2017-05-28 22:15:24 +00:00
|
|
|
filler.addText(150, 80, "Cooling down ...", "#c9604c", 20);
|
2017-05-22 16:29:04 +00:00
|
|
|
} else if (cooldown.willOverheat() && cost != "Not enough power") {
|
|
|
|
if (cooldown.cooling > 1) {
|
|
|
|
let turns = cooldown.cooling;
|
2017-05-28 22:15:24 +00:00
|
|
|
filler.addText(150, 80, `Unavailable for ${turns} turn${turns > 1 ? "s" : ""} if used`, "#c9604c", 20);
|
2017-05-16 23:12:05 +00:00
|
|
|
} else {
|
2017-05-28 22:15:24 +00:00
|
|
|
filler.addText(150, 80, "Unavailable until next turn if used", "#c9604c", 20);
|
2017-05-16 23:12:05 +00:00
|
|
|
}
|
2017-05-16 23:31:23 +00:00
|
|
|
}
|
2017-07-19 17:46:04 +00:00
|
|
|
} else if (action instanceof ToggleAction && action.activated) {
|
|
|
|
filler.addText(150, 80, `Activated`, "#b1d549", 20);
|
2017-05-16 23:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let description = action.getEffectsDescription();
|
|
|
|
if (description) {
|
|
|
|
filler.addText(0, 150, description, "#ffffff", 14);
|
|
|
|
}
|
2017-02-12 18:54:09 +00:00
|
|
|
|
2017-05-16 23:12:05 +00:00
|
|
|
let shortcut = "";
|
|
|
|
if (action instanceof EndTurnAction) {
|
|
|
|
shortcut = "[ space ]";
|
|
|
|
} else if (position == 9) {
|
|
|
|
shortcut = "[ 0 ]";
|
|
|
|
} else if (position >= 0 && position < 9) {
|
|
|
|
shortcut = `[ ${position + 1} ]`;
|
|
|
|
}
|
|
|
|
if (shortcut) {
|
2017-05-28 22:15:24 +00:00
|
|
|
filler.addText(150, 120, shortcut, "#aaaaaa", 12);
|
2015-03-03 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|