Module: Lich::Gemstone::Infomon::XMLParser
- Defined in:
- lib/gemstone/infomon/xmlparser.rb
Overview
This module handles all of the logic for parsing game lines that Infomon depends on.
Defined Under Namespace
Modules: Pattern
Class Method Summary collapse
-
.parse(line) ⇒ Symbol
Parses a given line of text to identify and handle various game events.
Class Method Details
.parse(line) ⇒ Symbol
Parses a given line of text to identify and handle various game events.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/gemstone/infomon/xmlparser.rb', line 111 def self.parse(line) # O(1) vs O(N) return :noop unless line =~ Pattern::All begin case line # This detects for death messages in XML that are not matched with appropriate combat attributes above. when Pattern::NpcDeathMessage match = Regexp.last_match if (npc = GameObj.npcs.find { |obj| obj.id == match[:npc_id] && obj.status !~ /\b(?:dead|gone)\b/ }) npc.status = 'dead' end :ok when Pattern::Group_Short return :noop unless (match_data = Group::Observer.wants?(line)) Group::Observer.consume(line.strip, match_data) :ok when Pattern::Also_Here_Arrival return :noop unless Lich::Claim::Lock.locked? line.scan(%r{<a exist=(?:'|")(?<id>.*?)(?:'|") noun=(?:'|")(?<noun>.*?)(?:'|")>(?<name>.*?)</a>}).each { |player_found| XMLData.arrival_pcs.push(player_found[1]) unless XMLData.arrival_pcs.include?(player_found[1]) } :ok when Pattern::StowListOutputStart StowList.reset :ok when Pattern::StowListContainer, Pattern::StowSetContainer1, Pattern::StowSetContainer2 match = Regexp.last_match if GameObj[match[:id]] StowList.__send__("#{match[:type].downcase}=", GameObj[match[:id]]) else StowList.__send__("#{match[:type].downcase}=", GameObj.new(match[:id], match[:noun], match[:name], nil, (match[:after].nil? ? nil : match[:after].strip))) end StowList.checked = true if line =~ Pattern::StowListContainer :ok when Pattern::ReadyListOutputStart ReadyList.reset :ok when Pattern::ReadyListNormal, Pattern::ReadyListAmmo2, Pattern::ReadyListSheathsSet, Pattern::ReadyItemSet match = Regexp.last_match if GameObj[match[:id]] ReadyList.__send__("#{Lich::Util.normalize_name(match[:type].downcase)}=", GameObj[match[:id]]) else ReadyList.__send__("#{Lich::Util.normalize_name(match[:type].downcase)}=", GameObj.new(match[:id], match[:noun], match[:name], nil, (match[:after].nil? ? nil : match[:after].strip))) end :ok when Pattern::ReadyListFinished ReadyList.checked = true :ok when Pattern::ReadyItemClear match = Regexp.last_match ReadyList.__send__("#{Lich::Util.normalize_name(match[:type].downcase)}=", nil) :ok else :noop end rescue StandardError respond "--- Lich: error: Infomon::XMLParser.parse: #{$!}" respond "--- Lich: error: line: #{line}" Lich.log "error: Infomon::XMLParser.parse: #{$!}\n\t#{$!.backtrace.join("\n\t")}" Lich.log "error: line: #{line}\n\t" end end |