import { getPlayerProgress, initPlayerProgress } from "./playerprogress.ts"; import { getHuntMode, HuntMode, initHuntMode } from "./huntmode.ts"; import { getVNModal } from "./vnmodal.ts"; import { getScorer } from "./scorer.ts"; import { getEndgameModal } from "./endgamemodal.ts"; import { SuccessorOption, Wish } from "./datatypes.ts"; import { generateManor } from "./manormap.ts"; import { sndSilence, sndSleep } from "./sounds.ts"; import { openingScene } from "./openingscene.ts"; import { generateName } from "./namegen.ts"; import { photogenicThralls } from "./thralls.ts"; import { choose } from "./utils.ts"; import { SaveFileV1 } from "./saveformat.ts"; const N_TURNS: number = 9; export class StateManager { #turn: number; #revision: number; constructor(file?:SaveFileV1) { this.#turn = file?.turn ?? 1; this.#revision = file?.revision ?? 1; } getTurn(): number { return this.#turn; } nextRevision(): number { this.#revision++; return this.#revision; } startFirstGame() { getVNModal().play([ ...openingScene, { type: "callback", callback: () => { this.startGame( { name: generateName(), template: choose(photogenicThralls), nImprovements: 0, title: "", note: null, stats: { AGI: 10, INT: 10, CHA: 10, PSI: 10 }, talents: { AGI: 0, INT: 0, CHA: 0, PSI: 0 }, skills: [], isCompulsory: false, inPenance: false, }, null, ); }, }, ]); } startGame(asSuccessor: SuccessorOption, withWish: Wish | null) { this.#turn = 1; initPlayerProgress(asSuccessor, withWish); initHuntMode(new HuntMode(1, generateManor())); sndSleep.play({ bgm: true }); } advance() { if (this.#turn + 1 <= N_TURNS) { this.#turn += 1; getPlayerProgress().applyEndOfTurn(); getPlayerProgress().refill(); initHuntMode(new HuntMode(getHuntMode().depth, generateManor())); sndSleep.play({ bgm: true }); } else { sndSilence.play({ bgm: true }); let ending = getScorer().pickEnding(); getVNModal().play(ending.scene); getEndgameModal().show(ending); } } getMaxTurns() { return N_TURNS; } } let active: StateManager = new StateManager(); export function getStateManager(): StateManager { return active; }