Module: Gamefic::Mud::Adapter::Common

Included in:
Tcp, Websocket
Defined in:
lib/gamefic-mud/adapter/common.rb

Overview

Common attributes and methods of client adapters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#characterActor

Returns:

  • (Actor)


11
12
13
# File 'lib/gamefic-mud/adapter/common.rb', line 11

def character
  @character
end

#plotPlot

Returns:

  • (Plot)


8
9
10
# File 'lib/gamefic-mud/adapter/common.rb', line 8

def plot
  @plot
end

#stateState::Base (readonly)

Returns:



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.

Parameters:

  • data (String)

    The message text



# File 'lib/gamefic-mud/adapter/common.rb', line 35

#sessionObject



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.

Parameters:



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.

Parameters:

  • output (Hash)


# File 'lib/gamefic-mud/adapter/common.rb', line 48