Module: Lich::Common::RoomBlock

Defined in:
documented/common/room_block.rb

Overview

The Saga-identity stream (Frontend::CLIENT_STRING since #1700) renders a room in the main window as one inline element:

<room><name>[Area, Title] (230008)</name><description>...</description>
<exists>You also see ...</exists><crtrStatus .../><players>Also here: ...</players>
<exits>Obvious paths: <d>north</d>.</exits><extra></extra></room>

where the legacy stream (front ends sending their own Wrayth handshake) sends the roomName style, the roomDesc preset and one line per part. The rewrite targets that legacy layout; how the Saga client itself draws the block was not checked. The room components (room desc/objs/players/exits) are sent in both dialects and stay the parser's source of room state.

Constant Summary collapse

BLOCK =

A complete block; the body never spans another , so a block cut off before cannot swallow the next one in a multi-line string.

%r{<room>(?<body>(?:(?!<room>).)*?)</room>}m.freeze
COMPASS_DIRS =

The legacy stream's value for each exit name the game lists in "Obvious paths:", in the exits line's order.

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

The room number the game ends a room name with: "[Area, Title] (230008)".

/\((\d+)\)\s*\z/.freeze

Class Method Summary collapse

Class Method Details

.compass(exits) ⇒ String

The legacy stream's top-level compass for a room's exit names, in their order:

. Names without a compass value are left out; no exits give an empty compass. Also what a detachable client gets for the current room when it attaches, so every compass a front end gets has the same bytes.

Parameters:

  • exits (Array<String>) —

    exit names as the game lists them

Returns:



212
213
214
215
# File 'documented/common/room_block.rb', line 212

def compass(exits)
  dirs = exits.filter_map { |exit| %(<dir value="#{COMPASS_DIRS[exit]}"/>) if COMPASS_DIRS.key?(exit) }
  "<compass>#{dirs.join}</compass>"
end

.legacy_shape(server_string) ⇒ String

Rewrites a block into the legacy stream's layout, so code written for the legacy stream sees the same shape in both dialects. Markup.strip_xml and reget run it, so scripts get the legacy room lines; a client-bound rewrite can run it for front ends that do not understand :