class MenuCommands::SelectSavedGame

Overview

Handles displaying a list of saved games, and allows the player select one to continue.

Defined in:

engine/menu_commands/select_saved_game.cr

Constructors

Instance Method Summary

Instance methods inherited from class Command

description : String description, execute(state : State, user_input : String?) : State execute, key : String? key, scene : Scene.class? scene, sub_commands : Array(Command) sub_commands, validate(state : State, user_input : String?) : Bool validate

Constructor methods inherited from class Command

new(key : String, description : String, scene : Scene.class?)
new(key : String, description : String, sub_commands : Array(Command))
new(key : String, description : String, sub_command : Command)
new(description : String, scene : Scene.class?)
new(description : String, sub_commands : Array(Command))
new(description : String, sub_command : Command)
new

Constructor Detail

def self.new(default_scene : Scene.class) #

The player is taken to default_scene if there is a problem loading their saved scene.


[View source]

Instance Method Detail

def execute(state : State, user_input : String?) : State #
Description copied from class Command

Performs extra processing on the user input. This will run for both keyed and keyless commands. Override this to add your custom logic.

When using nested commands, commands are executed in order of selection by the player.

This is one of the most important parts of a command, because it allows us to change state in response to the player's choices in the game.

Example

If we had a skill field on Character we could update it here to give our player more abilities.

def execute(state : State, user_input : String?) : State
  state.character.skill += 1
  return state
end

[View source]
def validate(state : State, user_input : String?) : Bool #
Description copied from class Command

Validates the user input given to the command. This is only executed for keyless commands since the input to keyed commands is always the same as their #key. Override this to add your custom logic.

You could for example, you could make sure the player does not give an empty string for their character name.


[View source]