thomas-anderson-lib
Version:
A text adventure game library based on Thomas Anderson from The Matrix. Create your own Matrix-inspired text adventures with this easy-to-use library.
43 lines (42 loc) • 907 B
TypeScript
export interface Item {
id: string;
name: string;
description: string;
canTake: boolean;
onTake?: (game: GameState) => string;
}
export interface Room {
id: string;
description: string;
items: Item[];
exits: {
[direction: string]: string;
};
onEnter?: (game: GameState) => string;
onExit?: (game: GameState) => string;
}
export interface GameFlags {
cookieTaken?: boolean;
gruelAttempts?: number;
kungFuBootDriveTaken?: boolean;
}
export interface GameState {
currentRoom: string;
inventory: Item[];
score: number;
gameOver: boolean;
visitedRooms: Set<string>;
flags: GameFlags;
}
export interface Command {
verb: string;
noun?: string;
preposition?: string;
object?: string;
}
export type GameResponse = {
message: string;
score?: number;
gameOver?: boolean;
options?: string[];
};