Module: Lich::DragonRealms::DRCTH

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

Defined Under Namespace

Classes: CommuneSenseResult

Constant Summary collapse

CLERIC_ITEMS =

Items used by clerics for theurgy rituals Note: With frozen_string_literal: true, string literals are already frozen Items used by clerics for theurgy rituals.

Examples:

CLERIC_ITEMS #=> ["holy water", "holy oil", "wine", "incense", "flint", "chamomile", "sage", "jalbreth balm"]
[
  'holy water', 'holy oil', 'wine', 'incense', 'flint', 'chamomile', 'sage', 'jalbreth balm'
].freeze
COMMUNE_ERRORS =

Error messages when attempting commune rituals Error messages when attempting commune rituals.

Examples:

COMMUNE_ERRORS #=> ["As you commune you sense that the ground is already consecrated.", "You stop as you realize that you have attempted a commune", "completed this commune too recently"]
[
  'As you commune you sense that the ground is already consecrated.',
  'You stop as you realize that you have attempted a commune',
  'completed this commune too recently'
].freeze
DEVOTION_LEVELS =

Devotion level messages from commune sense, ordered from lowest to highest Devotion level messages from commune sense, ordered from lowest to highest.

Examples:

DEVOTION_LEVELS #=> ["You sense nothing special from your communing", "You feel unclean and unworthy", ...]
[
  'You sense nothing special from your communing',
  'You feel unclean and unworthy',
  'You close your eyes and start to concentrate',
  'You call out to your god, but there is no answer',
  'After a moment, you sense that your god is barely aware of you',
  'After a moment, you sense that your efforts have not gone unnoticed',
  'After a moment, you sense a distinct link between you and your god',
  'After a moment, you sense that your god is aware of your devotion',
  'After a moment, you sense that your god knows your name',
  'After a moment, you sense that your god is pleased with your devotion',
  'After a moment, you see a vision of your god, though the visage is cloudy',
  'After a moment, you sense a slight pressure on your shoulder',
  'After a moment, you see a silent vision of your god',
  'After a moment, you see a vision of your god who calls to you by name, "Come here, my child',
  'After a moment, you see a vision of your god who calls to you by name, "My child, though you may',
  'After a moment, you see a crystal-clear vision of your god who speaks slowly and deliberately',
  'After a moment, you feel a clear presence like a warm blanket covering you'
].freeze
COMMUNE_SENSE_START =

Start pattern for commune sense output. Matches the first line of output which varies depending on active commune state. Verified in-game 2026-02-07. Start pattern for commune sense output. Matches the first line of output.

Examples:

COMMUNE_SENSE_START #=> /benevolent eyes|miracle of Tamsine|auspices of Kertigen|influence is woven|not a vessel|will not be able|eager to better/
/benevolent eyes|miracle of Tamsine|auspices of Kertigen|influence is woven|not a vessel|will not be able|eager to better/.freeze

Class Method Summary collapse

Class Method Details

.apply_jalbreth_balm(theurgy_supply_container, target) ⇒ void

This method returns an undefined value.

Applies jalbreth balm to a target.

Parameters:

  • theurgy_supply_container (String)

    the container holding the balm.

  • target (String)

    the target to apply the balm to.



321
322
323
324
325
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 321

def apply_jalbreth_balm(theurgy_supply_container, target)
  DRCI.get_item?('jalbreth balm', theurgy_supply_container)
  DRC.bput("apply balm to #{target}", '.*')
  DRCI.put_away_item?('jalbreth balm', theurgy_supply_container) if DRCI.in_hands?('balm')
end

.buy_cleric_item?(town, item_name, stackable, num_to_buy, theurgy_supply_container) ⇒ Boolean

Attempts to buy a cleric item from a shop.

Parameters:

  • town (String)

    the town where the item is being bought.

  • item_name (String)

    the name of the item.

  • stackable (Boolean)

    indicates if the item is stackable.

  • num_to_buy (Integer)

    number of items to buy.

  • theurgy_supply_container (String)

    the container for the items.

Returns:

  • (Boolean)

    true if the purchase was successful, false otherwise.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 150

def buy_cleric_item?(town, item_name, stackable, num_to_buy, theurgy_supply_container)
  town_theurgy_data = get_data('theurgy')[town]
  if town_theurgy_data.nil?
    Lich::Messaging.msg("bold", "DRCTH: No theurgy data found for town '#{town}'.")
    return false
  end

  item_shop_data = town_theurgy_data["#{item_name}_shop"]
  if item_shop_data.nil?
    Lich::Messaging.msg("bold", "DRCTH: No shop data found for '#{item_name}' in '#{town}'.")
    return false
  end

  DRCT.walk_to(item_shop_data['id'])
  if stackable
    num_to_buy.times do
      buy_single_supply(item_name, item_shop_data)
      if DRCI.get_item?(item_name, theurgy_supply_container)
        DRC.bput("combine #{item_name} with #{item_name}", 'You combine', 'You can\'t combine', 'You must be holding')
      end
      # Put this back in the container each cycle so it doesn't interfere
      # with bless of next purchase.
      DRCI.put_away_item?(item_name, theurgy_supply_container)
    end
  else
    num_to_buy.times do
      buy_single_supply(item_name, item_shop_data)
      DRCI.put_away_item?(item_name, theurgy_supply_container)
    end
  end

  true
end

.buy_single_supply(item_name, shop_data) ⇒ void

This method returns an undefined value.

Buys a single supply item from the shop.

Parameters:

  • item_name (String)

    the name of the item to buy.

  • shop_data (Hash)

    the data of the shop where the item is being bought.



188
189
190
191
192
193
194
195
196
197
198
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 188

def buy_single_supply(item_name, shop_data)
  if shop_data['method']
    send(shop_data['method'])
  else
    DRCT.buy_item(shop_data['id'], item_name)
  end

  return unless shop_data['needs_bless'] && DRSpells.known_spells.include?('Bless')

  quick_bless_item(item_name)
end

.buying_cleric_item_requires_bless?(town, item_name) ⇒ Boolean?

Determines if buying a cleric item requires a blessing.

Parameters:

  • town (String)

    the town where the item is being bought.

  • item_name (String)

    the name of the item.

Returns:

  • (Boolean, nil)

    true if a blessing is needed, false if not, nil if town data is missing.



133
134
135
136
137
138
139
140
141
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 133

def buying_cleric_item_requires_bless?(town, item_name)
  town_theurgy_data = get_data('theurgy')[town]
  return if town_theurgy_data.nil?

  item_shop_data = town_theurgy_data["#{item_name}_shop"]
  return if item_shop_data.nil?

  item_shop_data['needs_bless']
end

.commune_senseCommuneSenseResult

Performs a commune sense operation to gather commune information.

Returns:



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

def commune_sense
  lines = Lich::Util.issue_command(
    'commune sense',
    COMMUNE_SENSE_START,
    /Roundtime/,
    usexml: false,
    quiet: true,
    include_end: false
  )
  return CommuneSenseResult.new if lines.nil?

  parse_commune_sense_lines(lines.map(&:strip).reject(&:empty?))
end

.empty_cleric_hands(theurgy_supply_container) ⇒ void

This method returns an undefined value.

Ensures the cleric's hands are empty before performing actions.

Parameters:

  • theurgy_supply_container (String)

    the container for the items.



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

def empty_cleric_hands(theurgy_supply_container)
  # Adding an explicit glance to ensure we know what's in hands, as
  # items can change
  # [combat-trainer]>snuff my incense
  # You snuff out the fragrant incense.
  # [combat-trainer]>put my fragrant incense in my portal
  # What were you referring to?
  # >glance
  # You glance down to see a steel light spear in your right hand and some burnt incense in your left hand.
  #
  # Which this explicit glance fixes.
  DRC.bput('glance', 'You glance')
  empty_cleric_right_hand(theurgy_supply_container)
  empty_cleric_left_hand(theurgy_supply_container)
end

.empty_cleric_left_hand(theurgy_supply_container) ⇒ void

This method returns an undefined value.

Empties the cleric's left hand if it contains a cleric item.

Parameters:

  • theurgy_supply_container (String)

    the container for the items.



243
244
245
246
247
248
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 243

def empty_cleric_left_hand(theurgy_supply_container)
  return if DRC.left_hand.nil?

  container = CLERIC_ITEMS.any? { |item| DRC.left_hand =~ /#{item}/i } ? theurgy_supply_container : nil
  DRCI.put_away_item?(DRC.left_hand, container)
end

.empty_cleric_right_hand(theurgy_supply_container) ⇒ void

This method returns an undefined value.

Empties the cleric's right hand if it contains a cleric item.

Parameters:

  • theurgy_supply_container (String)

    the container for the items.



233
234
235
236
237
238
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 233

def empty_cleric_right_hand(theurgy_supply_container)
  return if DRC.right_hand.nil?

  container = CLERIC_ITEMS.any? { |item| DRC.right_hand =~ /#{item}/i } ? theurgy_supply_container : nil
  DRCI.put_away_item?(DRC.right_hand, container)
end

.has_flint?(theurgy_supply_container) ⇒ Boolean

Checks if the specified container has flint.

Parameters:

  • theurgy_supply_container (String)

    the container to check.

Returns:

  • (Boolean)

    true if flint is present, false otherwise.



104
105
106
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 104

def has_flint?(theurgy_supply_container)
  DRCI.have_item_by_look?('flint', theurgy_supply_container)
end

.has_holy_oil?(theurgy_supply_container) ⇒ Boolean

Checks if the specified container has holy oil.

Parameters:

  • theurgy_supply_container (String)

    the container to check.

Returns:

  • (Boolean)

    true if holy oil is present, false otherwise.



111
112
113
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 111

def has_holy_oil?(theurgy_supply_container)
  DRCI.have_item_by_look?('holy oil', theurgy_supply_container)
end

.has_holy_water?(theurgy_supply_container, water_holder) ⇒ Boolean

Checks if the specified container has holy water.

Parameters:

  • theurgy_supply_container (String)

    the container to check.

  • water_holder (String)

    the item holding the water.

Returns:

  • (Boolean)

    true if holy water is present, false otherwise.



93
94
95
96
97
98
99
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 93

def has_holy_water?(theurgy_supply_container, water_holder)
  return false unless DRCI.get_item?(water_holder, theurgy_supply_container)

  has_water = DRCI.inside?('holy water', water_holder)
  DRCI.put_away_item?(water_holder, theurgy_supply_container)
  has_water
end

.has_incense?(theurgy_supply_container) ⇒ Boolean

Checks if the specified container has incense.

Parameters:

  • theurgy_supply_container (String)

    the container to check.

Returns:

  • (Boolean)

    true if incense is present, false otherwise.



118
119
120
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 118

def has_incense?(theurgy_supply_container)
  DRCI.have_item_by_look?('incense', theurgy_supply_container)
end

.has_jalbreth_balm?(theurgy_supply_container) ⇒ Boolean

Checks if the specified container has jalbreth balm.

Parameters:

  • theurgy_supply_container (String)

    the container to check.

Returns:

  • (Boolean)

    true if jalbreth balm is present, false otherwise.



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

def has_jalbreth_balm?(theurgy_supply_container)
  DRCI.have_item_by_look?('jalbreth balm', theurgy_supply_container)
end

.parse_commune_sense_lines(lines) ⇒ CommuneSenseResult

Parses the lines returned from a commune sense operation.

Parameters:

  • lines (Array<String>)

    the lines to parse.

Returns:



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 394

def parse_commune_sense_lines(lines)
  commune_ready = true
  active_communes = []
  recent_communes = []

  lines.each do |line|
    case line
    when /You will not be able to open another divine conduit yet/
      commune_ready = false
    when /Tamsine's benevolent eyes are upon you/, /The miracle of Tamsine has manifested about you/
      active_communes << 'Tamsine'
    when /You are under the auspices of Kertigen/
      active_communes << 'Kertigen'
    when /Meraud's influence is woven into the area/
      active_communes << 'Meraud'
    when /The waters of Eluned are still in your thoughts/
      recent_communes << 'Eluned'
    when /You have been recently enlightened by Tamsine/
      recent_communes << 'Tamsine'
    when /The sounds of Kertigen's forge still ring in your ears/
      recent_communes << 'Kertigen'
    when /You are still captivated by Truffenyi's favor/
      recent_communes << 'Truffenyi'
    end
  end

  CommuneSenseResult.new(
    active_communes: active_communes,
    recent_communes: recent_communes,
    commune_ready: commune_ready
  )
end

.quick_bless_item(item_name) ⇒ void

This method returns an undefined value.

Quickly blesses an item if required.

Parameters:

  • item_name (String)

    the name of the item to bless.



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

def quick_bless_item(item_name)
  # use dummy settings object since this isn't complex enough for camb, etc.
  DRCA.cast_spell(
    { 'abbrev' => 'bless', 'mana' => 1, 'prep_time' => 2, 'cast' => "cast my #{item_name}" },
    {}
  )
end

.sprinkle?(item, target) ⇒ Boolean

Performs the action of sprinkling an item on a target.

Parameters:

  • item (String)

    the item to sprinkle.

  • target (String)

    the target to sprinkle on.

Returns:

  • (Boolean)

    true if the action was successful, false otherwise.



312
313
314
315
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 312

def sprinkle?(item, target)
  result = DRC.bput("sprinkle #{item} on #{target}", 'You sprinkle', 'Sprinkle (what|that)', 'What were you referring to')
  result == 'You sprinkle'
end

.sprinkle_holy_oil(theurgy_supply_container, target) ⇒ Boolean

Sprinkles holy oil on a target without checks.

Parameters:

  • theurgy_supply_container (String)

    the container holding the oil.

  • target (String)

    the target to sprinkle on.

Returns:

  • (Boolean)

    true if successful, false otherwise.



302
303
304
305
306
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 302

def sprinkle_holy_oil(theurgy_supply_container, target)
  DRCI.get_item?('holy oil', theurgy_supply_container)
  sprinkle?('oil', target)
  DRCI.put_away_item?('holy oil', theurgy_supply_container) if DRCI.in_hands?('oil')
end

.sprinkle_holy_oil?(theurgy_supply_container, target) ⇒ Boolean

Sprinkles holy oil on a target.

Parameters:

  • theurgy_supply_container (String)

    the container holding the oil.

  • target (String)

    the target to sprinkle on.

Returns:

  • (Boolean)

    true if successful, false otherwise.



273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 273

def sprinkle_holy_oil?(theurgy_supply_container, target)
  unless DRCI.get_item?("holy oil", theurgy_supply_container)
    Lich::Messaging.msg("bold", "DRCTH: Can't get holy oil to sprinkle.")
    return false
  end
  unless sprinkle?("oil", target)
    empty_cleric_hands(theurgy_supply_container)
    Lich::Messaging.msg("bold", "DRCTH: Couldn't sprinkle holy oil.")
    return false
  end
  empty_cleric_hands(theurgy_supply_container)
  true
end

.sprinkle_holy_water(theurgy_supply_container, water_holder, target) ⇒ Boolean

Sprinkles holy water on a target without checks.

Parameters:

  • theurgy_supply_container (String)

    the container holding the water.

  • water_holder (String)

    the item holding the water.

  • target (String)

    the target to sprinkle on.

Returns:

  • (Boolean)

    true if successful, false otherwise.



292
293
294
295
296
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 292

def sprinkle_holy_water(theurgy_supply_container, water_holder, target)
  DRCI.get_item?(water_holder, theurgy_supply_container)
  sprinkle?(water_holder, target)
  DRCI.put_away_item?(water_holder, theurgy_supply_container)
end

.sprinkle_holy_water?(theurgy_supply_container, water_holder, target) ⇒ Boolean

Sprinkles holy water on a target.

Parameters:

  • theurgy_supply_container (String)

    the container holding the water.

  • water_holder (String)

    the item holding the water.

  • target (String)

    the target to sprinkle on.

Returns:

  • (Boolean)

    true if successful, false otherwise.



255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 255

def sprinkle_holy_water?(theurgy_supply_container, water_holder, target)
  unless DRCI.get_item?(water_holder, theurgy_supply_container)
    Lich::Messaging.msg("bold", "DRCTH: Can't get #{water_holder} to sprinkle.")
    return false
  end
  unless sprinkle?(water_holder, target)
    DRCI.put_away_item?(water_holder, theurgy_supply_container)
    Lich::Messaging.msg("bold", "DRCTH: Couldn't sprinkle holy water.")
    return false
  end
  DRCI.put_away_item?(water_holder, theurgy_supply_container)
  true
end

.wave_incense?(theurgy_supply_container, flint_lighter, target) ⇒ Boolean

Waves incense at a target after lighting it.

Parameters:

  • theurgy_supply_container (String)

    the container holding the incense.

  • flint_lighter (String)

    the item used to light the incense.

  • target (String)

    the target to wave the incense at.

Returns:

  • (Boolean)

    true if successful, false otherwise.



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
365
366
367
368
369
370
371
372
373
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 332

def wave_incense?(theurgy_supply_container, flint_lighter, target)
  empty_cleric_hands(theurgy_supply_container)

  unless has_flint?(theurgy_supply_container)
    Lich::Messaging.msg("bold", "DRCTH: Can't find flint to light")
    return false
  end

  unless has_incense?(theurgy_supply_container)
    Lich::Messaging.msg("bold", "DRCTH: Can't find incense to light")
    return false
  end

  unless DRCI.get_item?(flint_lighter)
    Lich::Messaging.msg("bold", "DRCTH: Can't get #{flint_lighter} to light incense")
    return false
  end

  unless DRCI.get_item?('incense', theurgy_supply_container)
    Lich::Messaging.msg("bold", "DRCTH: Can't get incense to light")
    empty_cleric_hands(theurgy_supply_container)
    return false
  end

  lighting_attempts = 0
  while DRC.bput('light my incense with my flint', 'nothing happens', 'bursts into flames', 'much too dark in here to do that', 'What were you referring to?') == 'nothing happens'
    waitrt?

    lighting_attempts += 1
    if lighting_attempts >= 5
      Lich::Messaging.msg("bold", "DRCTH: Can't light your incense for some reason. Tried 5 times, giving up.")
      empty_cleric_hands(theurgy_supply_container)
      return false
    end
  end
  DRC.bput("wave my incense at #{target}", 'You wave')
  DRC.bput('snuff my incense', 'You snuff out') if DRCI.in_hands?('incense')

  DRCI.put_away_item?(flint_lighter)
  empty_cleric_hands(theurgy_supply_container)
  true
end