Module: Lich::DragonRealms::DRParser::Pattern

Defined in:
documented/dragonrealms/drinfomon/drparser.rb

Overview

Regex patterns for parsing server output.

Constants in this module match game output formats (experience display, inventory listings, spell rosters, room state, etc.). Patterns are frozen for reuse and performance.

Constant Summary collapse

ExpColumns =
/(?:\s*(?<skill>[a-zA-Z\s]+)\b:\s*(?<rank>\d+)\s+(?<percent>\d+)%\s+(?<rate>[a-zA-Z\s]+)\b)/.freeze
BriefExpOn =
%r{<component id='exp .*?<d cmd='skill (?<skill>[a-zA-Z\s]+)'.*:\s+(?<rank>\d+)\s+(?<percent>\d+)%\s*\[\s?(?<rate>\d+)\/34\].*?<\/component>}.freeze
BriefExpOff =
%r{<component id='exp .*?\b(?<skill>[a-zA-Z\s]+)\b:\s+(?<rank>\d+)\s+(?<percent>\d+)%\s+\b(?<rate>[a-zA-Z\s]+)\b.*?<\/component>}.freeze
NameRaceGuild =
/^Name:\s+\b(?<name>.+)\b\s+Race:\s+\b(?<race>.+)\b\s+Guild:\s+\b(?<guild>.+)\b\s+/.freeze
GenderAgeCircle =
/^Gender:\s+\b(?<gender>.+)\b\s+Age:\s+\b(?<age>.+)\b\s+Circle:\s+\b(?<circle>.+)/.freeze
StatValue =
/(?<stat>Strength|Agility|Discipline|Intelligence|Reflex|Charisma|Wisdom|Stamina|Favors|TDPs)\s+:\s+(?<value>\d+)/.freeze
TDPValue =
/You have (?<tdp>\d+) TDPs\./.freeze
EncumbranceValue =
/^\s*Encumbrance\s+:\s+(?<encumbrance>[\w\s'?!]+)$/.freeze
LuckValue =
/^\s*Luck\s+:\s+.*\((?<luck>[-\d]+)\/3\)/.freeze
BalanceValue =
/^(?:You are|\[You're)(?:.*,)? (?<balance>#{Regexp.union(DR_BALANCE_VALUES)}) balanced?\b/.freeze
PositionValue =
/balanced? (?:and|with) (?<position>#{Regexp.union(DR_POSITION_VALUES.keys)})/.freeze
ExpClearMindstate =
%r{<component id='exp (?<skill>[a-zA-Z\s]+)'><\/component>}.freeze
RoomPlayers =
%r{\'room players\'>Also here: (?<players>.*)\.</component>}.freeze
RoomPlayersEmpty =
%r{\'room players\'></component>}.freeze
RoomObjs =
%r{\'room objs\'>(?<objs>.*)</component>}.freeze
RoomObjsEmpty =
%r{\'room objs\'></component>}.freeze
GroupMembers =
%r{<pushStream id="group"/>  (?<member>\w+):}.freeze
GroupMembersEmpty =
%r{<pushStream id="group"/>Members of your group:}.freeze
ExpModsStart =
/^(<.*?\/>)?The following skills are currently under the influence of a modifier/.freeze
ExpModLine =
/^(?:<preset id="(?:speech|thought)">)?(?<sign>\+|--)(?<value>\d+)\s+(?<skill>[\w\s]+)(?:<\/preset>)?$/.freeze
KnownSpellsStart =
/^You recall the spells you have learned/.freeze
BarbarianAbilitiesStart =
/^You know the (Berserks:)/.freeze
ThiefKhriStart =
/^From the Subtlety tree, you know the following khri:/.freeze
SpellBookFormat =
/^You will .* (?<format>column-formatted|non-column) output for the SPELLS verb/.freeze
PlayedAccount =
/^(?:<.*?\/>)?Account Info for (?<account>.+):/.freeze
PlayedSubscription =
/Current Account Status: (?<subscription>F2P|Basic|Premium|Platinum)/.freeze
LastLogoff =
/^\s+Logoff :  (?<weekday>[A-Z][a-z]{2}) (?<month>[A-Z][a-z]{2}) (?<day>[\s\d]{2}) (?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}) ET (?<year>\d{4})/.freeze
Rested_EXP =
%r{^<component id='exp rexp'>Rested EXP Stored:\s*(?<stored>.*?)\s*Usable This Cycle:\s*(?<usable>.*?)\s*Cycle Refreshes:\s*(?<refresh>.*)</component>}.freeze
Rested_EXP_F2P =
%r{^<component id='exp rexp'>\[Unlock Rested Experience}.freeze
TDPValue_XPWindow =
%r{^<component id='exp tdp'>\s*TDPs:\s*(?<tdp>\d+)</component>}.freeze
FavorValue_XPWindow =
%r{^<component id='exp favor'>\s*Favors:\s*(?<favor>\d+)</component>}.freeze
InventoryListStart =

Headers that open a DR inventory scrape whose output we mine for item IDs. The two differ in completeness, which decides how we write GameObj (see .parse):

INV LIST -> COMPLETE: lists everything, so we clear and repopulate.
"You take a moment and rummage about your person, taking stock of
 your possessions..."
INV SEARCH <word> / INV <category> full -> PARTIAL: lists only the
matching items, so we upsert without clearing. The header's trailing
phrase is a per-category friendly name (e.g. "looking for gems...",
"looking for armor and shields...") and is not matched here.

Both are anchored to the start of the stream line so quoted/chat/book text containing the phrase mid-line cannot open a (mutating) scrape (cf. GameShutdown). Logs confirm the exact prefixes: INV LIST is bare at line start; the "looking for" verbs carry exactly one leading , which is allowed optionally.

%r{^You take a moment and rummage about your person, taking stock of your possessions}.freeze
InventorySearchStart =
%r{^(?:<roundTime[^>]*/>)?You rummage about your person, looking for}.freeze
GameShutdown =

Scheduled shutdown announcement, e.g. "Announcement: DragonRealms will be shutting down in 15 minutes for routine maintenance." Anchored to the start of the line (with the optional "Announcement:" prefix) so quoted or chat text containing the phrase cannot trigger it. Only the stem is stable: the count drops to "1 minute" (singular) and the reason/trailing text varies ("...as soon as possible."), so match the stem and capture the count.

/^(?:Announcement:\s+)?DragonRealms will be shutting down in (?<minutes>\d+) minutes?\b/.freeze
OutputClassMono =

Spell parsing patterns (check_known_spells)

%r{^<output class="mono"/>}.freeze
OutputClassEmpty =
%r{^<output class=""/>}.freeze
SpellbookName =
/^[\w\s]+:/.freeze
SpellSlotInfo =
/Slot\(s\): \d+ \s+ Min Prep: \d+ \s+ Max Prep: \d+/.freeze
SpellChapterStart =
/^In the chapter entitled|^You have temporarily memorized|^From your apprenticeship you remember practicing/.freeze
SpellFeatsStart =
/^You recall proficiency with the magic feats of/.freeze
SpellsEnd =
/^You can use SPELL STANCE|^You have (?:no|yet to receive any) training in the magical arts|You have no desire to soil yourself with magical trickery|^You really shouldn't be loitering here|\(Use SPELL|\(Use PREPARE/.freeze
ChapterEntitled =
/^In the chapter entitled "[\w\s'-]+", you have notes on the /.freeze
TemporarilyMemorized =
/^You have temporarily memorized the /.freeze
ApprenticeshipPractice =
/^From your apprenticeship you remember practicing with the /.freeze
SpellSuffix =
/ spells?\./.freeze
CommaAnd =
/,? and /.freeze
PopBoldTag =
/<popBold\/>/.freeze
BarbarianAbility =

Barbarian ability parsing patterns (check_known_barbarian_abilities)

/^(?:<(?:push|pop)Bold\/>)?You know the (?:Berserks|Forms|Roars|Meditations):(?:<(?:push|pop)Bold\/>)?/.freeze
BarbarianMastery =
/^(?:<(?:push|pop)Bold\/>)?You know the Masteries:(?:<(?:push|pop)Bold\/>)?/.freeze
BarbarianTrainingRemaining =
/^You recall that you have \d+ training sessions? remaining with the Guild/.freeze
ThiefKhriTree =

Thief khri parsing patterns (check_known_thief_khri)

/^From the (?:Subtlety|Finesse|Potence) tree, you know the following khri:/.freeze
ThiefAvailableSlots =
/^You have \d+ available slots?/.freeze
KhriType =
/\(.+?\)/.freeze