2021-06-22 19:25:41 -04:00
|
|
|
|
import { getTheme } from "@themes";
|
2021-06-19 21:22:28 -04:00
|
|
|
|
import { Game } from "../../Game.js";
|
|
|
|
|
|
import { progressbar } from "../../Progressbar.js";
|
|
|
|
|
|
import { PawnDetails } from "../PawnDetails.js";
|
2021-06-22 19:25:41 -04:00
|
|
|
|
import { panels } from "../UI.js";
|
2021-06-19 12:40:01 -04:00
|
|
|
|
import { View } from "../View.js";
|
2021-06-18 21:29:45 -04:00
|
|
|
|
|
|
|
|
|
|
export default class PawnsView extends View {
|
2021-07-02 23:01:45 -04:00
|
|
|
|
constructor() {
|
|
|
|
|
|
super();
|
|
|
|
|
|
this.name = 'Pawns';
|
|
|
|
|
|
}
|
2021-06-19 21:22:28 -04:00
|
|
|
|
|
2021-07-02 23:01:45 -04:00
|
|
|
|
keypress(key: { full: string; }) {
|
|
|
|
|
|
if (key.full === 'delete') {
|
|
|
|
|
|
Game.current.removePawn(Game.current.selected);
|
|
|
|
|
|
} else if (key.full === 'up') {
|
|
|
|
|
|
Game.current.advanceSelection(-1);
|
|
|
|
|
|
} else if (key.full === 'down') {
|
|
|
|
|
|
Game.current.advanceSelection(1);
|
|
|
|
|
|
} else if (key.full === 'enter') {
|
|
|
|
|
|
new PawnDetails(Game.current.selected);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-06-19 21:22:28 -04:00
|
|
|
|
|
2021-07-02 23:01:45 -04:00
|
|
|
|
render() {
|
|
|
|
|
|
return `${
|
|
|
|
|
|
Game.current.pawns.map(pawn => `${(function() {
|
|
|
|
|
|
const selected = pawn === Game.current.selected;
|
|
|
|
|
|
let str = '';
|
|
|
|
|
|
if(selected) {
|
|
|
|
|
|
str += ` ${getTheme().bright(` ❯ ${pawn.toString()}`)}{|}${pawn.status} \n`;
|
2021-07-16 20:49:29 -04:00
|
|
|
|
// str += ` ${getTheme().normal('Energy')}{|}${progressbar(pawn.energy / 100, (panels.right.width - 4) / 2)} \n`;
|
2021-07-02 23:01:45 -04:00
|
|
|
|
} else {
|
|
|
|
|
|
str += ` ${getTheme().normal(pawn.toString())}{|}${pawn.status} `;
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
|
|
|
})()}`).join('\n')
|
|
|
|
|
|
}`;
|
|
|
|
|
|
}
|
2021-06-18 21:29:45 -04:00
|
|
|
|
}
|