struct

Scene

Inherits Struct < Value < Object

Represents a single scene in the game. Players navigate through the game by visiting different scenes. Scenes describe the environment and provide the user with different Command options.

Constructors

Instance methods

commands(state : State) : Array(Command)

Returns an ordered list of commands available to the user. These commands will be displayed after the scene description produced in #render

Source
initialize
Source
persist_scene_state(state : State) : State

Persists the scene information to the state so we can keep track of a player's progress between saves.

Example:

If we also had a timstamp field on State we could set it here

protected def persist_scene_state(state : State) : State
  state = super(state)
  state.timstamp = Time.utc
  return state
end
Source
render(state : State)

Render the scene description.

Note: There is no need to explain the scene's available options since Command options are automatically generated from #commands.

Example:

def render(state : State)
  puts "You are in an empty room. To your left is an open door."
end
Source
run(state : State) : Tuple(Scene, State) | Nil

Execute the scene and return the next scene and state

Source