import { D } from "./engine/public.ts"; import { Point, Size } from "./engine/datatypes.ts"; import { BG_OUTER, FG_BOLD, FG_TEXT, FG_TEXT_ENDORSED, FG_TOO_EXPENSIVE, } from "./colors.ts"; import { ALL_STATS } from "./datatypes.ts"; import { getPlayerProgress } from "./playerprogress.ts"; import { getHuntMode } from "./huntmode.ts"; import { getStateManager } from "./statemanager.ts"; import { withCamera } from "./layout.ts"; export class Hud { get size(): Size { return new Size(96, 176); } update() { withCamera("HUD", () => { this.#update(); }); } draw() { withCamera("HUD", () => { this.#draw(); }); } #update() {} #draw() { D.fillRect(new Point(-4, -4), this.size.add(new Size(8, 8)), BG_OUTER); D.drawText(getPlayerProgress().name, new Point(0, 0), FG_BOLD); let levelText = `Level ${getHuntMode().getDepth()}`; let zoneLabel = getHuntMode().getZoneLabel(); if (zoneLabel != null) { levelText += ": " + zoneLabel; } D.drawText(levelText, new Point(0, 16), FG_TEXT); D.drawText( `Turn ${getStateManager().getTurn()}/${getStateManager().getMaxTurns()}`, new Point(0, 32), FG_TEXT, ); let y = 64; let prog = getPlayerProgress(); for (let s of ALL_STATS.values()) { D.drawText(`${s}`, new Point(0, y), FG_BOLD); D.drawText(`${prog.getStat(s)}`, new Point(32, y), FG_TEXT); let talent = prog.getTalent(s); if (talent > 0) { D.drawText(`(+${talent})`, new Point(56, y), FG_TEXT); } if (talent < 0) { D.drawText(`(${talent})`, new Point(56, y), FG_TEXT); } y += 16; } D.drawText("EXP", new Point(0, 144), FG_BOLD); D.drawText(`${prog.getExperience()}`, new Point(32, 144), FG_TEXT); D.drawText("BLD", new Point(0, 160), FG_BOLD); let bloodAmount = prog.getBlood(); let bloodColor = FG_TEXT; if (bloodAmount > 2000) { bloodColor = FG_TEXT_ENDORSED; } if (bloodAmount < 100) { bloodColor = FG_TOO_EXPENSIVE; } D.drawText(`${prog.getBlood()}cc`, new Point(32, 160), bloodColor); } } let active = new Hud(); export function getHud(): Hud { return active; }