Rooms
The next most high-level component are Rooms, which have a recursive data structure and can hold sub-rooms.
A room can hold sub-rooms, and thus exist as a game world on its own, as rooms have a recursive data structure. Rooms will render any type of HTML or plaintext, with in-line styles, but will not load in-line scripts. Scripts for a room can be loaded externally.
A room has the following properties:
name [string] - name of the room (must be unique)
contents [string] - HTML to display upon entering room (optional)
contentsPath [string] - file path to load and render HTML from upon entering room (optional); if this value is not empty, the HTML loaded from the file will replace any value to render from the room contents
prompts [Array[prompt]] - actions available in the room that can be found through natural language or text input, or rendered in the UI as clickable buttons or cards; prompts can have itemRequirements in order to perform them.
Some advanced, optional properties rooms can have:
subrooms [Array[room]] - sub-rooms of the same type of data structure (recursive) that a room can contain (optional)
type [string] - a tag or type given to the room for categorization and UI organization (optional)
skipAsEnd [bool] - if a room is an end room of a game, and this is set to true (by default it is false), then the next game as defined in Game.nextGame is loaded. (optional)
scripts [Array[string]] - list of script paths (can be local or on the web) to load upon entering the room; all scripts are removed upon exiting the room (optional)
stylesheets [Array[string]] - list of CSS / SCSS stylesheet paths (can be local or on the web) to load upon entering the room; all stylesheets will be removed upon exiting the room (optional)
exitScripts [Array[string]] - list of script paths (can be local or on the web) to load upon exiting the room; all scripts are removed upon finishing of execution (optional)
exitScriptsNoCleanup [Array[string]] - list of script paths (can be local or on the web) to load upon exiting the room; all scripts are persistently kept after exiting the room (optional)
Good to know: Splitting your product into fundamental concepts, objects, or areas can be a great way to let readers deep dive into the concepts that matter most to them.
Last updated