Module: Lich::DragonRealms::DRCMM

Defined in:
documented/dragonrealms/commons/common-moonmage.rb

Constant Summary collapse

MOON_WEAPON_REGEX =

Moon weapon detection regex. Matches summoned moon weapons in hand. Colors: black (Katamba), red-hot (Yavash), blue-white (Xibar). Moon weapon detection regex. Matches summoned moon weapons in hand. Colors: black (Katamba), red-hot (Yavash), blue-white (Xibar).

Examples:

Matches

"black moonblade"
"red-hot moonstaff"

See Also:

/^(?:black|red-hot|blue-white) moon(?:blade|staff)$/i.freeze
MOON_WEAPON_NAMES =

Canonical moon weapon base names for glance/hold operations. Canonical moon weapon base names for glance/hold operations.

Examples:

Names

"moonblade"
"moonstaff"
['moonblade', 'moonstaff'].freeze
MOON_WEAR_MESSAGES =

Expected game messages when wearing a summoned moon weapon. Expected game messages when wearing a summoned moon weapon.

Examples:

Messages

"You're already"
"You can't wear"
["You're already", "You can't wear", "Wear what", "telekinetic"].freeze
MOON_DROP_MESSAGES =

Expected game messages when dropping a summoned moon weapon. Expected game messages when dropping a summoned moon weapon.

Examples:

Messages

"As you open your hand"
"What were you referring to"
["As you open your hand", "What were you referring to"].freeze
MOON_COLOR_TO_NAME =

Maps moon weapon color adjective to moon name. Maps moon weapon color adjective to moon name.

Examples:

Mapping

"black" => "katamba"
"red-hot" => "yavash"
"blue-white" => "xibar"
{
  'black'      => 'katamba',
  'red-hot'    => 'yavash',
  'blue-white' => 'xibar'
}.freeze
MOON_GLANCE_REGEX =

Regex for extracting moon color from glance output. Regex for extracting moon color from glance output.

Examples:

Matches

"You glance at a black moonblade"
"You glance at a blue-white moonstaff"
/You glance at a .* (?<color>black|red-hot|blue-white) moon(?:blade|staff)/i.freeze
DIV_TOOL_VERBS =

Maps divination tool keywords to their use verb. Maps divination tool keywords to their use verb.

Examples:

Mapping

"charts" => "review"
"bones" => "roll"
{
  'charts' => 'review',
  'bones'  => 'roll',
  'mirror' => 'gaze',
  'bowl'   => 'gaze',
  'prism'  => 'raise'
}.freeze
MOON_VISIBILITY_TIMER_THRESHOLD =

Minimum minutes remaining before a celestial body sets to be considered "visible." Minimum minutes remaining before a celestial body sets to be considered "visible."

4
CENTER_TELESCOPE_MESSAGES =

Expected game responses when centering a telescope on a target. Expected game responses when centering a telescope on a target.

Examples:

Messages

"Center what"
"You put your eye"
[
  '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'
].freeze
OBSERVE_MESSAGES =

Expected game responses when observing celestial bodies. Used by observe method to match bput responses. Patterns validated via in-game testing with test_observe_comprehensive.lic Note: Roundtime is intentionally NOT included - every observation that produces a Roundtime also produces a more specific pattern that matches first. Expected game responses when observing celestial bodies. Used by observe method to match bput responses.

Examples:

Messages

"Your search for"
"You see nothing regarding the future"
[
  'Your search for',                           # Covers: fruitless, foiled by daylight/darkness
  'You see nothing regarding the future',      # No vision available
  'Clouds obscure',                            # Weather blocking
  'The following heavenly bodies are visible:', # Observe heavens listing
  "That's a bit hard to do while inside",      # Indoor blocking
  'too close to the sun',                      # Planet visibility (solar conjunction)
  'too faint for you to pick out',             # Requires telescope
  'You learn nothing of the future',           # Circle too low for body
  'below the horizon',                         # Body not visible
  'You have not pondered',                     # Observation cooldown
  'You are unable to make use',                # Cooldown followup
  'While the sighting',                        # Partial success
  'You learned something useful'               # Full success
].freeze

Class Method Summary collapse

Class Method Details

.align(skill) ⇒ void

This method returns an undefined value.

Aligns the telescope based on the specified skill.

Examples:

Align the telescope

align("astrology")

Parameters:

  • skill (String)

    the skill to align with



246
247
248
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 246

def align(skill)
  DRC.bput("align #{skill}", 'You focus internally')
end

.any_celestial_object?Boolean

Checks if any celestial object is visible.

Examples:

Check for any celestial objects

any_celestial_object?

Returns:

  • (Boolean)

    true if any celestial object is visible



573
574
575
576
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 573

def any_celestial_object?
  check_moonwatch
  (UserVars.sun['day'] && UserVars.sun['timer'] >= MOON_VISIBILITY_TIMER_THRESHOLD) || moons_visible?
end

.bright_celestial_object?Boolean

Checks if a bright celestial object is visible.

Examples:

Check for bright celestial objects

bright_celestial_object?

Returns:

  • (Boolean)

    true if a bright celestial object is visible



564
565
566
567
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 564

def bright_celestial_object?
  check_moonwatch
  (UserVars.sun['day'] && UserVars.sun['timer'] >= MOON_VISIBILITY_TIMER_THRESHOLD) || moon_visible?('xibar') || moon_visible?('yavash')
end

.center_telescope(target) ⇒ void

This method returns an undefined value.

Centers the telescope on a specified target.

Examples:

Center the telescope on a planet

center_telescope("Mars")

Parameters:

  • target (String)

    the target to center on



231
232
233
234
235
236
237
238
239
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 231

def center_telescope(target)
  case DRC.bput("center telescope on #{target}", *CENTER_TELESCOPE_MESSAGES)
  when 'The pain is too much', "That's a bit tough to do when you can't see the sky"
    Lich::Messaging.msg("bold", "DRCMM: 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_moonwatchvoid

This method returns an undefined value.

Checks if the moonwatch script is running and starts it if not.

Examples:

Check and start moonwatch

check_moonwatch


609
610
611
612
613
614
615
616
617
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 609

def check_moonwatch
  return if Script.running?('moonwatch')

  Lich::Messaging.msg("bold", "DRCMM: moonwatch is not running. Starting it now.")
  UserVars.moons = {}
  start_script('moonwatch')
  Lich::Messaging.msg("plain", "DRCMM: 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

Attempts to drop a moon weapon if one is held.

Examples:

Drop a moon weapon

drop_moon_weapon?

Returns:

  • (Boolean)

    true if a moon weapon was dropped



410
411
412
413
414
415
416
417
418
419
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 410

def drop_moon_weapon?
  dropped_it = false
  if is_moon_weapon?(DRC.left_hand)
    dropped_it = dropped_it || DRC.bput("drop #{DRC.left_hand}", *MOON_DROP_MESSAGES) == "As you open your hand"
  end
  if is_moon_weapon?(DRC.right_hand)
    dropped_it = dropped_it || DRC.bput("drop #{DRC.right_hand}", *MOON_DROP_MESSAGES) == "As you open your hand"
  end
  dropped_it
end

.find_visible_planets(planets, settings = nil) ⇒ Array<String>

Finds visible planets based on the provided settings.

Examples:

Find visible planets

find_visible_planets(planets, settings)

Parameters:

  • planets (Array<String>)

    the list of planets to check

  • settings (OpenStruct, nil) (defaults to: nil)

    optional settings for the search

Returns:

  • (Array<String>)

    the visible planets



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 495

def find_visible_planets(planets, settings = nil)
  unless get_telescope?(settings.telescope_name, settings.telescope_storage)
    Lich::Messaging.msg("bold", "DRCMM: Could not get telescope to find visible planets.")
    return
  end

  Flags.add('planet-not-visible', 'turns up fruitless')
  observed_planets = []

  begin
    planets.each do |planet|
      center_telescope(planet)
      observed_planets << planet unless Flags['planet-not-visible']
      Flags.reset('planet-not-visible')
    end
  ensure
    Flags.delete('planet-not-visible')
  end

  Lich::Messaging.msg("bold", "DRCMM: Could not store telescope after finding visible planets.") unless store_telescope?(settings.telescope_name, settings.telescope_storage)
  observed_planets
end

.get_bones(storage) ⇒ void

This method returns an undefined value.

Attempts to get bones and sends a message if it fails.

Examples:

Get bones

get_bones(storage)

Parameters:

  • storage (Hash)

    the storage information



285
286
287
288
289
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 285

def get_bones(storage)
  return if get_bones?(storage)

  Lich::Messaging.msg('bold', 'DRCMM: Failed to get bones.')
end

.get_bones?(storage) ⇒ Boolean

Retrieves bones from storage or hands.

Examples:

Get bones from storage

get_bones?(storage)

Parameters:

  • storage (Hash)

    the storage information

Returns:

  • (Boolean)

    true if the bones are successfully retrieved



255
256
257
258
259
260
261
262
263
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 255

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) ⇒ void

This method returns an undefined value.

Attempts to get a divination tool and sends a message if it fails.

Examples:

Get a divination tool

get_div_tool(tool)

Parameters:

  • tool (Hash)

    the tool information



354
355
356
357
358
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 354

def get_div_tool(tool)
  return if get_div_tool?(tool)

  Lich::Messaging.msg('bold', "DRCMM: Failed to get divination tool '#{tool['name']}'.")
end

.get_div_tool?(tool) ⇒ Boolean

Retrieves a divination tool from storage or hands.

Examples:

Get a divination tool

get_div_tool(tool)

Parameters:

  • tool (Hash)

    the tool information

Returns:

  • (Boolean)

    true if the tool is successfully retrieved



324
325
326
327
328
329
330
331
332
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 324

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) ⇒ void

This method returns an undefined value.

Attempts to get a telescope and sends a message if it fails.

Examples:

Get a telescope

get_telescope(storage)

Parameters:

  • storage (Hash)

    the storage information



193
194
195
196
197
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 193

def get_telescope(storage)
  return if get_telescope?('telescope', storage)

  Lich::Messaging.msg('bold', 'DRCMM: Failed to get telescope.')
end

.get_telescope?(telescope_name = 'telescope', storage) ⇒ Boolean

Retrieves a telescope from storage or hands.

Examples:

Get a telescope from storage

get_telescope?("telescope", storage)

Parameters:

  • telescope_name (String) (defaults to: 'telescope')

    the name of the telescope

  • storage (Hash)

    the storage information

Returns:

  • (Boolean)

    true if the telescope is successfully retrieved



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 154

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'])
      Lich::Messaging.msg("plain", "DRCMM: Telescope not found in container. Trying to get it from anywhere we can.")
      return DRCI.get_item?(telescope_name)
    end
    true
  else
    DRCI.get_item?(telescope_name)
  end
end

.hold_moon_weapon?Boolean

Attempts to hold a moon weapon if not already holding two.

Examples:

Hold a moon weapon

hold_moon_weapon?

Returns:

  • (Boolean)

    true if a moon weapon was held



433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 433

def hold_moon_weapon?
  return true if holding_moon_weapon?
  return false if [DRC.left_hand, DRC.right_hand].compact.length >= 2

  MOON_WEAPON_NAMES.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

Checks if a moon weapon is currently being held.

Examples:

Check if holding a moon weapon

holding_moon_weapon?

Returns:

  • (Boolean)

    true if a moon weapon is held



425
426
427
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 425

def holding_moon_weapon?
  is_moon_weapon?(DRC.left_hand) || is_moon_weapon?(DRC.right_hand)
end

.is_moon_weapon?(item) ⇒ Boolean

Checks if the specified item is a moon weapon.

Examples:

Check if an item is a moon weapon

is_moon_weapon("black moonblade")

Parameters:

  • item (String)

    the item to check

Returns:

  • (Boolean)

    true if the item is a moon weapon



452
453
454
455
456
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 452

def is_moon_weapon?(item)
  return false unless item

  MOON_WEAPON_REGEX.match?(item)
end

.moon_used_to_summon_weaponString?

Determines which moon was used to summon a weapon.

Examples:

Get the moon used to summon a weapon

moon_used_to_summon_weapon

Returns:

  • (String, nil)

    the name of the moon or nil if none



462
463
464
465
466
467
468
469
470
471
472
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 462

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.
  MOON_WEAPON_NAMES.each do |weapon|
    glance = DRC.bput("glance my #{weapon}", MOON_GLANCE_REGEX, "I could not find")
    match = glance&.match(MOON_GLANCE_REGEX)
    return MOON_COLOR_TO_NAME[match[:color]] if match
  end
  nil
end

.moon_visible?(moon_name) ⇒ Boolean

Checks if a specific moon is currently visible.

Examples:

Check if a specific moon is visible

moon_visible?("xibar")

Parameters:

  • moon_name (String)

    the name of the moon to check

Returns:

  • (Boolean)

    true if the moon is visible



591
592
593
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 591

def moon_visible?(moon_name)
  visible_moons.include?(moon_name)
end

.moons_visible?Boolean

Checks if any moons are currently visible.

Examples:

Check if moons are visible

moons_visible?

Returns:

  • (Boolean)

    true if moons are visible



582
583
584
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 582

def moons_visible?
  !visible_moons.empty?
end

.observe(thing) ⇒ void

This method returns an undefined value.

Observes a specified thing in the heavens.

Examples:

Observe a specific item

observe("moon")

Parameters:

  • thing (String)

    the item to observe



123
124
125
126
127
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 123

def observe(thing)
  output = "observe #{thing} in heavens"
  output = 'observe heavens' if thing.eql?('heavens')
  DRC.bput(output.to_s, *OBSERVE_MESSAGES)
end

.peer_telescopevoid

This method returns an undefined value.

Peers through the telescope to observe celestial bodies.

Examples:

Peer through the telescope

peer_telescope


214
215
216
217
218
219
220
221
222
223
224
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 214

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').observe_finished_messages),
    /open it/,
    /Your vision is too fuzzy/,
  )
  Lich::Util.issue_command("peer my telescope", telescope_regex_patterns, /Roundtime: /, usexml: false)
end

.predict(thing) ⇒ void

This method returns an undefined value.

Predicts the future regarding a specified thing.

Examples:

Predict the state of all

predict("all")

Parameters:

  • thing (String)

    the item to predict



134
135
136
137
138
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 134

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) ⇒ void

This method returns an undefined value.

Rolls the bones and manages the storage of bones afterward.

Examples:

Roll the bones

roll_bones(storage)

Parameters:

  • storage (Hash)

    the storage information



307
308
309
310
311
312
313
314
315
316
317
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 307

def roll_bones(storage)
  unless get_bones?(storage)
    Lich::Messaging.msg('bold', 'DRCMM: Failed to get bones, aborting roll_bones.')
    return
  end

  DRC.bput('roll my bones', 'roundtime')
  waitrt?

  Lich::Messaging.msg('bold', 'DRCMM: Failed to store bones after rolling.') unless store_bones?(storage)
end

.set_moon_data(data) ⇒ Hash?

Sets the moon data based on the provided information.

Examples:

Set moon data

set_moon_data(data)

Parameters:

  • data (Hash)

    the data to set

Returns:

  • (Hash, nil)

    the updated data or nil if no moon is available



545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 545

def set_moon_data(data)
  return data unless data['moon']

  moon = visible_moons.first
  if moon
    data['cast'] = "cast #{moon}"
  elsif data['name'].downcase == 'cage of light'
    data['cast'] = "cast ambient"
  else
    Lich::Messaging.msg("bold", "DRCMM: 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.

Examples:

Set planet data

set_planet_data(data, settings)

Parameters:

  • data (Hash)

    the data to set

  • settings (OpenStruct, nil) (defaults to: nil)

    optional settings for the update

Returns:

  • (Hash)

    the updated data



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 524

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
  Lich::Messaging.msg("bold", "DRCMM: Could not set planet data. Cannot cast #{data['abbrev']}.")
end

.store_bones(storage) ⇒ void

This method returns an undefined value.

Attempts to store bones and sends a message if it fails.

Examples:

Store bones

store_bones(storage)

Parameters:

  • storage (Hash)

    the storage information



296
297
298
299
300
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 296

def store_bones(storage)
  return if store_bones?(storage)

  Lich::Messaging.msg('bold', 'DRCMM: Failed to store bones.')
end

.store_bones?(storage) ⇒ Boolean

Stores bones back into storage or ties them.

Examples:

Store bones

store_bones?(storage)

Parameters:

  • storage (Hash)

    the storage information

Returns:

  • (Boolean)

    true if the bones are successfully stored



270
271
272
273
274
275
276
277
278
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 270

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) ⇒ void

This method returns an undefined value.

Attempts to store a divination tool and sends a message if it fails.

Examples:

Store a divination tool

store_div_tool(tool)

Parameters:

  • tool (Hash)

    the tool information



365
366
367
368
369
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 365

def store_div_tool(tool)
  return if store_div_tool?(tool)

  Lich::Messaging.msg('bold', "DRCMM: Failed to store divination tool '#{tool['name']}'.")
end

.store_div_tool?(tool) ⇒ Boolean

Stores a divination tool back into storage or wears it.

Examples:

Store a divination tool

store_div_tool(tool)

Parameters:

  • tool (Hash)

    the tool information

Returns:

  • (Boolean)

    true if the tool is successfully stored



339
340
341
342
343
344
345
346
347
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 339

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) ⇒ void

This method returns an undefined value.

Attempts to store a telescope and sends a message if it fails.

Examples:

Store a telescope

store_telescope(storage)

Parameters:

  • storage (Hash)

    the storage information



204
205
206
207
208
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 204

def store_telescope(storage)
  return if store_telescope?('telescope', storage)

  Lich::Messaging.msg('bold', 'DRCMM: Failed to store telescope.')
end

.store_telescope?(telescope_name = "telescope", storage) ⇒ Boolean

Stores a telescope back into storage or ties it.

Examples:

Store a telescope

store_telescope?("telescope", storage)

Parameters:

  • telescope_name (String) (defaults to: "telescope")

    the name of the telescope

  • storage (Hash)

    the storage information

Returns:

  • (Boolean)

    true if the telescope is successfully stored



176
177
178
179
180
181
182
183
184
185
186
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 176

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_skyvoid

This method returns an undefined value.

Studies the sky for celestial information.

Examples:

Study the sky

study_sky


144
145
146
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 144

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.

Examples:

Update astral data

update_astral_data(data, settings)

Parameters:

  • data (Hash)

    the data to update

  • settings (OpenStruct, nil) (defaults to: nil)

    optional settings for the update

Returns:

  • (Hash)

    the updated data



480
481
482
483
484
485
486
487
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 480

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) ⇒ void

This method returns an undefined value.

Uses a divination tool for its intended purpose.

Examples:

Use a divination tool

use_div_tool(tool_storage)

Parameters:

  • tool_storage (Hash)

    the storage information of the tool



376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 376

def use_div_tool(tool_storage)
  unless get_div_tool?(tool_storage)
    Lich::Messaging.msg('bold', "DRCMM: Failed to get divination tool '#{tool_storage['name']}', aborting use_div_tool.")
    return
  end

  DIV_TOOL_VERBS
    .select { |tool, _| tool_storage['name'].include?(tool) }
    .each   { |tool, verb| DRC.bput("#{verb} my #{tool}", 'roundtime'); waitrt? }

  unless store_div_tool?(tool_storage)
    Lich::Messaging.msg('bold', "DRCMM: Failed to store divination tool '#{tool_storage['name']}'.")
  end
end

.visible_moonsArray<String>

Retrieves a list of currently visible moons.

Examples:

Get visible moons

visible_moons

Returns:

  • (Array<String>)

    the names of visible moons



599
600
601
602
603
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 599

def visible_moons
  check_moonwatch
  UserVars.moons.select { |moon_name, moon_data| UserVars.moons['visible'].include?(moon_name) && moon_data['timer'] >= MOON_VISIBILITY_TIMER_THRESHOLD }
                .map { |moon_name, _moon_data| moon_name }
end

.wear_moon_weapon?Boolean

Attempts to wear a moon weapon if one is held.

Examples:

Wear a moon weapon

wear_moon_weapon?

Returns:

  • (Boolean)

    true if a moon weapon was worn



395
396
397
398
399
400
401
402
403
404
# File 'documented/dragonrealms/commons/common-moonmage.rb', line 395

def wear_moon_weapon?
  wore_it = false
  if is_moon_weapon?(DRC.left_hand)
    wore_it = wore_it || DRC.bput("wear #{DRC.left_hand}", *MOON_WEAR_MESSAGES) == "telekinetic"
  end
  if is_moon_weapon?(DRC.right_hand)
    wore_it = wore_it || DRC.bput("wear #{DRC.right_hand}", *MOON_WEAR_MESSAGES) == "telekinetic"
  end
  wore_it
end