abstract struct Scene

Overview

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.

Direct Known Subclasses

Defined in:

engine/scene.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

abstract def 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


[View source]
def 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

[View source]
abstract def 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

[View source]
def run(state : State) : Tuple(Scene, State)? #

Execute the scene and return the next scene and state


[View source]