30 lines
848 B
JavaScript
30 lines
848 B
JavaScript
/**
|
|
* DORMANT PROTOTYPE — moved from game/npc-logic.js
|
|
*
|
|
* Why dormant: Uses ES module syntax (export default) — incompatible with <script> tag loading
|
|
*
|
|
* To integrate (future):
|
|
* 1. Refactor to remove ES module exports
|
|
* 2. Add <script src="reference/npc-logic.js"> to index.html
|
|
* 3. Wire into game engine lifecycle
|
|
* 4. Add tests
|
|
*/
|
|
|
|
class NPCStateMachine {
|
|
constructor(states) {
|
|
this.states = states;
|
|
this.current = 'idle';
|
|
}
|
|
update(context) {
|
|
const state = this.states[this.current];
|
|
for (const transition of state.transitions) {
|
|
if (transition.condition(context)) {
|
|
this.current = transition.target;
|
|
console.log(`NPC transitioned to ${this.current}`);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
export default NPCStateMachine;
|