Module: Lich::Util::Magicinfo
- Defined in:
- documented/magic-info.rb
Overview
Module for handling magic information commands.
This module provides methods to manage and display magic-related information.
Class Method Summary collapse
-
.announce ⇒ void
Displays the current active spells and their details.
-
.bonus ⇒ void
Toggles the display of spell bonuses in the active spell list.
-
.circle ⇒ void
Toggles the display of spell circle labels in the active spell list.
-
.clear(rd) ⇒ void
Clears the active spells from the list or a specific spell if provided.
-
.deprecated ⇒ void
Responds with a message indicating that the setting is no longer used.
-
.gift ⇒ void
Toggles the display of Gift of Lumnis information in the active spell list.
-
.help ⇒ void
Displays help information for magic commands.
-
.messages ⇒ void
Toggles the display of spell duration messages after each cast.
-
.request(type = 'announce') ⇒ void
Processes a magic command request based on the provided type.
-
.set(ra) ⇒ void
Sets the duration for a specified spell.
Class Method Details
.announce ⇒ void
This method returns an undefined value.
Displays the current active spells and their details.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'documented/magic-info.rb', line 210 def self.announce output = String.new if Spell.active.empty? output.concat("\r\n(no active spells)\r\n") else lastcircle = nil Spell.active.compact! total_boltAS, total_physicalAS, total_boltDS, total_physicalDS, total_elementalCS, total_mentalCS, total_spiritCS, total_sorcererCS, total_elementalTD, total_mentalTD, total_spiritTD, total_sorcererTD, total_strength, total_dodging, total_combatmaneuvers, total_damagefactor, total_block, total_constitution, total_health, total_uaf, total_asg, total_fof_offset = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Spell.active.sort_by { |spell| spell.num.to_i }.each { |spell| if @circle_state and (spell.circle != lastcircle) then output.concat("\r\n- #{spell.circlename}:\r\n") end bonus_string = ' - ' if @bonus_state if spell.bolt_as != 0 bonus_string.concat "#{spell.bolt_as} bAS, " total_boltAS += spell.bolt_as end if spell.physical_as != 0 bonus_string.concat "#{spell.physical_as} pAS, " total_physicalAS += spell.physical_as end if spell.bolt_ds != 0 bonus_string.concat "#{spell.bolt_ds} bDS, " total_boltDS += spell.bolt_ds end if spell.physical_ds != 0 bonus_string.concat "#{spell.physical_ds} pDS, " total_physicalDS += spell.physical_ds end if spell.elemental_cs != 0 bonus_string.concat "#{spell.elemental_cs} elemCS, " total_elementalCS += spell.elemental_cs end if spell.spirit_cs != 0 bonus_string.concat "#{spell.spirit_cs} spirCS, " total_spiritCS += spell.spirit_cs end if spell.sorcerer_cs != 0 bonus_string.concat "#{spell.sorcerer_cs} sorcCS, " total_sorcererCS += spell.sorcerer_cs end if spell.elemental_td != 0 bonus_string.concat "#{spell.elemental_td} elemTD, " total_elementalTD += spell.elemental_td end if spell.mental_td != 0 bonus_string.concat "#{spell.mental_td} mentTD, " total_mentalTD += spell.mental_td end if spell.spirit_td != 0 bonus_string.concat "#{spell.spirit_td} spirTD, " total_spiritTD += spell.spirit_td end if spell.sorcerer_td != 0 bonus_string.concat "#{spell.sorcerer_td} sorcTD, " total_sorcererTD += spell.sorcerer_td end if spell.strength.to_i != 0 bonus_string.concat "#{spell.strength} str, " total_strength += spell.strength.to_i end if spell.dodging.to_i != 0 bonus_string.concat "#{spell.dodging} dodge, " total_dodging += spell.dodging.to_i end if spell.combatmaneuvers.to_i != 0 bonus_string.concat "#{spell.combatmaneuvers} CM, " total_combatmaneuvers += spell.combatmaneuvers.to_i end if spell.damagefactor.to_i != 0 bonus_string.concat "#{spell.damagefactor}% DF, " total_damagefactor += spell.damagefactor.to_i end if spell.block.to_i != 0 bonus_string.concat "#{spell.block}% block, " total_block += spell.block.to_i end if spell.constitution.to_i != 0 bonus_string.concat "#{spell.constitution} con, " total_constitution += spell.constitution.to_i end if spell.health.to_i != 0 bonus_string.concat "#{spell.health} health, " total_health += spell.health.to_i end if spell.unarmed_af.to_i != 0 bonus_string.concat "#{spell.unarmed_af} UAF, " total_uaf += spell.unarmed_af.to_i end if spell.asg.to_i != 0 bonus_string.concat "#{spell.asg} AsG, " total_asg += spell.asg.to_i end begin if spell.fof_offset.to_i != 0 bonus_string.concat "#{spell.fof_offset} FoF offset, " total_fof_offset += spell.fof_offset.to_i end rescue nil end end output.concat(sprintf(" %04s: %-023s - %s%s\r\n", spell.num.to_s, spell.name, spell.remaining, bonus_string.chop.chop)) lastcircle = spell.circle } output.concat("\r\n") if @bonus_state total_offense_string = '' total_defense_string = '' total_stat_string = '' total_skill_string = '' total_offense_string = total_offense_string + total_boltAS.to_s + ' bAS, ' if total_boltAS != 0 total_offense_string = total_offense_string + total_physicalAS.to_s + ' pAS, ' if total_physicalAS != 0 total_offense_string = total_offense_string + total_elementalCS.to_s + ' elemCS, ' if total_elementalCS != 0 total_offense_string = total_offense_string + total_mentalCS.to_s + ' mentCS, ' if total_mentalCS != 0 total_offense_string = total_offense_string + total_spiritCS.to_s + ' spirCS, ' if total_spiritCS != 0 total_offense_string = total_offense_string + total_sorcererCS.to_s + ' sorcCS, ' if total_sorcererCS != 0 total_offense_string = total_offense_string + total_damagefactor.to_s + '% DF ' if total_damagefactor != 0 total_offense_string = total_offense_string + total_uaf.to_s + ' UAF, ' if total_uaf != 0 total_offense_string.chop!.chop! total_defense_string = total_defense_string + total_boltDS.to_s + ' bDS, ' if total_boltDS != 0 total_defense_string = total_defense_string + total_physicalDS.to_s + ' pDS, ' if total_physicalDS != 0 total_defense_string = total_defense_string + total_elementalTD.to_s + ' elemTD, ' if total_elementalTD != 0 total_defense_string = total_defense_string + total_mentalTD.to_s + ' mentTD, ' if total_mentalTD != 0 total_defense_string = total_defense_string + total_spiritTD.to_s + ' spirTD, ' if total_spiritTD != 0 total_defense_string = total_defense_string + total_sorcererTD.to_s + ' sorcTD, ' if total_sorcererTD != 0 total_defense_string = total_defense_string + total_block.to_s + '% block, ' if total_block != 0 total_defense_string = total_defense_string + total_asg.to_s + ' AsG, ' if total_asg != 0 total_defense_string = total_defense_string + total_fof_offset.to_s + ' FoF offset, ' if total_fof_offset != 0 total_defense_string.chop!.chop! total_stat_string = total_stat_string + total_strength.to_s + ' str, ' if total_strength != 0 total_stat_string = total_stat_string + total_constitution.to_s + ' con, ' if total_constitution != 0 total_stat_string = total_stat_string + total_health.to_s + ' health, ' if total_health != 0 total_stat_string.chop!.chop! total_skill_string = total_skill_string + total_dodging.to_s + ' dodge, ' if total_dodging != 0 total_skill_string = total_skill_string + total_combatmaneuvers.to_s + ' CM, ' if total_combatmaneuvers != 0 total_skill_string.chop!.chop! output.concat("- Totals:\r\n") output.concat(" Offense: #{total_offense_string}\r\n") if total_offense_string.length > 0 output.concat(" Defense: #{total_defense_string}\r\n") if total_defense_string.length > 0 output.concat(" Stats: #{total_stat_string}\r\n") if total_stat_string.length > 0 output.concat(" Skills: #{total_skill_string}\r\n") if total_skill_string.length > 0 output.concat("\r\n") end end respond output if @gift_state string_to_send = 'lumnis info' do_client("#{string_to_send}") end end |
.bonus ⇒ void
This method returns an undefined value.
Toggles the display of spell bonuses in the active spell list.
142 143 144 145 146 147 148 149 150 151 152 |
# File 'documented/magic-info.rb', line 142 def self.bonus if @bonus_state == false Lich.magicinfo_bonus = true @bonus_state = true respond('Spell bonuses will be displayed in the active spell list.') else Lich.magicinfo_bonus = false @bonus_state = false respond('Spell bonuses will not be displayed in the active spell list.') end end |
.circle ⇒ void
This method returns an undefined value.
Toggles the display of spell circle labels in the active spell list.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'documented/magic-info.rb', line 111 def self.circle if @circle_state == false Lich.magicinfo_circle = true @circle_state = true respond('Spell circle labels will be displayed in the active spell list.') else Lich.magicinfo_circle = false @circle_state = false respond('Spell circle labels will not be displayed in the active spell list.') end end |
.clear(rd) ⇒ void
This method returns an undefined value.
Clears the active spells from the list or a specific spell if provided.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'documented/magic-info.rb', line 84 def self.clear(rd) # requested_drop = rd if rd.nil? or rd.empty? while (spell = Spell.active.first) spell.putdown end Spell.active.clear respond('Active spell list cleared.') else if rd.to_i == 0 spell = Spell[rd] else spell = Spell[rd.to_i] end if spell.nil? respond("Could not identify spell #{$1}") else spell.putdown respond("#{spell} has been removed from the list.") end end end |
.deprecated ⇒ void
This method returns an undefined value.
Responds with a message indicating that the setting is no longer used.
174 175 176 |
# File 'documented/magic-info.rb', line 174 def self.deprecated respond('this setting is no longer used') end |
.gift ⇒ void
This method returns an undefined value.
Toggles the display of Gift of Lumnis information in the active spell list.
158 159 160 161 162 163 164 165 166 167 168 |
# File 'documented/magic-info.rb', line 158 def self.gift if @gift_state == false Lich.magicinfo_gift = true @gift_state = true respond('Gift of Lumnis will be displayed in the active spell list.') else Lich.magicinfo_gift = false @gift_state = false respond('Gift of Lumnis will not be displayed in the active spell list.') end end |
.help ⇒ void
This method returns an undefined value.
Displays help information for magic commands.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'documented/magic-info.rb', line 62 def self.help respond respond 'Magic usage:' respond ' ;magic - Shows your active spells and their durations.' respond " ;magic set [spell#] [mins] - Sets a spell's duration." respond ' ;magic clear [spell] - Remove a single spell.' respond ' ;magic clear - Clears the whole list.' respond ' ;magic circles - Toggles the display of spell circle labels with the active spell list.' respond ' ;magic bonuses - Toggles the display of spell bonuses with the active spell list.' respond ' ;magic gift - Toggles the display of Gift of Lumnis information with the active spell list.' respond ' ;magic messages - Toggles the display of a duration message after each cast.' respond end |
.messages ⇒ void
This method returns an undefined value.
Toggles the display of spell duration messages after each cast.
127 128 129 130 131 132 133 134 135 136 |
# File 'documented/magic-info.rb', line 127 def self. # if $infomon_values['show_messages'] == false # $infomon_values['show_messages'] = true # respond('Showing spell duration messages after each cast is now on.') # else # $infomon_values['show_messages'] = false # respond('Showing spell duration messages after each cast is now off.') # end respond('This command may be coming soon!') end |
.request(type = 'announce') ⇒ void
This method returns an undefined value.
Processes a magic command request based on the provided type.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'documented/magic-info.rb', line 23 def self.request(type = 'announce') case type when /help/ self.help # Ok, that's just wrong. when /announce/ self.announce when /clear(?:\s+(.*)|$)/ if $1.nil? self.clear(nil) else dump = $1.dup self.clear(dump) end when /circle/ self.circle when /messages/ self. when /bonus/ self.bonus when /gift/ self.gift when /set (.*)/ if $1.nil? self.set(nil) else pump = $1.dup self.set(pump) end when /update|save|load/ self.deprecated else _respond; _respond "Magic error! Type ';magic help' for usage information."; _respond end end |
.set(ra) ⇒ void
This method returns an undefined value.
Sets the duration for a specified spell.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'documented/magic-info.rb', line 184 def self.set(ra) request_actions = ra if request_actions.nil? respond("Magic error! Type ';magic help' for usage information.") else set_request_elements = request_actions.split if set_request_elements[0].to_i == 0 respond("Use the spell number for accuracy. Type ';magic help' for usage information.") else spell = Spell[set_request_elements[0].to_i] end if spell.nil? respond("Magic error! Requested spell cannot be found.") else spell.putup spell.timeleft = set_request_elements[1].to_i respond set_request_elements.length respond("Spell '#{spell}' is now set as having #{spell.timeleft} minutes left.") end end end |