Module: Lich::DragonRealms::DRCTH

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

Overview

The DRCTH module This module provides methods related to the cleric theurgy in DragonRealms.

Examples:

Using DRCTH methods

DRCTH.has_holy_water?(container, holder)

Constant Summary collapse

CLERIC_ITEMS =

List of items used by clerics in the game.

Returns:

  • (Array<String>)

    An array of cleric item names.

[
  'holy water', 'holy oil', 'wine', 'incense', 'flint', 'chamomile', 'sage', 'jalbreth balm'
]
COMMUNE_ERRORS =

List of error messages related to commune actions.

Returns:

  • (Array<String>)

    An array of commune error messages.

[
  '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'
]
DEVOTION_LEVELS =

List of devotion levels messages for clerics.

Returns:

  • (Array<String>)

    An array of devotion level messages.

[
  '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'
]

Class Method Summary collapse

Class Method Details

.apply_jalbreth_balm(theurgy_supply_container, target) ⇒ nil

Applies jalbreth balm to a target.

Examples:

Applying jalbreth balm

apply_jalbreth_balm(supply_container, "target")

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

  • target (String)

    The target to apply the balm to.

Returns:

  • (nil)

    Returns nil after applying the balm.



316
317
318
319
320
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 316

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 town’s shop.

Examples:

Buying a cleric item

buy_cleric_item?("town_name", "item_name", true, 5, supply_container)

Parameters:

  • town (String)

    The name of the town.

  • item_name (String)

    The name of the item to buy.

  • stackable (Boolean)

    Indicates if the item is stackable.

  • num_to_buy (Integer)

    The number of items to buy.

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (Boolean)

    Returns true if the purchase was successful, false otherwise.



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
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 129

def buy_cleric_item?(town, item_name, stackable, num_to_buy, theurgy_supply_container)
  town_theurgy_data = get_data('theurgy')[town]
  return false if town_theurgy_data.nil?

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

  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

  return true
end

.buy_single_supply(item_name, shop_data) ⇒ nil

Buys a single supply item from the shop.

Examples:

Buying a single supply

buy_single_supply("item_name", shop_data)

Parameters:

  • item_name (String)

    The name of the item to buy.

  • shop_data (Hash)

    The data related to the shop.

Returns:

  • (nil)

    Returns nil after attempting to buy the item.



163
164
165
166
167
168
169
170
171
172
173
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 163

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'] && @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.

Examples:

Checking if a blessing is required

buying_cleric_item_requires_bless?("town_name", "item_name")

Parameters:

  • town (String)

    The name of the town.

  • item_name (String)

    The name of the item to check.

Returns:

  • (Boolean, nil)

    Returns true if a blessing is needed, false if not, or nil if data is unavailable.



110
111
112
113
114
115
116
117
118
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 110

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?

  return item_shop_data['needs_bless']
end

.commune_senseHash

Senses the current state of communes.

Examples:

Sensing commune state

state = commune_sense

Returns:

  • (Hash)

    Returns a hash containing active and recent communes, and readiness status.



376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 376

def commune_sense
  DRC.bput('commune sense', 'Roundtime:')
  pause 0.5

  commune_ready = true
  active_communes = []
  recent_communes = []

  theurgy_lines = reget(50).map(&:strip)
  theurgy_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

  return {
    'active_communes' => active_communes,
    'recent_communes' => recent_communes,
    'commune_ready'   => commune_ready
  }
end

.empty_cleric_hands(theurgy_supply_container) ⇒ nil

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

Examples:

Emptying cleric hands

empty_cleric_hands(supply_container)

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (nil)

    Returns nil after ensuring hands are empty.



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 193

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

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

Examples:

Emptying left hand

empty_cleric_left_hand(supply_container)

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (nil)

    Returns nil after attempting to empty the left hand.



226
227
228
229
230
231
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 226

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

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

Examples:

Emptying right hand

empty_cleric_right_hand(supply_container)

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (nil)

    Returns nil after attempting to empty the right hand.



214
215
216
217
218
219
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 214

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.

Examples:

Checking for flint

has_flint?(supply_container)

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (Boolean)

    Returns true if flint is present, false otherwise.



73
74
75
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 73

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.

Examples:

Checking for holy oil

has_holy_oil?(supply_container)

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (Boolean)

    Returns true if holy oil is present, false otherwise.



82
83
84
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 82

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.

Examples:

Checking for holy water

has_holy_water?(supply_container, "my water holder")

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

  • water_holder (String)

    The item holder for holy water.

Returns:

  • (Boolean)

    Returns true if holy water is present, false otherwise.



60
61
62
63
64
65
66
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 60

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)
  return has_water
end

.has_incense?(theurgy_supply_container) ⇒ Boolean

Checks if the specified container has incense.

Examples:

Checking for incense

has_incense?(supply_container)

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (Boolean)

    Returns true if incense is present, false otherwise.



91
92
93
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 91

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.

Examples:

Checking for jalbreth balm

has_jalbreth_balm?(supply_container)

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

Returns:

  • (Boolean)

    Returns true if jalbreth balm is present, false otherwise.



100
101
102
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 100

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

.quick_bless_item(item_name) ⇒ nil

Casts a quick blessing on the specified item.

Examples:

Quick blessing an item

quick_bless_item("item_name")

Parameters:

  • item_name (String)

    The name of the item to bless.

Returns:

  • (nil)

    Returns nil after attempting to bless the item.



180
181
182
183
184
185
186
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 180

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.

Examples:

Sprinkling an item

sprinkle?("holy water", "target")

Parameters:

  • item (String)

    The item to sprinkle.

  • target (String)

    The target to sprinkle on.

Returns:

  • (Boolean)

    Returns true if the action was successful, false otherwise.



305
306
307
308
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 305

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

Sprinkles holy oil on a target without checking for success.

Examples:

Sprinkling holy oil directly

sprinkle_holy_oil(supply_container, "target")

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

  • target (String)

    The target to sprinkle holy oil on.

Returns:

  • (nil)

    Returns nil after attempting to sprinkle holy oil.



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

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.

Examples:

Sprinkling holy oil

sprinkle_holy_oil?(supply_container, "target")

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

  • target (String)

    The target to sprinkle holy oil on.

Returns:

  • (Boolean)

    Returns true if successful, false otherwise.



260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 260

def sprinkle_holy_oil?(theurgy_supply_container, target)
  unless DRCI.get_item?("holy oil", theurgy_supply_container)
    DRC.message("Can't get holy oil to sprinkle.")
    return false
  end
  unless sprinkle?("oil", target)
    empty_cleric_hands(theurgy_supply_container)
    DRC.message("Couldn't sprinkle holy oil.")
    return false
  end
  empty_cleric_hands(theurgy_supply_container)
  return true
end

.sprinkle_holy_water(theurgy_supply_container, water_holder, target) ⇒ nil

Sprinkles holy water on a target without checking for success.

Examples:

Sprinkling holy water directly

sprinkle_holy_water(supply_container, "my water holder", "target")

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

  • water_holder (String)

    The item holder for holy water.

  • target (String)

    The target to sprinkle holy water on.

Returns:

  • (nil)

    Returns nil after attempting to sprinkle holy water.



281
282
283
284
285
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 281

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.

Examples:

Sprinkling holy water

sprinkle_holy_water?(supply_container, "my water holder", "target")

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

  • water_holder (String)

    The item holder for holy water.

  • target (String)

    The target to sprinkle holy water on.

Returns:

  • (Boolean)

    Returns true if successful, false otherwise.



240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 240

def sprinkle_holy_water?(theurgy_supply_container, water_holder, target)
  unless DRCI.get_item?(water_holder, theurgy_supply_container)
    DRC.message("Can't get #{water_holder} to sprinkle.")
    return false
  end
  unless sprinkle?(water_holder, target)
    DRCI.put_away_item?(water_holder, theurgy_supply_container)
    DRC.message("Couldn't sprinkle holy water.")
    return false
  end
  DRCI.put_away_item?(water_holder, theurgy_supply_container)
  return true
end

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

Waves incense at a target after ensuring necessary items are available.

Examples:

Waving incense

wave_incense?(supply_container, "my flint", "target")

Parameters:

  • theurgy_supply_container (Object)

    The container holding the theurgy supplies.

  • flint_lighter (String)

    The item used to light the incense.

  • target (String)

    The target to wave incense at.

Returns:

  • (Boolean)

    Returns true if successful, false otherwise.



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

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

  unless has_flint?(theurgy_supply_container)
    DRC.message("Can't find flint to light")
    return false
  end

  unless has_incense?(theurgy_supply_container)
    DRC.message("Can't find incense to light")
    return false
  end

  unless DRCI.get_item?(flint_lighter)
    DRC.message("Can't get #{flint_lighter} to light incense")
    return false
  end

  unless DRCI.get_item?('incense', theurgy_supply_container)
    DRC.message("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)
      DRC.message("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)
  return true
end