Module: Lich::Gemstone::DetachableClientInit

Defined in:
documented/gemstone/detachable_client_init.rb

Overview

Builds the one-time state push a newly attached detachable-client frontend receives, so it starts with the vitals, status, hands, injuries, and exits it missed before attaching.

GemStone-owned: the DragonRealms feed differs substantially, so it has its own Lich::DragonRealms::DetachableClientInit. Shared code that overlaps (indicators, spell, hands, compass) is duplicated on purpose so each game can change its push without affecting the other. Waiting for the login feed and sending the result stay in detachable_client_send_init (global_defs.rb).

Constant Summary collapse

INDICATORS =

Every indicator the game sends. One not yet sent is reported as not visible rather than as an empty attribute.

%w[IconBLEEDING IconPOISONED IconDISEASED IconSTANDING IconKNEELING IconSITTING IconPRONE
IconSTUNNED IconHIDDEN IconINVISIBLE IconDEAD IconWEBBED IconJOINED].freeze
INJURY_AREAS =

Ordered list of body parts used to report wound and scar severity.

Returns:

  • (Array<String>) —

    the injury area names

%w[back leftHand rightHand head rightArm abdomen leftEye leftArm chest rightLeg neck leftLeg nsys rightEye].freeze
SHORT_DIRS =

Maps full direction names to single-letter compass abbreviations.

Long names include cardinal (north, south, east, west), intercardinal (northeast, northwest, southeast, southwest), and special directions (up, down, out).

Examples:

SHORT_DIRS["northeast"] #=> "ne"
SHORT_DIRS["up"] #=> "up"

Returns:

{
  'north' => 'n', 'northeast' => 'ne', 'east' => 'e', 'southeast' => 'se',
  'south' => 's', 'southwest' => 'sw', 'west' => 'w', 'northwest' => 'nw',
  'up' => 'up', 'down' => 'down', 'out' => 'out'
}.freeze

Class Method Summary collapse

Class Method Details

.init_string ⇒ String

Returns the XML to send to the frontend.

Returns:

  • (String) —

    the XML to send to the frontend



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'documented/gemstone/detachable_client_init.rb', line 54

def self.init_string
  [
    vitals,
    "<spell>#{encode(XMLData.prepared_spell)}</spell>",
    hands,
    indicators,
    "<progressBar id='pbarStance' value='#{XMLData.stance_value}'/>",
    "<progressBar id='mindState' value='#{XMLData.mind_value}' text='#{encode(XMLData.mind_text)}'/>",
    "<progressBar id='encumlevel' value='#{XMLData.encumbrance_value}' text='#{encode(XMLData.encumbrance_text)}'/>",
    injuries,
    compass,
  ].join
end

.ready? ⇒ Boolean

Whether enough of the login feed has been parsed to build the push. In the GemStone login feed the first follows everything the push describes (vitals, stance, mind, encumbrance, indicators, spell, hands, and room exits), whereas IconJOINED and arrive before some of it. XMLData.prompt starts empty and holds the prompt text once one has been parsed.

Returns:

  • (Boolean)


49
50
51
# File 'documented/gemstone/detachable_client_init.rb', line 49

def self.ready?
  !XMLData.prompt.empty?
end