Module: Lich::DragonRealms::XMLDelta
- Extended by:
- Common::XMLParserDelta::Base
- Defined in:
- documented/dragonrealms/xml_delta.rb
Overview
DragonRealms' semantic deltas for the shared server-stream parser. See Lich::Common::XMLParserDelta for the composition and the hook contracts.
Constant Summary collapse
- SUBTITLE_ROOM =
Pattern to extract the room title and optional UID marker from a DragonRealms subtitle.
Matches "[Room Name]" and an optional trailing UID marker " (230008)" or " (**)". Named captures: :roomtitle for the bracketed room name, :uid for the numeric ID or asterisks, or nil if the marker is absent.
%r{(?<roomtitle>\[.*?\])(?:\s\((?<uid>\d+|\*+)\))?}.freeze
Class Method Summary collapse
-
.apply_crtr_status(id, flags, in_room_objs: false) ⇒ Object
DragonRealms'
batch carries its own id and arrives after the room-objs component, so it is applied at once, id-first: Creature.sync registers the creature and marks it in the room even when no link names it (the legacy stream has none). -
.main_subtitle(subtitle, nav_uid_pending:) ⇒ Object
DragonRealms subtitles read " - [Bosque Deriel, Hermit's Shacks]", with a trailing UID marker only when the game's ShowRoomID flag is ON: " (230008)" for a room with a UID, " (**)" for one without.
Methods included from Common::XMLParserDelta::Base
apply_crtr_status, main_subtitle
Class Method Details
.apply_crtr_status(id, flags, in_room_objs: false) ⇒ Object
DragonRealms'
62 63 64 65 66 67 |
# File 'documented/dragonrealms/xml_delta.rb', line 62 def self.apply_crtr_status(id, flags, in_room_objs: false) # rubocop:disable Lint/UnusedMethodArgument return false unless defined?(Lich::DragonRealms::Creature) Lich::DragonRealms::Creature.sync(id, flags) true end |
.main_subtitle(subtitle, nav_uid_pending:) ⇒ Object
DragonRealms subtitles read " - [Bosque Deriel, Hermit's Shacks]", with a trailing UID marker only when the game's ShowRoomID flag is ON: " (230008)" for a room with a UID, " ()" for one without. )" clears it to 0 (explicit "no UID"). A ShowRoomID-OFF subtitle has no marker, so room_id is untouched (never write 0 blindly). The title stays UID-free. A blank or identity-less subtitle (e.g. " - ") has no "[...]", so nothing is updated and the prior title stands.
show_room_id records whether the game displayed the RealID this arrival (marker present == ShowRoomID ON), so the outbound room-name/subtitle rewrite can preserve that choice GemStone-style.
47 48 49 50 51 52 53 54 |
# File 'documented/dragonrealms/xml_delta.rb', line 47 def self.main_subtitle(subtitle, nav_uid_pending:) room = subtitle.match(SUBTITLE_ROOM) return {} unless room update = { room_title: "[#{room[:roomtitle]}]", nav_uid_pending: false, show_room_id: !room[:uid].nil? } update[:room_id] = (room[:uid] =~ /\A\d+\z/ ? room[:uid].to_i : 0) if room[:uid] && !nav_uid_pending update end |