Class: Gamefic::Mud::State::Guest

Inherits:
Base
  • Object
show all
Defined in:
lib/gamefic-mud/state/guest.rb

Overview

A simple introductory state that creates a character with a name provided by the user. MUDs in production should implement a more robust version of authentication, but this is sufficient for testing and development.

Instance Attribute Summary

Attributes inherited from Base

#adapter

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gamefic::Mud::State::Base

Instance Method Details

#process(message) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gamefic-mud/state/guest.rb', line 14

def process message
  if message.strip.empty?
    adapter.send_raw "Blank names are not allowed.\r\n"
    start
  else
    character = adapter.plot.make_player_character
    character.name = message.strip
    adapter.character = character
    adapter.start Mud::State::Play
  end
end

#startObject



10
11
12
# File 'lib/gamefic-mud/state/guest.rb', line 10

def start
  adapter.send_raw 'Enter your name: '
end