Module: Lich::DragonRealms::DRCTH
- Defined in:
- documented/dragonrealms/commons/common-theurgy.rb
Overview
Theurgy helper methods for clerics performing rituals and commune sense.
Theurgy is the cleric holy magic system in DragonRealms. This module provides inventory management for ritual supplies (holy water, oil, incense, etc.), sprinkle/apply operations, and parsing of COMMUNE SENSE output to determine active/recent communes and readiness for the next commune.
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
[ 'holy water', 'holy oil', 'wine', 'incense', 'flint', 'chamomile', 'sage', 'jalbreth balm' ].freeze
- COMMUNE_ERRORS =
Error messages when attempting commune rituals
[ '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
[ '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.
/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
-
.apply_jalbreth_balm(theurgy_supply_container, target) ⇒ void
private
Applies jalbreth balm to a target and returns it to storage.
-
.buy_cleric_item?(town, item_name, stackable, num_to_buy, theurgy_supply_container) ⇒ Boolean
Purchases cleric ritual supplies and returns them to storage.
-
.buy_single_supply(item_name, shop_data) ⇒ void
private
Purchases a single cleric supply item and optionally blesses it.
-
.buying_cleric_item_requires_bless?(town, item_name) ⇒ Boolean?
Queries theurgy data to determine if an item must be blessed when purchased.
-
.commune_sense ⇒ Object
Issues 'commune sense' and parses the output to determine active/recent communes and whether the character is ready to commune again.
-
.empty_cleric_hands(theurgy_supply_container) ⇒ void
Puts away or drops all items held by the cleric.
-
.empty_cleric_left_hand(theurgy_supply_container) ⇒ void
private
Puts away the left hand item if it is a cleric ritual supply.
-
.empty_cleric_right_hand(theurgy_supply_container) ⇒ void
private
Puts away the right hand item if it is a cleric ritual supply.
-
.has_flint?(theurgy_supply_container) ⇒ Boolean
Checks for flint in the supply container.
-
.has_holy_oil?(theurgy_supply_container) ⇒ Boolean
Checks for holy oil in the supply container.
-
.has_holy_water?(theurgy_supply_container, water_holder) ⇒ Boolean
Checks for holy water in a container without leaving the container open.
-
.has_incense?(theurgy_supply_container) ⇒ Boolean
Checks for incense in the supply container.
-
.has_jalbreth_balm?(theurgy_supply_container) ⇒ Boolean
Checks for jalbreth balm in the supply container.
-
.parse_commune_sense_lines(lines) ⇒ Object
Pure parsing method for commune sense output lines.
-
.quick_bless_item(item_name) ⇒ void
private
Casts Bless on a held item using minimal mana and prep time.
-
.sprinkle?(item, target) ⇒ Boolean
private
Attempts to sprinkle an item on a target and reports success.
-
.sprinkle_holy_oil(theurgy_supply_container, target) ⇒ void
private
Sprinkles holy oil on a target without explicit error handling.
-
.sprinkle_holy_oil?(theurgy_supply_container, target) ⇒ Boolean
Sprinkles holy oil on a target, with error handling.
-
.sprinkle_holy_water(theurgy_supply_container, water_holder, target) ⇒ void
private
Sprinkles holy water on a target without explicit error handling.
-
.sprinkle_holy_water?(theurgy_supply_container, water_holder, target) ⇒ Boolean
Sprinkles holy water on a target from a water container, with error handling.
-
.wave_incense?(theurgy_supply_container, flint_lighter, target) ⇒ Boolean
Lights incense with flint and waves it at a target, with full error handling.
Class Method Details
.apply_jalbreth_balm(theurgy_supply_container, target) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Applies jalbreth balm to a target and returns it to storage.
Retrieves jalbreth balm from the supply container, applies it to the target, and returns it to storage if still held. Accepts any server response (.*) without checking success.
435 436 437 438 439 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 435 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
Purchases cleric ritual supplies and returns them to storage.
Walks to the shop location, buys the requested quantity of items, optionally combines stackable items, and stores them in the supply container. Each item is blessed after purchase if needed and the player knows the Bless spell. Prints a bold message and returns false if town or item data is missing.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 195 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 is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Purchases a single cleric supply item and optionally blesses it.
If shop_data contains a 'method' key, calls that method to perform purchase (allowing custom handling). Otherwise uses the standard DRCT.buy_item call. If the item requires blessing and the player knows Bless, casts it immediately.
239 240 241 242 243 244 245 246 247 248 249 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 239 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?
Queries theurgy data to determine if an item must be blessed when purchased.
Consults the game data (lich/theurgy.yaml) for the given town and item. Returns nil if town data or item shop data does not exist.
170 171 172 173 174 175 176 177 178 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 170 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? item_shop_data['needs_bless'] end |
.commune_sense ⇒ Object
Issues 'commune sense' and parses the output to determine active/recent communes and whether the character is ready to commune again. Returns a CommuneSenseResult (backward-compatible with hash access via []).
A reply that is not captured in full never gives a "ready" reading:
- no reply in time: prints a bold message and returns a result with captured false, commune_ready false and empty lists.
- a reply cut off before its Roundtime line: prints a bold message and returns the communes that did arrive, with captured false and commune_ready false.
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 508 def commune_sense lines, complete = DRC.capture_reply( 'commune sense', COMMUNE_SENSE_START, /Roundtime/, usexml: false ) if lines.empty? Lich::Messaging.msg("bold", "DRCTH: Failed to capture COMMUNE SENSE output (timeout).") return CommuneSenseResult.new(commune_ready: false, captured: false) end result = parse_commune_sense_lines(lines.map(&:strip).reject(&:empty?)) return result if complete Lich::Messaging.msg("bold", "DRCTH: COMMUNE SENSE output was cut off (timeout); the result is incomplete.") CommuneSenseResult.new( active_communes: result.active_communes, recent_communes: result.recent_communes, commune_ready: false, captured: false ) end |
.empty_cleric_hands(theurgy_supply_container) ⇒ void
This method returns an undefined value.
Puts away or drops all items held by the cleric.
Calls empty_cleric_right_hand and empty_cleric_left_hand to handle both hands. Issues an explicit glance command first to refresh hand state (because item snuffing and other operations can leave hands in unexpected states).
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 277 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 is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Puts away the left hand item if it is a cleric ritual supply.
Checks the left hand against CLERIC_ITEMS patterns. If matched, stores in theurgy_supply_container; otherwise drops it or uses default put-away. Does nothing if the left hand is empty.
318 319 320 321 322 323 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 318 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 is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Puts away the right hand item if it is a cleric ritual supply.
Checks the right hand against CLERIC_ITEMS patterns. If matched, stores in theurgy_supply_container; otherwise drops it or uses default put-away. Does nothing if the right hand is empty.
302 303 304 305 306 307 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 302 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 for flint in the supply container.
132 133 134 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 132 def has_flint?(theurgy_supply_container) DRCI.have_item_by_look?('flint', theurgy_supply_container) end |
.has_holy_oil?(theurgy_supply_container) ⇒ Boolean
Checks for holy oil in the supply container.
140 141 142 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 140 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 for holy water in a container without leaving the container open.
Retrieves the water_holder (e.g., a waterskin) from theurgy_supply_container, verifies it contains holy water, then puts it back. This is safer than a simple inventory check.
120 121 122 123 124 125 126 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 120 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 for incense in the supply container.
148 149 150 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 148 def has_incense?(theurgy_supply_container) DRCI.have_item_by_look?('incense', theurgy_supply_container) end |
.has_jalbreth_balm?(theurgy_supply_container) ⇒ Boolean
Checks for jalbreth balm in the supply container.
156 157 158 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 156 def has_jalbreth_balm?(theurgy_supply_container) DRCI.have_item_by_look?('jalbreth balm', theurgy_supply_container) end |
.parse_commune_sense_lines(lines) ⇒ Object
Pure parsing method for commune sense output lines. Takes an array of plain text strings and returns a CommuneSenseResult.
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 534 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 is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Casts Bless on a held item using minimal mana and prep time.
Constructs a dummy settings object and invokes DRCA.cast_spell with fixed parameters suitable for quick blessing during supply purchase.
259 260 261 262 263 264 265 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 259 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
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Attempts to sprinkle an item on a target and reports success.
Issues the sprinkle command and returns true only if the output contains "You sprinkle"; returns false for any other response (invalid target, etc.).
420 421 422 423 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 420 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) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Sprinkles holy oil on a target without explicit error handling.
Retrieves holy oil, executes the sprinkle, and returns it to storage only if still held. No return value or error messages; suitable for scripted sequences where preconditions are already verified.
405 406 407 408 409 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 405 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, with error handling.
Retrieves holy oil from storage, attempts the sprinkle action, and empties both cleric hands afterward. Prints a bold message and returns false if retrieval or the sprinkle action fails.
362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 362 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) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Sprinkles holy water on a target without explicit error handling.
Retrieves the water_holder, executes the sprinkle, and returns it to storage. No return value or error messages; suitable for scripted sequences where preconditions are already verified.
388 389 390 391 392 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 388 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 from a water container, with error handling.
Retrieves the water_holder from storage, attempts the sprinkle action, and returns it to storage. Prints a bold message and returns false if retrieval fails or the sprinkle action does not succeed.
337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 337 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
Lights incense with flint and waves it at a target, with full error handling.
Clears both hands first, verifies presence of flint and incense in storage, retrieves the flint lighter, gets incense, attempts to light (retrying up to 5 times on "nothing happens"), waves at target, snuffs if still held, and returns both items to storage. Prints bold messages and returns false at each failure point.
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 455 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 |