Files
the-beacon/reference/npc-logic.js
Alexander Whitestone aadd8109f0
Some checks failed
Accessibility Checks / a11y-audit (pull_request) Successful in 14s
Smoke Test / smoke (pull_request) Failing after 24s
chore: move dormant prototypes to reference/ directory
- game/npc-logic.js → reference/npc-logic.js (added REFERENCE PROTOTYPE header)
- scripts/guardrails.js → reference/guardrails.js (added REFERENCE PROTOTYPE header)
- New reference/README.md with integration instructions

Closes #196
2026-04-15 21:45:53 -04:00

28 lines
841 B
JavaScript

/**
* REFERENCE PROTOTYPE — NOT LOADED BY RUNTIME
*
* This file is dormant. It uses ES module syntax (export default),
* which is incompatible with <script> tag loading.
*
* To integrate: remove the default export, add <script src="reference/npc-logic.js">
* to index.html, and wire NPCStateMachine into the game engine lifecycle.
*/
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;