Module: Lich::DragonRealms::DRCMM
- Defined in:
- documented/dragonrealms/commons/common-moonmage.rb
Overview
Module for DRCMM functionalities This module provides methods for observing and interacting with celestial bodies.
Class Method Summary collapse
-
.align(skill) ⇒ String
Aligns the telescope based on the specified skill.
-
.any_celestial_object? ⇒ Boolean
returns true if at least one moon (katamba, yavash, xibar) or the sun are above the horizon and won’t set for at least another ~4 minutes.
-
.bright_celestial_object? ⇒ Boolean
returns true if at least one bright moon (yavash, xibar) or the sun are above the horizon and won’t set for at least another ~4 minutes.
-
.center_telescope(target) ⇒ String
Centers the telescope on a specified target.
-
.check_moonwatch ⇒ void
Checks if the moonwatch script is running and starts it if not.
-
.drop_moon_weapon? ⇒ Boolean
Drops the moon weapon in your hands, if any.
-
.find_visible_planets(planets, settings = nil) ⇒ Array
Finds visible planets based on the provided settings.
-
.get_bones(storage) ⇒ String
Retrieves bones from storage.
-
.get_bones?(storage) ⇒ Boolean
Checks if bones can be obtained from storage.
-
.get_div_tool(tool) ⇒ String
Retrieves a divination tool from storage.
-
.get_div_tool?(tool) ⇒ Boolean
Checks if a divination tool can be obtained from storage.
-
.get_telescope(storage) ⇒ String
Retrieves a telescope from storage.
-
.get_telescope?(telescope_name = 'telescope', storage) ⇒ Boolean
Checks if a telescope can be obtained from storage.
-
.hold_moon_weapon? ⇒ Boolean
Try to hold a moon weapon.
-
.holding_moon_weapon? ⇒ Boolean
Is a moon weapon in your hands? Checks if a moon weapon is currently held.
-
.is_moon_weapon?(item) ⇒ Boolean
Does the item appear to be a moon weapon? Determines if the given item is a moon weapon.
-
.moon_used_to_summon_weapon ⇒ String?
Determines which moon was used to summon a weapon.
-
.moon_visible?(moon_name) ⇒ Boolean
Returns true if the moon is above the horizon and won’t set for at least another ~4 minutes.
-
.moons_visible? ⇒ Boolean
Returns true if at least one moon (e.g. katamba, yavash, xibar) is above the horizon and won’t set for at least another ~4 minutes.
-
.observe(thing) ⇒ String
Observes a celestial body or the heavens.
-
.peer_telescope ⇒ String
Peers through the telescope to observe celestial bodies.
-
.predict(thing) ⇒ String
Predicts the state of a celestial body.
-
.roll_bones(storage) ⇒ String
Rolls the bones and stores them afterward.
-
.set_moon_data(data) ⇒ Hash
Sets the moon data based on the provided information.
-
.set_planet_data(data, settings = nil) ⇒ Hash
Sets the planet data based on the provided information.
-
.store_bones(storage) ⇒ String
Stores bones in the specified storage.
-
.store_bones?(storage) ⇒ Boolean
Checks if bones can be stored in the specified storage.
-
.store_div_tool(tool) ⇒ String
Stores a divination tool in the specified storage.
-
.store_div_tool?(tool) ⇒ Boolean
Checks if a divination tool can be stored in the specified storage.
-
.store_telescope(storage) ⇒ String
Stores a telescope in the specified storage.
-
.store_telescope?(telescope_name = "telescope", storage) ⇒ Boolean
Checks if a telescope can be stored in the specified storage.
-
.study_sky ⇒ String
Studies the sky for additional information.
-
.update_astral_data(data, settings = nil) ⇒ Hash
Updates the astral data based on the provided information.
-
.use_div_tool(tool_storage) ⇒ String
Uses a divination tool after retrieving it from storage.
-
.visible_moons ⇒ Array
Returns list of moon names (e.g. katamba, yavash, xibar) that are above the horizon and won’t set for at least another ~4 minutes.
-
.wear_moon_weapon? ⇒ Boolean
There are many variants of a summoned moon weapon (blade, staff, sword, etc) This function checks if you’re holding one then tries to wear it.
Class Method Details
.align(skill) ⇒ String
Aligns the telescope based on the specified skill.
160 161 162 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 160 def align(skill) DRC.bput("align #{skill}", 'You focus internally') end |
.any_celestial_object? ⇒ Boolean
returns true if at least one moon (katamba, yavash, xibar) or the sun are
above the horizon and won't set for at least another ~4 minutes.
Checks if any celestial object is visible.
520 521 522 523 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 520 def any_celestial_object? check_moonwatch (UserVars.sun['day'] && UserVars.sun['timer'] >= 4) || moons_visible? end |
.bright_celestial_object? ⇒ Boolean
returns true if at least one bright moon (yavash, xibar) or the sun are
above the horizon and won't set for at least another ~4 minutes.
Checks if at least one bright celestial object is visible.
509 510 511 512 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 509 def bright_celestial_object? check_moonwatch (UserVars.sun['day'] && UserVars.sun['timer'] >= 4) || moon_visible?('xibar') || moon_visible?('yavash') end |
.center_telescope(target) ⇒ String
Centers the telescope on a specified target.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 135 def center_telescope(target) case DRC.bput("center telescope on #{target}", 'Center what', 'You put your eye', 'open it to make any use of it', 'The pain is too much', "That's a bit tough to do when you can't see the sky", "You would probably need a periscope to do that", 'Your search for', 'Your vision is too fuzzy', "You'll need to open it to make any use of it", 'You must have both hands free') when 'The pain is too much', "That's a bit tough to do when you can't see the sky" echo("Planet #{target} not visible. Are you indoors perhaps?") when "You'll need to open it to make any use of it" fput("open my telescope") fput("center telescope on #{target}") end end |
.check_moonwatch ⇒ void
This method returns an undefined value.
Checks if the moonwatch script is running and starts it if not.
561 562 563 564 565 566 567 568 569 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 561 def check_moonwatch return if Script.running?('moonwatch') echo 'moonwatch is not running. Starting it now' UserVars.moons = {} custom_require.call('moonwatch') echo "Run `#{$clean_lich_char}e autostart('moonwatch')` to avoid this in the future" pause 0.5 while UserVars.moons.empty? end |
.drop_moon_weapon? ⇒ Boolean
Drops the moon weapon in your hands, if any. Returns true if dropped something, false otherwise. Drops a moon weapon if held.
341 342 343 344 345 346 347 348 349 350 351 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 341 def drop_moon_weapon? = ["As you open your hand", "What were you referring to"] dropped_it = false if is_moon_weapon?(DRC.left_hand) dropped_it = dropped_it || DRC.bput("drop #{DRC.left_hand}", *) == "As you open your hand" end if is_moon_weapon?(DRC.right_hand) dropped_it = dropped_it || DRC.bput("drop #{DRC.right_hand}", *) == "As you open your hand" end return dropped_it end |
.find_visible_planets(planets, settings = nil) ⇒ Array
Finds visible planets based on the provided settings.
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 441 def find_visible_planets(planets, settings = nil) unless get_telescope?(settings.telescope_name, settings.telescope_storage) DRC.("Coult not get telescope to find visible planets") return end Flags.add('planet-not-visible', 'turns up fruitless') observed_planets = [] planets.each do |planet| center_telescope(planet) observed_planets << planet unless Flags['planet-not-visible'] Flags.reset('planet-not-visible') end Flags.delete('planet-not-visible') DRC.("Could not store telescope after finding visible planets") unless store_telescope?(settings.telescope_name, settings.telescope_storage) observed_planets end |
.get_bones(storage) ⇒ String
Retrieves bones from storage.
199 200 201 202 203 204 205 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 199 def get_bones(storage) if storage['tied'] DRC.bput("untie bones from my #{storage['container']}", 'You untie', 'You remove') else DRC.bput("get bones from my #{storage['container']}", 'You get') end end |
.get_bones?(storage) ⇒ Boolean
Checks if bones can be obtained from storage.
169 170 171 172 173 174 175 176 177 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 169 def get_bones?(storage) if storage['tied'] DRCI.untie_item?("bones", storage['tied']) elsif storage['container'] DRCI.get_item?("bones", storage['container']) else DRCI.get_item?("bones") end end |
.get_div_tool(tool) ⇒ String
Retrieves a divination tool from storage.
269 270 271 272 273 274 275 276 277 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 269 def get_div_tool(tool) if tool['tied'] DRC.bput("untie #{tool['name']} from my #{tool['container']}", tool['name']) elsif tool['worn'] DRC.bput("remove my #{tool['name']}", tool['name']) else DRC.bput("get my #{tool['name']} from my #{tool['container']}", tool['name'], 'you get') end end |
.get_div_tool?(tool) ⇒ Boolean
Checks if a divination tool can be obtained from storage.
239 240 241 242 243 244 245 246 247 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 239 def get_div_tool?(tool) if tool['tied'] DRCI.untie_item?(tool['name'], tool['container']) elsif tool['worn'] DRCI.remove_item?(tool['name']) else DRCI.get_item?(tool['name'], tool['container']) end end |
.get_telescope(storage) ⇒ String
Retrieves a telescope from storage.
89 90 91 92 93 94 95 96 97 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 89 def get_telescope(storage) if storage['tied'] DRC.bput("untie telescope from my #{storage['tied']}", 'You remove', 'You untie', '^What were you referring', 'Untie what', '^You are a little too busy') elsif storage['container'] DRC.bput("get telescope in my #{storage['container']}", 'You get a', 'You are already', "That can't be picked up", 'You need a free hand to pick that up.', 'What were you referring to', 'stop practicing your Athletics') else DRC.bput('get my telescope', 'You get a', 'What were you referring to', 'You are already holding that.', "That can't be picked up", 'You need a free hand to pick that up.', 'stop practicing your Athletics') end end |
.get_telescope?(telescope_name = 'telescope', storage) ⇒ Boolean
Checks if a telescope can be obtained from storage.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 50 def get_telescope?(telescope_name = 'telescope', storage) return true if DRCI.in_hands?(telescope_name) if storage['tied'] DRCI.untie_item?(telescope_name, storage['tied']) elsif storage['container'] unless DRCI.get_item?(telescope_name, storage['container']) echo("Telescope not found in container. Trying to get it from anywhere we can.") return DRCI.get_item?(telescope_name) end true else return DRCI.get_item?(telescope_name) end end |
.hold_moon_weapon? ⇒ Boolean
Try to hold a moon weapon. If you end up not holding a moon weapon then returns false. Attempts to hold a moon weapon if not already holding one.
368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 368 def hold_moon_weapon? return true if holding_moon_weapon? return false if [DRC.left_hand, DRC.right_hand].compact.length >= 2 ['moonblade', 'moonstaff'].each do |weapon| glance = DRC.bput("glance my #{weapon}", "You glance at a .* #{weapon}", "I could not find") case glance when /You glance/ return DRC.bput("hold my #{weapon}", "You grab", "You aren't wearing", "Hold hands with whom?", "You need a free hand") == "You grab" end end false end |
.holding_moon_weapon? ⇒ Boolean
Is a moon weapon in your hands? Checks if a moon weapon is currently held.
358 359 360 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 358 def holding_moon_weapon? return is_moon_weapon?(DRC.left_hand) || is_moon_weapon?(DRC.right_hand) end |
.is_moon_weapon?(item) ⇒ Boolean
Does the item appear to be a moon weapon? Determines if the given item is a moon weapon.
388 389 390 391 392 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 388 def is_moon_weapon?(item) return false unless item !(item =~ /^((black|red-hot|blue-white) moon(blade|staff))$/i).nil? end |
.moon_used_to_summon_weapon ⇒ String?
Determines which moon was used to summon a weapon.
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 398 def moon_used_to_summon_weapon # Note, if you have more than one weapon summoned at a time # then the results of this method are non-deterministic. # For example, if you have 2+ moonblades/staffs cast on different moons. ['moonblade', 'moonstaff'].each do |weapon| glance = DRC.bput("glance my #{weapon}", "You glance at a .* (black|red-hot|blue-white) moon(blade|staff)", "I could not find") case glance when /black moon/ return 'katamba' when /red-hot moon/ return 'yavash' when /blue-white moon/ return 'xibar' end end return nil end |
.moon_visible?(moon_name) ⇒ Boolean
Returns true if the moon is above the horizon and won’t set for at least another ~4 minutes. Checks if a specific moon is visible.
541 542 543 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 541 def moon_visible?(moon_name) visible_moons.include?(moon_name) end |
.moons_visible? ⇒ Boolean
Returns true if at least one moon (e.g. katamba, yavash, xibar) is above the horizon and won’t set for at least another ~4 minutes. Checks if at least one moon is visible.
531 532 533 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 531 def moons_visible? !visible_moons.empty? end |
.observe(thing) ⇒ String
Observes a celestial body or the heavens.
18 19 20 21 22 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 18 def observe(thing) output = "observe #{thing} in heavens" output = 'observe heavens' if thing.eql?('heavens') DRC.bput(output.to_s, 'Your search for', 'You see nothing regarding the future', 'Clouds obscure', 'Roundtime', 'The following heavenly bodies are visible:', "That's a bit hard to do while inside") end |
.peer_telescope ⇒ String
Peers through the telescope to observe celestial bodies.
118 119 120 121 122 123 124 125 126 127 128 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 118 def peer_telescope telescope_regex_patterns = Regexp.union( /The pain is too much/, /You see nothing regarding the future/, /You believe you've learned all that you can about/, Regexp.union(get_data('constellations').), /open it/, /Your vision is too fuzzy/, ) Lich::Util.issue_command("peer my telescope", telescope_regex_patterns, /Roundtime: /, usexml: false) end |
.predict(thing) ⇒ String
Predicts the state of a celestial body.
30 31 32 33 34 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 30 def predict(thing) output = "predict #{thing}" output = 'predict state all' if thing.eql?('all') DRC.bput(output.to_s, 'You predict that', 'You are far too', 'you lack the skill to grasp them fully', /(R|r)oundtime/i, 'You focus inwardly') end |
.roll_bones(storage) ⇒ String
Rolls the bones and stores them afterward.
225 226 227 228 229 230 231 232 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 225 def roll_bones(storage) get_bones(storage) DRC.bput('roll my bones', 'roundtime') waitrt? store_bones(storage) end |
.set_moon_data(data) ⇒ Hash
Sets the moon data based on the provided information.
488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 488 def set_moon_data(data) return data unless data['moon'] moon = visible_moons.first if moon data['cast'] = "cast #{moon}" elsif !moon && data['name'].downcase == 'cage of light' data['cast'] = "cast ambient" else echo "No moon available to cast #{data['name']}" data = nil end data end |
.set_planet_data(data, settings = nil) ⇒ Hash
Sets the planet data based on the provided information.
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 467 def set_planet_data(data, settings = nil) return data unless data['stats'] planets = get_data('constellations')[:constellations].select { |planet| planet['stats'] } planet_names = planets.map { |planet| planet['name'] } visible_planets = find_visible_planets(planet_names, settings) data['stats'].each do |stat| cast_on = planets.map { |planet| planet['name'] if planet['stats'].include?(stat) && visible_planets.include?(planet['name']) }.compact.first next unless cast_on data['cast'] = "cast #{cast_on}" return data end DRC.("Could not set planet data. Cannot cast #{data['abbrev']}") end |
.store_bones(storage) ⇒ String
Stores bones in the specified storage.
212 213 214 215 216 217 218 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 212 def store_bones(storage) if storage['tied'] DRC.bput("tie bones to my #{storage['container']}", 'You attach', 'You tie') else DRC.bput("put bones in my #{storage['container']}", 'You put') end end |
.store_bones?(storage) ⇒ Boolean
Checks if bones can be stored in the specified storage.
184 185 186 187 188 189 190 191 192 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 184 def store_bones?(storage) if storage['tied'] DRCI.tie_item?("bones", storage['tied']) elsif storage['container'] DRCI.put_away_item?("bones", storage['container']) else DRCI.put_away_item?("bones") end end |
.store_div_tool(tool) ⇒ String
Stores a divination tool in the specified storage.
284 285 286 287 288 289 290 291 292 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 284 def store_div_tool(tool) if tool['tied'] DRC.bput("tie #{tool['name']} to my #{tool['container']}", tool['name']) elsif tool['worn'] DRC.bput("wear my #{tool['name']}", tool['name']) else DRC.bput("put #{tool['name']} in my #{tool['container']}", tool['name'], 'You put') end end |
.store_div_tool?(tool) ⇒ Boolean
Checks if a divination tool can be stored in the specified storage.
254 255 256 257 258 259 260 261 262 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 254 def store_div_tool?(tool) if tool['tied'] DRCI.tie_item?(tool['name'], tool['container']) elsif tool['worn'] DRCI.wear_item?(tool['name']) else DRCI.put_away_item?(tool['name'], tool['container']) end end |
.store_telescope(storage) ⇒ String
Stores a telescope in the specified storage.
104 105 106 107 108 109 110 111 112 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 104 def store_telescope(storage) if storage['tied'] DRC.bput("tie telescope to my #{storage['tied']}", 'You attach', 'you tie', 'You are a little too busy') elsif storage['container'] DRC.bput("put telescope in my #{storage['container']}", 'You put') else DRC.bput('stow my telescope', 'Stow what', 'You put your telescope') end end |
.store_telescope?(telescope_name = "telescope", storage) ⇒ Boolean
Checks if a telescope can be stored in the specified storage.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 72 def store_telescope?(telescope_name = "telescope", storage) return true unless DRCI.in_hands?(telescope_name) if storage['tied'] DRCI.tie_item?(telescope_name, storage['tied']) elsif storage['container'] DRCI.put_away_item?(telescope_name, storage['container']) else DRCI.put_away_item?(telescope_name) end end |
.study_sky ⇒ String
Studies the sky for additional information.
40 41 42 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 40 def study_sky DRC.bput('study sky', 'You feel a lingering sense', 'You feel it is too soon', 'Roundtime', 'You are unable to sense additional information', 'detect any portents') end |
.update_astral_data(data, settings = nil) ⇒ Hash
Updates the astral data based on the provided information.
426 427 428 429 430 431 432 433 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 426 def update_astral_data(data, settings = nil) if data['moon'] data = set_moon_data(data) elsif data['stats'] data = set_planet_data(data, settings) end data end |
.use_div_tool(tool_storage) ⇒ String
Uses a divination tool after retrieving it from storage.
299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 299 def use_div_tool(tool_storage) get_div_tool(tool_storage) { 'charts' => 'review', 'bones' => 'roll', 'mirror' => 'gaze', 'bowl' => 'gaze', 'prism' => 'raise' }.select { |tool, _| tool_storage['name'].include?(tool) } .each { |tool, verb| DRC.bput("#{verb} my #{tool}", 'roundtime'); waitrt? } store_div_tool(tool_storage) end |
.visible_moons ⇒ Array
Returns list of moon names (e.g. katamba, yavash, xibar) that are above the horizon and won’t set for at least another ~4 minutes. Returns a list of visible moons.
551 552 553 554 555 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 551 def visible_moons check_moonwatch UserVars.moons.select { |moon_name, moon_data| UserVars.moons['visible'].include?(moon_name) && moon_data['timer'] >= 4 } .map { |moon_name, _moon_data| moon_name } end |
.wear_moon_weapon? ⇒ Boolean
There are many variants of a summoned moon weapon (blade, staff, sword, etc) This function checks if you’re holding one then tries to wear it. Returns true if what is in your hands is a summoned moon weapon that becomes worn. Returns false if you’re not holding a moon weapon, or you are but can’t wear it. elanthipedia.play.net/Shape_Moonblade Attempts to wear a moon weapon if held.
323 324 325 326 327 328 329 330 331 332 333 |
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 323 def wear_moon_weapon? = ["You're already", "You can't wear", "Wear what", "telekinetic"] wore_it = false if is_moon_weapon?(DRC.left_hand) wore_it = wore_it || DRC.bput("wear #{DRC.left_hand}", *) == "telekinetic" end if is_moon_weapon?(DRC.right_hand) wore_it = wore_it || DRC.bput("wear #{DRC.right_hand}", *) == "telekinetic" end return wore_it end |