Module: Gamefic::Mud::Adapter::Common
Overview
Common attributes and methods of client adapters.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#send_raw(data) ⇒ void
abstract
Send raw data to the client outside of the game.
- #session ⇒ Object
- #start(state) ⇒ void
-
#update(output) ⇒ void
abstract
Send a game update to the client.
Instance Attribute Details
#character ⇒ Actor
11 12 13 |
# File 'lib/gamefic-mud/adapter/common.rb', line 11 def character @character end |
#plot ⇒ Plot
8 9 10 |
# File 'lib/gamefic-mud/adapter/common.rb', line 8 def plot @plot end |
#state ⇒ State::Base (readonly)
14 15 16 |
# File 'lib/gamefic-mud/adapter/common.rb', line 14 def state @state end |
Instance Method Details
#[](key) ⇒ Object
27 28 29 |
# File 'lib/gamefic-mud/adapter/common.rb', line 27 def [] key session[key] end |
#[]=(key, value) ⇒ Object
31 32 33 |
# File 'lib/gamefic-mud/adapter/common.rb', line 31 def []= key, value session[key] = value end |
#send_raw(data) ⇒ void
This method is abstract.
This method returns an undefined value.
Send raw data to the client outside of the game. Normally, game-related data is sent through the character, usually via ‘character#tell` or `character#stream`. `#raw_data` allows the engine to communicate with the client outside of the game proper, e.g., to display a login prompt.
Adapters should implement this method.
|
# File 'lib/gamefic-mud/adapter/common.rb', line 35
|
#session ⇒ Object
23 24 25 |
# File 'lib/gamefic-mud/adapter/common.rb', line 23 def session @session ||= {} end |
#start(state) ⇒ void
This method returns an undefined value.
18 19 20 21 |
# File 'lib/gamefic-mud/adapter/common.rb', line 18 def start state @state = state.new(self) @state.start end |
#update(output) ⇒ void
This method is abstract.
This method returns an undefined value.
Send a game update to the client. The engine uses this method to broadcast messages and provide data about the current game state.
Adapters should implement this method.
|
# File 'lib/gamefic-mud/adapter/common.rb', line 48
|