Class: Gamefic::Mud::State::Play

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

Overview

The typical gameplay handler. This state processes client messages as commands to be executed by the player’s character.

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



16
17
18
# File 'lib/gamefic-mud/state/play.rb', line 16

def process message
  adapter.character.queue.push message unless message == ''
end

#startObject



8
9
10
11
12
13
14
# File 'lib/gamefic-mud/state/play.rb', line 8

def start
  adapter.plot.introduce adapter.character
  # Since the game is already running when the player connects, the
  # plot update flushes messages received in the introduction. We're
  # working around the problem by sending them here.
  adapter.update({ messages: adapter.character.messages })
end