54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { getPlayerProgress, initPlayerProgress } from "./playerprogress.ts";
|
|
import { getHuntMode, HuntMode, initHuntMode } from "./huntmode.ts";
|
|
import { getSleepModal } from "./sleepmodal.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";
|
|
|
|
const N_TURNS: number = 9;
|
|
|
|
export class StateManager {
|
|
#turn: number;
|
|
|
|
constructor() {
|
|
this.#turn = 1;
|
|
}
|
|
|
|
getTurn(): number {
|
|
return this.#turn;
|
|
}
|
|
|
|
startGame(asSuccessor: SuccessorOption, withWish: Wish | null) {
|
|
this.#turn = 1;
|
|
initPlayerProgress(asSuccessor, withWish);
|
|
initHuntMode(new HuntMode(1, generateManor()));
|
|
}
|
|
|
|
advance() {
|
|
getSleepModal().setShown(false);
|
|
|
|
if (this.#turn + 1 <= N_TURNS) {
|
|
this.#turn += 1;
|
|
getPlayerProgress().applyEndOfTurn();
|
|
getPlayerProgress().refill();
|
|
initHuntMode(new HuntMode(getHuntMode().depth, generateManor()));
|
|
} else {
|
|
// TODO: Play a specific scene
|
|
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;
|
|
}
|