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.
Constant Summary collapse
- CLERIC_ITEMS =
List of items used by clerics in the game.
[ 'holy water', 'holy oil', 'wine', 'incense', 'flint', 'chamomile', 'sage', 'jalbreth balm' ]
- COMMUNE_ERRORS =
List of error messages related to commune actions.
[ '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.
[ '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
-
.apply_jalbreth_balm(theurgy_supply_container, target) ⇒ nil
Applies jalbreth balm to a target.
-
.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.
-
.buy_single_supply(item_name, shop_data) ⇒ nil
Buys a single supply item from the shop.
-
.buying_cleric_item_requires_bless?(town, item_name) ⇒ Boolean?
Determines if buying a cleric item requires a blessing.
-
.commune_sense ⇒ Hash
Senses the current state of communes.
-
.empty_cleric_hands(theurgy_supply_container) ⇒ nil
Ensures the cleric’s hands are empty before performing actions.
-
.empty_cleric_left_hand(theurgy_supply_container) ⇒ nil
Empties the cleric’s left hand if it contains a cleric item.
-
.empty_cleric_right_hand(theurgy_supply_container) ⇒ nil
Empties the cleric’s right hand if it contains a cleric item.
-
.has_flint?(theurgy_supply_container) ⇒ Boolean
Checks if the specified container has flint.
-
.has_holy_oil?(theurgy_supply_container) ⇒ Boolean
Checks if the specified container has holy oil.
-
.has_holy_water?(theurgy_supply_container, water_holder) ⇒ Boolean
Checks if the specified container has holy water.
-
.has_incense?(theurgy_supply_container) ⇒ Boolean
Checks if the specified container has incense.
-
.has_jalbreth_balm?(theurgy_supply_container) ⇒ Boolean
Checks if the specified container has jalbreth balm.
-
.quick_bless_item(item_name) ⇒ nil
Casts a quick blessing on the specified item.
-
.sprinkle?(item, target) ⇒ Boolean
Performs the action of sprinkling an item on a target.
-
.sprinkle_holy_oil(theurgy_supply_container, target) ⇒ nil
Sprinkles holy oil on a target without checking for success.
-
.sprinkle_holy_oil?(theurgy_supply_container, target) ⇒ Boolean
Sprinkles holy oil on a target.
-
.sprinkle_holy_water(theurgy_supply_container, water_holder, target) ⇒ nil
Sprinkles holy water on a target without checking for success.
-
.sprinkle_holy_water?(theurgy_supply_container, water_holder, target) ⇒ Boolean
Sprinkles holy water on a target.
-
.wave_incense?(theurgy_supply_container, flint_lighter, target) ⇒ Boolean
Waves incense at a target after ensuring necessary items are available.
Class Method Details
.apply_jalbreth_balm(theurgy_supply_container, target) ⇒ nil
Applies jalbreth balm to a target.
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.
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.
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.
110 111 112 113 114 115 116 117 118 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 110 def (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_sense ⇒ Hash
Senses the current state of communes.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.("Can't get holy oil to sprinkle.") return false end unless sprinkle?("oil", target) empty_cleric_hands(theurgy_supply_container) DRC.("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.
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.
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.("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.("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.
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.("Can't find flint to light") return false end unless has_incense?(theurgy_supply_container) DRC.("Can't find incense to light") return false end unless DRCI.get_item?(flint_lighter) DRC.("Can't get #{flint_lighter} to light incense") return false end unless DRCI.get_item?('incense', theurgy_supply_container) DRC.("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.("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 |