Implement Lantern Bearer logic, Phase buttons, and Monster spawning basics

This commit is contained in:
2026-01-04 23:48:53 +01:00
parent 4c8b58151b
commit 056217437c
9 changed files with 638 additions and 102 deletions

View File

@@ -5,30 +5,36 @@ export class TurnManager {
this.currentTurn = 0;
this.currentPhase = GAME_PHASES.SETUP;
this.listeners = {}; // Simple event system
// Power Phase State
this.currentPowerRoll = 0;
this.eventsTriggered = [];
}
startGame() {
this.currentTurn = 1;
this.setPhase(GAME_PHASES.HERO); // Jump straight to Hero phase for now
console.log(`--- TURN ${this.currentTurn} START ---`);
this.startPowerPhase();
}
nextPhase() {
// Simple sequential flow for now
// Simple sequential flow
switch (this.currentPhase) {
case GAME_PHASES.POWER:
this.setPhase(GAME_PHASES.HERO);
break;
case GAME_PHASES.HERO:
// Usually goes to Exploration if at edge, or Monster if not.
// For this dev stage, let's allow manual triggering of Exploration
// via UI, so we stay in HERO until confirmed done.
// Move to Monster Phase
this.setPhase(GAME_PHASES.MONSTER);
break;
case GAME_PHASES.MONSTER:
// Move to Exploration Phase
this.setPhase(GAME_PHASES.EXPLORATION);
break;
case GAME_PHASES.EXPLORATION:
// End Turn and restart
this.endTurn();
break;
// Exploration is usually triggered as an interrupt, not strictly sequential
}
}
@@ -40,6 +46,37 @@ export class TurnManager {
}
}
startPowerPhase() {
this.setPhase(GAME_PHASES.POWER);
this.rollPowerDice();
}
rollPowerDice() {
const roll = Math.floor(Math.random() * 6) + 1;
this.currentPowerRoll = roll;
console.log(`Power Roll: ${roll}`);
let message = "The dungeon is quiet...";
let eventTriggered = false;
if (roll === 1) {
message = "UNEXPECTED EVENT! (Roll of 1)";
eventTriggered = true;
this.triggerRandomEvent();
}
this.emit('POWER_RESULT', { roll, message, eventTriggered });
// Auto-advance to Hero phase after short delay (game feel)
setTimeout(() => {
this.nextPhase();
}, 2000);
}
triggerRandomEvent() {
console.warn("TODO: TRIGGER EVENT CARD DRAW");
}
triggerExploration() {
this.setPhase(GAME_PHASES.EXPLORATION);
// Logic to return to HERO phase would handle elsewhere
@@ -48,7 +85,7 @@ export class TurnManager {
endTurn() {
console.log(`--- TURN ${this.currentTurn} END ---`);
this.currentTurn++;
this.setPhase(GAME_PHASES.POWER);
this.startPowerPhase();
}
// -- Simple Observer Pattern --