2017-08-21 22:01:11 +00:00
|
|
|
/// <reference path="../common/UIDialog.ts" />
|
2017-05-25 23:09:29 +00:00
|
|
|
|
2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.UI {
|
2017-03-12 23:32:41 +00:00
|
|
|
/**
|
|
|
|
* Dialog to display battle outcome
|
|
|
|
*/
|
2017-08-21 22:01:11 +00:00
|
|
|
export class OutcomeDialog extends UIDialog {
|
|
|
|
battleview: BattleView
|
|
|
|
player: Player
|
|
|
|
outcome: BattleOutcome
|
|
|
|
stats: BattleStats
|
|
|
|
|
2017-05-25 23:09:29 +00:00
|
|
|
constructor(parent: BattleView, player: Player, outcome: BattleOutcome, stats: BattleStats) {
|
2017-08-21 22:01:11 +00:00
|
|
|
super(parent);
|
|
|
|
|
|
|
|
this.battleview = parent;
|
|
|
|
this.player = player;
|
|
|
|
this.outcome = outcome;
|
|
|
|
this.stats = stats;
|
|
|
|
|
|
|
|
this.refreshContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shortcut to add a single action button at the bottom of dialog
|
|
|
|
*/
|
|
|
|
addActionButton(x: number, text: string, tooltip: string, action: Function) {
|
2018-05-15 14:57:45 +00:00
|
|
|
let button = this.content.button("common-dialog-textbutton", x, 885, action, tooltip, undefined, {
|
|
|
|
center: true,
|
|
|
|
text: text,
|
|
|
|
text_style: { color: "#d9e0e5" }
|
|
|
|
});
|
2017-08-21 22:01:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refresh the whole dialog
|
|
|
|
*/
|
|
|
|
refreshContent(): void {
|
|
|
|
let parent = this.battleview;
|
|
|
|
let outcome = this.outcome;
|
2018-01-16 00:08:24 +00:00
|
|
|
let victory = outcome.winner && this.player.is(outcome.winner.player);
|
2017-03-12 23:32:41 +00:00
|
|
|
|
2018-05-15 14:57:45 +00:00
|
|
|
this.content.clear();
|
2017-03-12 23:32:41 +00:00
|
|
|
|
2018-05-15 14:57:45 +00:00
|
|
|
this.content.image(victory ? "battle-outcome-title-victory" : "battle-outcome-title-defeat", 747, 180, true);
|
2017-03-15 21:40:19 +00:00
|
|
|
|
2018-05-15 14:57:45 +00:00
|
|
|
this.content.text("You", 815, 320, { color: "#ffffff", size: 20 });
|
|
|
|
this.content.text("Enemy", 1015, 320, { color: "#ffffff", size: 20 });
|
2017-08-21 22:01:11 +00:00
|
|
|
this.stats.getImportant(10).forEach((stat, index) => {
|
2018-05-15 14:57:45 +00:00
|
|
|
this.content.text(stat.name, 530, 364 + 40 * index, { color: "#ffffff", size: 20 });
|
|
|
|
this.content.text(stat.attacker.toString(), 815, 364 + 40 * index, { color: "#8ba883", size: 20, bold: true });
|
|
|
|
this.content.text(stat.defender.toString(), 1015, 364 + 40 * index, { color: "#cd6767", size: 20, bold: true });
|
2017-08-21 22:01:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!this.battleview.session.hasUniverse()) {
|
|
|
|
this.addActionButton(747, "Main menu", "Exit the battle and go back to the main menu", () => {
|
2017-03-12 23:32:41 +00:00
|
|
|
parent.exitBattle();
|
2017-08-21 22:01:11 +00:00
|
|
|
});
|
|
|
|
} else if (victory) {
|
2018-02-08 15:16:03 +00:00
|
|
|
this.addActionButton(747, "Back to map", "Exit the battle and go back to the map", () => {
|
|
|
|
parent.exitBattle();
|
|
|
|
});
|
2017-03-12 23:32:41 +00:00
|
|
|
} else {
|
2017-08-21 22:01:11 +00:00
|
|
|
this.addActionButton(535, "Revert battle", "Go back to where the fleet was before the battle happened", () => {
|
2017-03-14 22:28:07 +00:00
|
|
|
parent.revertBattle();
|
2017-08-21 22:01:11 +00:00
|
|
|
});
|
2017-03-15 21:40:19 +00:00
|
|
|
|
2017-08-21 22:01:11 +00:00
|
|
|
this.addActionButton(957, "Main menu", "Quit the game, and go back to main menu", () => {
|
2017-03-12 23:32:41 +00:00
|
|
|
parent.gameui.quitGame();
|
2017-08-21 22:01:11 +00:00
|
|
|
});
|
2017-03-12 23:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|