-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Reusable framework for creating and managing security-related minigames.
Basically a mini-game should be initialised and launched, and feedback results into the game, potentially updating state, such as unlocking the lock that has been interacted with.
Implementation Details:
Base Minigame Structure:
abstract class SecurityMinigame {
protected difficulty: number;
protected timeLimit?: number;
protected score: number;
protected state: "ready" | "active" | "complete" | "failed";
abstract initialize(): void;
abstract update(delta: number): void;
abstract checkWinCondition(): boolean;
start() {
this.state = "active";
this.score = 0;
this.initialize();
}
updateGame(delta: number) {
if (this.state !== "active") return;
this.update(delta);
if (this.checkWinCondition()) {
this.complete();
}
}
}
Example Implementation:
class LockpickingGame extends SecurityMinigame {
private lock: Lock;
private picks: number;
initialize() {
this.lock = new Lock(this.difficulty);
this.picks = 3;
}
update(delta: number) {
this.handleInput();
this.updateLockState();
if (this.picks <= 0) {
this.state = "failed";
}
}
checkWinCondition(): boolean {
return this.lock.pins.every(pin => pin.binding);
}
}
Reactions are currently unavailable