Module: Lich::DragonRealms::DRCI
- Defined in:
- documented/dragonrealms/commons/common-items.rb
Constant Summary collapse
- TRASH_STORAGE =
How to add new trash receptacles github.com/elanthia-online/dr-scripts/wiki/Adding-new-trash-receptacles List of trash receptacles available in the game.
%w[arms barrel basin basket bin birdbath bucket chamberpot gloop hole log puddle statue stump tangle tree turtle urn gelapod]
- DROP_TRASH_SUCCESS_PATTERNS =
Patterns for successful trash drop messages.
[ /^You drop/, /^You put/, /^You spread .* on the ground/, /smashing it to bits/, # The next message is when item crumbles when leaves your hand, like a moonblade. /^As you open your hand to release the/, /^You toss .* at the domesticated gelapod/, /^You feed .* a bit warily to the domesticated gelapod/ ]
- DROP_TRASH_FAILURE_PATTERNS =
Patterns for failed trash drop messages.
[ /^What were you referring to/, /^I could not find/, /^But you aren't holding that/, /^Perhaps you should be holding that first/, /^You're kidding, right/, /^You can't do that/, /No littering/, # A guard steps over to you and says, "No littering in the bank." /^Where do you want to put that/, /^You really shouldn't be loitering/, /^You don't seem to be able to move/, # You may get the next message if you've been cursed and unable to let go of items. # Find a Cleric to uncurse you. /^Oddly, when you attempt to stash it away safely/, /^You need something in your right hand/, /^You can't put that there/, /^The domesticated gelapod glances warily at/, # deeds /^You should empty it out, first./ # container with items ]
- DROP_TRASH_RETRY_PATTERNS =
Messages that when trying to drop an item you’re warned. To continue you must retry the command. Patterns for retry messages when dropping trash.
[ # You may get the next message if the item would be damaged upon dropping. /^If you still wish to drop it/, /would damage it/, # You may get the next messages when an outdated item is updated upon use. # "Something appears different about the <item>, perhaps try doing that again." # Example: https://elanthipedia.play.net/Item:Leather_lotion /^Something appears different about/, /perhaps try doing that again/ ]
- WORN_TRASHCAN_VERB_PATTERNS =
Patterns for actions performed on worn trashcans.
[ /^You drum your fingers/, /^You pull a lever/, /^You poke your finger around/ ]
- GET_ITEM_SUCCESS_PATTERNS =
Patterns for successful item retrieval messages.
[ /you draw (?!\w+'s wounds)/i, /^You get/, /^You pick/, /^You pluck/, /^You slip/, /^You scoop/, /^You deftly remove/, /^You are already holding/, /^You fade in for a moment as you/, /^You carefully lift/, /^You carefully remove .* from the bundle/, /^With a flick of your wrist, you stealthily unsheath/ ]
- GET_ITEM_FAILURE_PATTERNS =
Patterns for failed item retrieval messages.
[ /^A magical force keeps you from grasping/, /^You'll need both hands free/, /^You need both hands free/, /^You need a free hand/, /^You can't pick that up with your hand that damaged/, /^Your (left|right) hand is too injured/, /^You just can't/, /^You stop as you realize the .* is not yours/, /^You can't reach that from here/, # on a mount like a flying carpet /^You don't seem to be able to move/, /^You should untie/, /^You can't do that/, /^Get what/, /^I could not/, /^What were you/, /already in your inventory/, # wearing it /needs to be tended to be removed/, # ammo lodged in you /push you over the item limit/, # you're at item capacity /rapidly decays away/, # item disappears when try to get it /cracks and rots away/, # item disappears when try to get it /^You should stop practicing your Athletics skill before you do that/ ]
- WEAR_ITEM_SUCCESS_PATTERNS =
Patterns for successful item wear messages.
[ /^You put/, /^You pull/, /^You sling/, /^You attach/, /^You strap/, /^You slide/, /^You spin/, /^You slip/, /^You place/, /^You hang/, /^You tug/, /^You struggle/, /^You squeeze/, /^You manage/, /^You gently place/, /^You toss one strap/, /^You carefully loop/, /^You work your way into/, /^You are already wearing/, /^Gritting your teeth, you grip/, /^You expertly sling the/, /put it on/, # weird clerical collar thing, trying to make it a bit generic /slide effortlessly onto your/, /^You carefully arrange/, /^A brisk chill rushes through you as you wear/, # some hiro bearskin gloves interlaced with strips of ice-veined leather /^You drape/, /You lean over and slip your feet into the boots./, # a pair of weathered barkcloth boots lined in flannel, /^You reach down and step into/, # pair of enaada boots clasped by asharsh'dai /Gritting your teeth/ # Gritting your teeth, you grip each of your heavy combat boots in turn by the straps, and drive your feet into them for a secure fit. ]
- WEAR_ITEM_FAILURE_PATTERNS =
Patterns for failed item wear messages.
[ /^You can't wear/, /^You (need to|should) unload/, /close the fan/, /^You don't seem to be able to move/, /^Wear what/, /^I could not/, /^What were you/ ]
- TIE_ITEM_SUCCESS_PATTERNS =
Patterns for successful item tie messages.
[ /^You .* tie/, /^You attach/ ]
- TIE_ITEM_FAILURE_PATTERNS =
Patterns for failed item tie messages.
[ /^You don't seem to be able to move/, /^There's no more free ties/, /^You must be holding/, /doesn't seem to fit/, /close the fan/, /^You are a little too busy/, /^Your wounds hinder your ability to do that/, /^Tie what/ ]
- UNTIE_ITEM_SUCCESS_PATTERNS =
Patterns for successful item untie messages.
[ /^You remove/, /You untie/i ]
- UNTIE_ITEM_FAILURE_PATTERNS =
Patterns for failed item untie messages.
[ /^You don't seem to be able to move/, /^You fumble with the ties/, /^Untie what/, /^What were you referring/ ]
- REMOVE_ITEM_SUCCESS_PATTERNS =
Patterns for successful item removal messages.
[ /^Dropping your shoulder/, /^The .* slide/, /^Without any effort/, /^You .* slide/, /^You detach/, /^You loosen/, /^You pull/, /^You.*remove/, /^You slide/, /^You sling/, /^You slip/, /^You struggle/, /^You take/, /you tug/i, /^You untie/, /as you remove/, /slide themselves off of your/, /you manage to loosen/, /you unlace/, /^You slam the heels/, /^With masterful grace, you ready/ ]
- REMOVE_ITEM_FAILURE_PATTERNS =
Patterns for failed item removal messages.
[ /^You'll need both hands free/, /^You need a free hand/, /^You aren't wearing/, /^You don't seem to be able to move/, /^Remove what/, /^I could not/, /^Grunting with momentary exertion/, # Grunting with momentary exertion, you grip each of your heavy combat boots in turn by the heel, and pull them off. /^What were you/ ]
- PUT_AWAY_ITEM_SUCCESS_PATTERNS =
Patterns for successful item stow messages.
[ /^You put your .* in/, /^You hold out/, /^You stuff/, /^You tuck/, /^You open your pouch and put/, /^You guide your/i, # puppy storage /^You hang/, # frog belt /^You nudge your/i, # monkey storage # The next message is when item crumbles when stowed, like a moonblade. /^As you open your hand to release the/, # You're a thief and you binned a stolen item. /nods toward you as your .* falls into the .* bin/, /^You add/, /^You rearrange/, /^You combine the stacks/, /^You secure/, # The following are success messages for putting an item in a container OFF your person. /^You drop/i, /^You set/i, /You put/i, /^You carefully fit .* into your bundle/, /^You slip/, /^You easily strap/, /^You gently set/, /^With a flick of your wrist, you stealthily sheath/, /^You strap your .* to your harness/, /^You toss .* into/ # You toss the alcohol into the bowl and mix it in thoroughly ]
- PUT_AWAY_ITEM_FAILURE_PATTERNS =
Patterns for failed item stow messages.
[ /^Stow what/, /^I can't find your container for stowing things in/, /^Please rephrase that command/, /^What were you referring to/, /^I could not find what you were referring to/, /^There isn't any more room in/, /^There's no room/, /^(The|That).* too heavy to go in there/, /^You (need to|should) unload/, /^You can't do that/, /^You just can't get/, /^You can't put items/, /^You can only take items out/, /^You don't seem to be able to move/, /^Perhaps you should be holding that first/, /^Containers can't be placed in/, /^The .* is not designed to carry anything/, /^You can't put that.*there/, /^Weirdly, you can't manage .* to fit/, /^\[Containers can't be placed in/, /even after stuffing it/, /is too .* to (fit|hold)/, /no matter how you arrange it/, /close the fan/, /to fit in the/, /doesn't seem to want to leave you/, # trying to put a pet in a home within a container # You may get the next message if you've been cursed and unable to let go of items. # Find a Cleric to uncurse you. /Oddly, when you attempt to stash it away safely/, /completely full/, /That doesn't belong in there!/, /exerts a steady force preventing/ ]
- PUT_AWAY_ITEM_RETRY_PATTERNS =
Messages that when trying to put away an item you’re warned. To continue you must retry the command. Patterns for retry messages when putting away items.
[ # You may get the next messages when an outdated item is updated upon use. # "Something appears different about the <item>, perhaps try doing that again." # Example: https://elanthipedia.play.net/Item:Leather_lotion /Something appears different about/, /perhaps try doing that again/ ]
- STOW_ITEM_SUCCESS_PATTERNS =
Combined patterns for successful stow actions.
[ *GET_ITEM_SUCCESS_PATTERNS, *PUT_AWAY_ITEM_SUCCESS_PATTERNS ]
- STOW_ITEM_FAILURE_PATTERNS =
Combined patterns for failed stow actions.
[ *GET_ITEM_FAILURE_PATTERNS, *PUT_AWAY_ITEM_FAILURE_PATTERNS, ]
- STOW_ITEM_RETRY_PATTERNS =
Combined patterns for retry actions when stowing items.
[ *PUT_AWAY_ITEM_RETRY_PATTERNS ]
- RUMMAGE_SUCCESS_PATTERNS =
Patterns for successful rummage messages.
[ /^You rummage through .* and see (.*)\./, /^In the .* you see (.*)\./, /there is nothing/i ]
- RUMMAGE_FAILURE_PATTERNS =
Patterns for failed rummage messages.
[ /^You don't seem to be able to move/, /^I could not find/, /^I don't know what you are referring to/, /^What were you referring to/ ]
- TAP_SUCCESS_PATTERNS =
Patterns for successful tap messages.
[ /^You tap\s(?!into).*/, # The `.*` is needed to capture entire phrase. Methods parse it to know if an item is worn, stowed, etc. /^You (thump|drum) your finger/, # You tapped an item with fancy verbiage, ohh la la! /^As you tap/, # As you tap a large ice-veined leather and flamewood surveyor's case /^The orb is delicate/, # You tapped a favor orb /^You .* on the shoulder/, # You tapped someone /^You suddenly forget what you were doing/ # "tap my tessera" messaging when hands are full ]
- TAP_FAILURE_PATTERNS =
Patterns for failed tap messages.
[ /^You don't seem to be able to move/, /^I could not find/, /^I don't know what you are referring to/, /^What were you referring to/ ]
- OPEN_CONTAINER_SUCCESS_PATTERNS =
Patterns for successful open container messages.
[ /^You open/, /^You slowly open/, /^The .* opens/, /^You unbutton/, /(It's|is) already open/, /^You spread your arms, carefully holding your bag well away from your body/ ]
- OPEN_CONTAINER_FAILURE_PATTERNS =
Patterns for failed open container messages.
[ /^Please rephrase that command/, /^What were you referring to/, /^I could not find what you were referring to/, /^You don't want to ruin your spell just for that do you/, /^It would be a shame to disturb the silence of this place for that/, /^This is probably not the time nor place for that/, /^You don't seem to be able to move/, /^There is no way to do that/, /^You can't do that/, /^Open what/ ]
- CLOSE_CONTAINER_SUCCESS_PATTERNS =
Patterns for successful close container messages.
[ /^You close/, /^You quickly close/, /^You pull/, /is already closed/ ]
- CLOSE_CONTAINER_FAILURE_PATTERNS =
Patterns for failed close container messages.
[ /^Please rephrase that command/, /^What were you referring to/, /^I could not find what you were referring to/, /^You don't want to ruin your spell just for that do you/, /^It would be a shame to disturb the silence of this place for that/, /^This is probably not the time nor place for that/, /^You don't seem to be able to move/, /^There is no way to do that/, /^You can't do that/ ]
- CONTAINER_IS_CLOSED_PATTERNS =
Patterns indicating that a container is closed.
[ /^But that's closed/, /^That is closed/, /^While it's closed/ ]
- LOWER_SUCCESS_PATTERNS =
Patterns for successful lower item messages.
[ /^You lower/, # The next message is when item crumbles when leaves your hand, like a moonblade. /^As you open your hand to release the/ ]
- LOWER_FAILURE_PATTERNS =
Patterns for failed lower item messages.
[ /^You don't seem to be able to move/, /^But you aren't holding anything/, /^Please rephrase that command/, /^What were you referring to/, /^I could not find what you were referring to/ ]
- LIFT_SUCCESS_PATTERNS =
Patterns for successful lift item messages.
[ /^You pick up/ ]
- LIFT_FAILURE_PATTERNS =
Patterns for failed lift item messages.
[ /^There are no items lying at your feet/, /^What did you want to try and lift/, /can't quite lift it/, /^You are not strong enough to pick that up/ ]
- GIVE_ITEM_SUCCESS_PATTERNS =
Patterns for successful give item messages.
[ /has accepted your offer/, /your ticket and are handed back/, /Please don't lose this ticket!/, /^You hand .* gives you back a repair ticket/, /^You hand .* your ticket and are handed back/ ]
- GIVE_ITEM_FAILURE_PATTERNS =
Patterns for failed give item messages.
[ /I don't repair those here/, /There isn't a scratch on that/, /give me a few more moments/, /I will not repair something that isn't broken/, /I can't fix those/, /has declined the offer/, /^Your offer to .* has expired/, /^You may only have one outstanding offer at a time/, /^What is it you're trying to give/, /Lucky for you! That isn't damaged!/ ]
Class Method Summary collapse
-
.accept_item? ⇒ String, false
If you accept then returns the name of the person whose offer you accepted.
-
.close_container?(container) ⇒ Boolean
Closes a specified container.
-
.container_is_empty?(container) ⇒ Boolean?
Checks if the container is empty.
-
.count_all_boxes(settings) ⇒ Integer
Counts all boxes from various sources.
-
.count_item_parts(item) ⇒ Integer
Counts the parts of a stackable item.
-
.count_items(item) ⇒ Integer
Counts items in a container that is inferred by first tapping the item.
-
.count_items_in_container(item, container) ⇒ Integer
Counts items in a container.
-
.count_lockpick_container(container) ⇒ Integer
Identifies how many more lockpicks that the container can hold.
-
.count_necro_stacker(necro_stacker) ⇒ Integer
Takes in the noun of the configured necro material stacker, and returns the current material item count.
-
.dispose_trash(item, worn_trashcan = nil, worn_trashcan_verb = nil) ⇒ Boolean
Disposes of an item in a trash receptacle.
-
.exists?(item, container = nil) ⇒ Boolean
Taps an item to confirm it exists.
-
.fill_gem_pouch_with_container(gem_pouch_adjective, gem_pouch_noun, source_container, full_pouch_container = nil, spare_gem_pouch_container = nil, should_tie_gem_pouches = false) ⇒ void
Fills a gem pouch with items from a specified container.
-
.get_box_list_in_container(container) ⇒ Array
Gets a list of boxes in a specified container.
-
.get_inventory_by_type(type = 'combat', line_count = 40) ⇒ Array
Returns a list of item descriptions from the ‘INVENTORY <type|slot>` verb output.
-
.get_item(item, container = nil) ⇒ Boolean
Gets an item, optionally from a specific container.
-
.get_item?(item, container = nil) ⇒ Boolean
Provide a predicate-named method to follow convention.
-
.get_item_from_eddy_portal?(item, container) ⇒ Boolean
Workaround to game changes where you must periodically look in the portal for the contents to be available.
-
.get_item_if_not_held?(item, container = nil) ⇒ Boolean
Gets an item unless you are already hold it.
-
.get_item_list(container, verb = 'rummage') ⇒ Array
Gets a list of items found in a container via RUMMAGE or LOOK.
-
.get_item_safe(item, container = nil) ⇒ Boolean
Gets an item safely with ‘my’ prefix from a specified container.
-
.get_item_safe?(item, container = nil) ⇒ Boolean
Same as ‘get_item_unsafe’ but ensures that the container argument is prefixed with ‘my’ qualifier.
-
.get_item_unsafe(item, container = nil) ⇒ Boolean
Gets an item, optionally from a specific container.
-
.get_scroll_list_in_container(container) ⇒ Array
Gets a list of scrolls in a specified container.
-
.give_item?(target, item = nil) ⇒ Boolean
Gives an item to a target.
-
.have_item_by_look?(item, container) ⇒ Boolean
Checks if an item is present by looking at it.
-
.in_hand?(item, which_hand = 'either') ⇒ Boolean
Checks if the item is in one or more hands.
-
.in_hands?(item) ⇒ Boolean
Checks if an item is in either hand.
-
.in_left_hand?(item) ⇒ Boolean
Checks if an item is in the left hand.
-
.in_right_hand?(item) ⇒ Boolean
Checks if an item is in the right hand.
-
.inside?(item, container = nil) ⇒ Boolean
Taps item to determine if it’s in the given container.
-
.lift?(item = nil, stow = nil) ⇒ Boolean
Implementing a suggestion by Gildaren for a simple predicate method You can pass this only an item and it will attempt to lift that item and return true/false You can pass this both an item and true and it will lift that item and return the result of stow_item? on that item You can pass this both an item and the name of a container and return the result of put_away_item? on that item and that container Lifts an item and optionally stows it.
-
.look_in_container(container) ⇒ Array?
Gets a list of items by LOOK in the container.
-
.lower_item?(item) ⇒ Boolean
Lowers the item to the ground.
-
.open_container?(container) ⇒ Boolean
Opens a specified container.
-
.put_away_item?(item, container = nil) ⇒ Boolean
Puts away an item, optionally into a specific container.
-
.put_away_item_safe?(item, container = nil) ⇒ Boolean
Same as ‘put_away_item_unsafe?’ but ensures that the container argument is prefixed with ‘my’ qualifier.
-
.put_away_item_unsafe?(item, container = nil, preposition = "in") ⇒ Boolean
Puts away an item, optionally into a specific container, optionally using a container preposition (e.g. “ON shelf”) If no container specified then uses the default stow location.
-
.remove_and_stow_pouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container = nil) ⇒ Boolean
Removes and stows a gem pouch.
-
.remove_item?(item) ⇒ Boolean
Removes an item you’re wearing.
-
.remove_item_safe?(item) ⇒ Boolean
Same as ‘remove_item_unsafe?’ but ensures that the item name is prefixed with ‘my’ qualifier.
-
.remove_item_unsafe?(item) ⇒ Boolean
Removes an item you’re wearing.
-
.rummage_container(container) ⇒ Array?
Gets a list of items by RUMMAGE the container.
-
.search?(item) ⇒ Boolean
Searches for an item in the inventory.
-
.stow_hand(hand) ⇒ Boolean
Stows an item from a specified hand.
-
.stow_hands ⇒ Boolean
Stows items in both hands if possible.
-
.stow_item?(item) ⇒ Boolean
Stows an item into its default container.
-
.stow_item_safe?(item) ⇒ Boolean
Stows an item into its default container.
-
.stow_item_unsafe?(item) ⇒ Boolean
Stows an item into its default container.
-
.swap_out_full_gempouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container = nil, spare_gem_pouch_container = nil, should_tie_gem_pouches = false) ⇒ Boolean
GEM POUCH HANDLING ROUTINES.
-
.tap(item, container = nil) ⇒ String?
Taps an item and returns the match string.
-
.tie_gem_pouch(gem_pouch_adjective, gem_pouch_noun) ⇒ Boolean
Ties a gem pouch.
-
.tie_item?(item, container = nil) ⇒ Boolean
Ties an item to a specified container.
-
.untie_item?(item, container = nil) ⇒ Boolean
Unties an item from a specified container.
-
.wear_item?(item) ⇒ Boolean
Wears an item from your hands.
-
.wear_item_safe?(item) ⇒ Boolean
Same as ‘wear_item_unsafe?’ but ensures that the item name is prefixed with ‘my’ qualifier.
-
.wear_item_unsafe?(item) ⇒ Boolean
Wears an item from your hands.
-
.wearing?(item) ⇒ Boolean
Taps items to check if you’re wearing it.
Class Method Details
.accept_item? ⇒ String, false
If you accept then returns the name of the person whose offer you accepted. This serves as a “truthy” value, too. If you don’t, or aren’t able to, accept then returns false. Accepts an item offer from another player.
1455 1456 1457 1458 1459 1460 1461 1462 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1455 def accept_item? case DRC.bput("accept", "You accept .* offer and are now holding", "You have no offers", "Both of your hands are full", "would push you over your item limit") when /You accept (?<name>\w+)'s offer and are now holding/ Regexp.last_match[:name] else false end end |
.close_container?(container) ⇒ Boolean
Closes a specified container.
1406 1407 1408 1409 1410 1411 1412 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1406 def close_container?(container) case DRC.bput("close #{container}", CLOSE_CONTAINER_SUCCESS_PATTERNS, CLOSE_CONTAINER_FAILURE_PATTERNS) when *CLOSE_CONTAINER_SUCCESS_PATTERNS return true end return false end |
.container_is_empty?(container) ⇒ Boolean?
Checks if the container is empty. Returns true if certain the container is empty. Returns false if certain the container is not empty. Returns nil if unable to determine either way (e.g. can’t open container or look in it). Checks if a container is empty.
1205 1206 1207 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1205 def container_is_empty?(container) look_in_container(container).empty? end |
.count_all_boxes(settings) ⇒ Integer
Counts all boxes from various sources.
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
# File 'documented/dragonrealms/commons/common-items.rb', line 811 def count_all_boxes(settings) current_box_count = 0 [ settings.picking_box_source, settings.pick['picking_box_sources'], settings.pick['blacklist_container'], settings.pick['too_hard_container'] ].flatten.uniq.reject { |container| container.to_s.empty? }.each { |container| current_box_count += get_box_list_in_container(container).size } current_box_count end |
.count_item_parts(item) ⇒ Integer
Counts the parts of a stackable item.
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
# File 'documented/dragonrealms/commons/common-items.rb', line 699 def count_item_parts(item) = [ /and see there (?:is|are) (.+) left\./, /There (?:is|are) (?:only )?(.+) parts? left/, /There's (?:only )?(.+) parts? left/, /The (?:.+) has (.+) uses remaining./, /There are enough left to create (.+) more/, /You count out (.+) pieces? of material there/, /There (?:is|are) (.+) scrolls? left for use with crafting/ ] count = 0 $ORDINALS.each do |ordinal| case DRC.bput("count my #{ordinal} #{item}", 'I could not find what you were referring to.', 'tell you much of anything.', *) when 'I could not find what you were referring to.' break when 'tell you much of anything.' echo "ERROR: count_item_parts called on non-stackable item: #{item}" count = count_items(item) break when * countval = Regexp.last_match(1).tr('-', ' ') if countval.match?(/\A\d+\z/) count += Integer(countval) else count += DRC.text2num(countval) end end waitrt? end count end |
.count_items(item) ⇒ Integer
Counts items in a container that is inferred by first tapping the item. If you want to count items in a specific container, use ‘count_items_in_container(item, container)` Counts items in a container inferred from the item.
741 742 743 744 745 746 747 |
# File 'documented/dragonrealms/commons/common-items.rb', line 741 def count_items(item) /inside your (.*)/ =~ tap(item) container = Regexp.last_match(1) return 0 if container.nil? count_items_in_container(item, container) end |
.count_items_in_container(item, container) ⇒ Integer
Counts items in a container. If you don’t know which container the items are in, use ‘count_items(item)` to infer it. Counts items in a specified container.
757 758 759 760 761 762 |
# File 'documented/dragonrealms/commons/common-items.rb', line 757 def count_items_in_container(item, container) contents = DRC.bput("rummage /C #{item.split.last} in my #{container}", /^You rummage .*/, /That would accomplish nothing/) # This regexp avoids counting the quoted item name in the message, as # well as avoiding finding the item as a substring of other items. contents.scan(/ #{item}\W/).size end |
.count_lockpick_container(container) ⇒ Integer
Identifies how many more lockpicks that the container can hold. Designed to work on lockpick stackers. elanthipedia.play.net/Lockpick_rings Counts how many more lockpicks a container can hold.
772 773 774 775 776 |
# File 'documented/dragonrealms/commons/common-items.rb', line 772 def count_lockpick_container(container) count = DRC.bput("appraise my #{container} quick", /it appears to be full/, /it might hold an additional \d+/, /\d+ lockpicks would probably fit/).scan(/\d+/).first.to_i waitrt? count end |
.count_necro_stacker(necro_stacker) ⇒ Integer
Takes in the noun of the configured necro material stacker, and returns the current material item count. Counts the current material item count in a necromancer’s material stacker.
802 803 804 |
# File 'documented/dragonrealms/commons/common-items.rb', line 802 def count_necro_stacker(necro_stacker) DRC.bput("study my #{necro_stacker}", /currently holds \d+ items/).scan(/\d+/).first.to_i end |
.dispose_trash(item, worn_trashcan = nil, worn_trashcan_verb = nil) ⇒ Boolean
If the item is not held, it will not be disposed.
Disposes of an item in a trash receptacle.
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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'documented/dragonrealms/commons/common-items.rb', line 470 def dispose_trash(item, worn_trashcan = nil, worn_trashcan_verb = nil) return unless item return unless DRCI.get_item_if_not_held?(item) if worn_trashcan case DRC.bput("put my #{item} in my #{worn_trashcan}", DROP_TRASH_RETRY_PATTERNS, DROP_TRASH_SUCCESS_PATTERNS, DROP_TRASH_FAILURE_PATTERNS, /^Perhaps you should be holding that first/) when /^Perhaps you should be holding that first/ return (DRCI.get_item?(item) && DRCI.dispose_trash(item, worn_trashcan, worn_trashcan_verb)) when *DROP_TRASH_RETRY_PATTERNS return DRCI.dispose_trash(item, worn_trashcan, worn_trashcan_verb) when *DROP_TRASH_SUCCESS_PATTERNS if worn_trashcan_verb DRC.bput("#{worn_trashcan_verb} my #{worn_trashcan}", *WORN_TRASHCAN_VERB_PATTERNS) DRC.bput("#{worn_trashcan_verb} my #{worn_trashcan}", *WORN_TRASHCAN_VERB_PATTERNS) end return true end end trashcans = DRRoom.room_objs .reject { |obj| obj =~ /azure \w+ tree/ } .map { |long_name| DRC.get_noun(long_name) } .select { |obj| TRASH_STORAGE.include?(obj) } trashcans.each do |trashcan| if trashcan == 'gloop' trashcan = 'bucket' if DRRoom.room_objs.include?('bucket of viscous gloop') trashcan = 'cauldron' if DRRoom.room_objs.include?('small bubbling cauldron of viscous gloop') elsif trashcan == 'bucket' trashcan = 'sturdy bucket' if DRRoom.room_objs.include?('sturdy bucket') elsif trashcan == 'basket' trashcan = 'waste basket' if DRRoom.room_objs.include?('waste basket') elsif trashcan == 'bin' trashcan = 'waste bin' if DRRoom.room_objs.include?('waste bin') trashcan = 'small bin' if DRRoom.room_objs.include?('small bin concealed with some nearby brush') elsif trashcan == 'arms' trashcan = 'statue' elsif trashcan == 'birdbath' trashcan = 'alabaster birdbath' elsif trashcan == 'turtle' trashcan = 'stone turtle' elsif trashcan == 'tree' trashcan = 'hollow' if DRRoom.room_objs.include?('dead tree with a darkened hollow near its base') elsif trashcan == 'basin' trashcan = 'stone basin' if DRRoom.room_objs.include?('hollow stone basin') elsif trashcan == 'tangle' trashcan = 'dark gap' if DRRoom.room_objs.include?('tangle of thick roots forming a dark gap') elsif XMLData.room_title == '[[A Junk Yard]]' trashcan = 'bin' elsif trashcan == 'gelapod' trash_command = "feed my #{item} to gelapod" end trash_command = "put my #{item} in #{trashcan}" unless trashcan == 'gelapod' case DRC.bput(trash_command, DROP_TRASH_SUCCESS_PATTERNS, DROP_TRASH_FAILURE_PATTERNS, DROP_TRASH_RETRY_PATTERNS, /^Perhaps you should be holding that first/) when /^Perhaps you should be holding that first/ return (DRCI.get_item?(item) && DRCI.dispose_trash(item)) when *DROP_TRASH_RETRY_PATTERNS # If still didn't dispose of trash after retry # then don't return yet, will try to drop it later. return true if dispose_trash(item) when *DROP_TRASH_SUCCESS_PATTERNS return true end end # No trash bins or not able to put item in a bin, just drop it. case DRC.bput("drop my #{item}", DROP_TRASH_SUCCESS_PATTERNS, DROP_TRASH_FAILURE_PATTERNS, DROP_TRASH_RETRY_PATTERNS, /^Perhaps you should be holding that first/, /^But you aren't holding that/) when /^Perhaps you should be holding that first/, /^But you aren't holding that/ return (DRCI.get_item?(item) && DRCI.dispose_trash(item)) when *DROP_TRASH_RETRY_PATTERNS return dispose_trash(item) when *DROP_TRASH_SUCCESS_PATTERNS return true else return false end end |
.exists?(item, container = nil) ⇒ Boolean
Taps an item to confirm it exists. Checks if an item exists in the inventory or container.
591 592 593 594 595 596 597 598 |
# File 'documented/dragonrealms/commons/common-items.rb', line 591 def exists?(item, container = nil) case tap(item, container) when *TAP_SUCCESS_PATTERNS true else false end end |
.fill_gem_pouch_with_container(gem_pouch_adjective, gem_pouch_noun, source_container, full_pouch_container = nil, spare_gem_pouch_container = nil, should_tie_gem_pouches = false) ⇒ void
This method returns an undefined value.
Fills a gem pouch with items from a specified container.
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1543 def fill_gem_pouch_with_container(gem_pouch_adjective, gem_pouch_noun, source_container, full_pouch_container = nil, spare_gem_pouch_container = nil, should_tie_gem_pouches = false) Flags.add("pouch-full", /is too full to fit any more/) case DRC.bput("fill my #{gem_pouch_adjective} #{gem_pouch_noun} with my #{source_container}", /^You open/, /is too full to fit/, /^You'd better tie it up before putting/, /You'll need to tie it up before/, /Please rephrase that command/, 'What were you referring to', "There aren't any gems", 'You fill your') when /Please rephrase that command/ DRC.("Container #{source_container} not found. Skipping fill") return when /^You'd better tie it up before putting/, /You'll need to tie it up before/ # This is equivalent to a full pouch, unless we should tie pouches, in which case we tie and retry unless should_tie_gem_pouches unless swap_out_full_gempouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container, spare_gem_pouch_container, should_tie_gem_pouches) DRC.("Could not swap gem pouches.") return end fill_gem_pouch_with_container(gem_pouch_adjective, gem_pouch_noun, source_container, full_pouch_container, spare_gem_pouch_container, should_tie_gem_pouches) end tie_gem_pouch(gem_pouch_adjective, gem_pouch_noun) if should_tie_gem_pouches fill_gem_pouch_with_container(gem_pouch_adjective, gem_pouch_noun, source_container, full_pouch_container, spare_gem_pouch_container, should_tie_gem_pouches) end if Flags["pouch-full"] unless swap_out_full_gempouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container, spare_gem_pouch_container, should_tie_gem_pouches) DRC.("Could not swap gem pouches.") return end fill_gem_pouch_with_container(gem_pouch_adjective, gem_pouch_noun, source_container, full_pouch_container, spare_gem_pouch_container, should_tie_gem_pouches) tie_gem_pouch(gem_pouch_adjective, gem_pouch_noun) if should_tie_gem_pouches Flags.reset("pouch-full") end end |
.get_box_list_in_container(container) ⇒ Array
Gets a list of boxes in a specified container.
783 784 785 |
# File 'documented/dragonrealms/commons/common-items.rb', line 783 def get_box_list_in_container(container) DRC.rummage('B', container) end |
.get_inventory_by_type(type = 'combat', line_count = 40) ⇒ Array
Returns a list of item descriptions from the ‘INVENTORY <type|slot>` verb output. Where <type> can be armor, weapon, fluff, container, or combat. Where <slot> can be any phrase from INV SLOTS LIST command. Returns a list of item descriptions from the inventory by type.
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1218 def get_inventory_by_type(type = 'combat', line_count = 40) case DRC.bput("inventory #{type}", /Use INVENTORY HELP for more options/, /The INVENTORY command is the best way/, /You can't do that/) when /The INVENTORY command is the best way/, /You can't do that/ DRC.("Unrecognized inventory type: #{type}. Valid options are ARMOR, WEAPON, FLUFF, CONTAINER, COMBAT, or any slot from INVENTORY SLOTS LIST.") return [] end # Multiple lines may have been printed to the game window, # grab the last several lines for analysis. snapshot = reget(line_count) # Unless you're looking for items at your feet, this is noise. items_at_feet = snapshot.grep(/(^Lying at your feet)/).any? # If the snapshot found all the inventory then begin processing. if snapshot.grep(/^All of your (#{type}|items)|^You aren't wearing anything like that|Both of your hands are empty/).any? && snapshot.grep(/Use INVENTORY HELP/).any? snapshot .map(&:strip) .reverse .take_while { |line| [/^All of your (#{type}|items)/, /^You aren't wearing anything like that/, /Both of your hands are empty/].none? { |phrase| phrase =~ line } } .drop_while { |line| !line.start_with?('[Use INVENTORY HELP for more options.]') } .drop(1) .reverse .take_while { |line| !items_at_feet || !line.start_with?('Lying at your feet') } .map { |item| item.gsub(/^(a|an|some)\s+/, '').gsub(/\s+\(closed\)/, '') } else # Otherwise, retry the command. Other actions may have flooded the game window. get_inventory_by_type(type, line_count + 40) end end |
.get_item(item, container = nil) ⇒ Boolean
Gets an item, optionally from a specific container. If no container specified then generically grabs from the room/your person. Can provide an array of containers to try, too, in case some might be empty. Gets an item from a specified container.
903 904 905 906 907 908 909 910 911 |
# File 'documented/dragonrealms/commons/common-items.rb', line 903 def get_item(item, container = nil) if container.is_a?(Array) container.each do |c| return true if get_item_safe(item, c) end return false end get_item_safe(item, container) end |
.get_item?(item, container = nil) ⇒ Boolean
Provide a predicate-named method to follow convention. Provides a predicate-named method to get an item.
890 891 892 |
# File 'documented/dragonrealms/commons/common-items.rb', line 890 def get_item?(item, container = nil) get_item(item, container) end |
.get_item_from_eddy_portal?(item, container) ⇒ Boolean
Workaround to game changes where you must periodically look in the portal for the contents to be available. forums.play.net/forums/DragonRealms/Discussions%20with%20DragonRealms%20Staff%20and%20Players/Game%20Master%20and%20Official%20Announcements/view/1899 Gets an item from an eddy portal, ensuring the portal is open.
963 964 965 966 967 968 969 970 971 972 973 974 975 |
# File 'documented/dragonrealms/commons/common-items.rb', line 963 def get_item_from_eddy_portal?(item, container) # Ensure the eddy is open then look in it to force the contents to be loaded. return false unless DRCI.open_container?('my eddy') && DRCI.look_in_container('portal in my eddy') from = container from = "from #{container}" if container && !(container =~ /^(in|on|under|behind|from) /i) case DRC.bput("get #{item} #{from}", GET_ITEM_SUCCESS_PATTERNS, GET_ITEM_FAILURE_PATTERNS) when *GET_ITEM_SUCCESS_PATTERNS return true else return false end end |
.get_item_if_not_held?(item, container = nil) ⇒ Boolean
Gets an item unless you are already hold it. Use this method to avoid having two of an item in your hands when you only want one.
Returns true if the item is in your hand or we were able to get it to your hand. Gets an item unless it is already held.
876 877 878 879 880 881 |
# File 'documented/dragonrealms/commons/common-items.rb', line 876 def get_item_if_not_held?(item, container = nil) return false unless item return true if in_hands?(item) return get_item(item, container) end |
.get_item_list(container, verb = 'rummage') ⇒ Array
Gets a list of items found in a container via RUMMAGE or LOOK. Default is ‘rummage’ which returns the full item tap descriptions (e.g. some grey ice skates with black laces) You can pass in ‘LOOK’ to get back the short item names, which is easier to parse to know the adjective and noun (e.g. some grey ice skates) Gets a list of items found in a container via RUMMAGE or LOOK.
1255 1256 1257 1258 1259 1260 1261 1262 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1255 def get_item_list(container, verb = 'rummage') case verb when /^(r|rummage)$/i rummage_container(container) when /^(l|look)$/i look_in_container(container) end end |
.get_item_safe(item, container = nil) ⇒ Boolean
Gets an item safely with ‘my’ prefix from a specified container.
927 928 929 |
# File 'documented/dragonrealms/commons/common-items.rb', line 927 def get_item_safe(item, container = nil) get_item_safe?(item, container) end |
.get_item_safe?(item, container = nil) ⇒ Boolean
Same as ‘get_item_unsafe’ but ensures that the container argument is prefixed with ‘my’ qualifier.
915 916 917 918 919 |
# File 'documented/dragonrealms/commons/common-items.rb', line 915 def get_item_safe?(item, container = nil) item = "my #{item}" if item && !(item =~ /^my /i) container = "my #{container}" if container && !(container =~ /^((in|on|under|behind|from) )?my /i) get_item_unsafe(item, container) end |
.get_item_unsafe(item, container = nil) ⇒ Boolean
Gets an item, optionally from a specific container. If no container specified then generically grabs from the room/your person. Gets an item without safety checks from a specified container.
939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
# File 'documented/dragonrealms/commons/common-items.rb', line 939 def get_item_unsafe(item, container = nil) from = container from = "from #{container}" if container && !(container =~ /^(in|on|under|behind|from) /i) case DRC.bput("get #{item} #{from}", GET_ITEM_SUCCESS_PATTERNS, GET_ITEM_FAILURE_PATTERNS) when *GET_ITEM_SUCCESS_PATTERNS return true else if container =~ /\bportal\b/i return get_item_from_eddy_portal?(item, container) else return false end end end |
.get_scroll_list_in_container(container) ⇒ Array
Gets a list of scrolls in a specified container.
792 793 794 |
# File 'documented/dragonrealms/commons/common-items.rb', line 792 def get_scroll_list_in_container(container) DRC.rummage('SC', container) end |
.give_item?(target, item = nil) ⇒ Boolean
Gives an item to a target.
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1424 def give_item?(target, item = nil) command = item ? "give my #{item} to #{target}" : "give #{target}" case DRC.bput(command, { 'timeout' => 35 }, /GIVE it again/, /give it to me again/, /^You don't need to specify the object/, /already has an outstanding offer/, GIVE_ITEM_SUCCESS_PATTERNS, GIVE_ITEM_FAILURE_PATTERNS) when *GIVE_ITEM_SUCCESS_PATTERNS true when *GIVE_ITEM_FAILURE_PATTERNS false when /give it to me again/ give_item?(target, item) when /already has an outstanding offer/ pause 5 give_item?(target, item) when /GIVE it again/ waitrt give_item?(target, item) when /You don't need to specify the object/ if DRC.right_hand.include?(item) give_item?(target) elsif DRC.left_hand.include?(item) fput("swap") give_item?(target) end end end |
.have_item_by_look?(item, container) ⇒ Boolean
Checks if an item is present by looking at it.
676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'documented/dragonrealms/commons/common-items.rb', line 676 def have_item_by_look?(item, container) return false unless item item = item.delete_prefix('my ') preposition = 'in my' if container && !(container =~ /^((in|on|under|behind|from) )?my /i) case DRC.bput("look at my #{item} #{preposition} #{container}", item, /^You see nothing unusual/, /^I could not find/, /^What were you referring to/) when /You see nothing unusual/, item true else false end end |
.in_hand?(item, which_hand = 'either') ⇒ Boolean
Checks if the item is in one or more hands. Hand options are: left, right, either, both. Checks if an item is in one or both hands.
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'documented/dragonrealms/commons/common-items.rb', line 651 def in_hand?(item, which_hand = 'either') return false unless item item = DRC::Item.from_text(item) if item.is_a?(String) case which_hand.downcase when 'left' DRC.left_hand =~ item.short_regex when 'right' DRC.right_hand =~ item.short_regex when 'either' in_left_hand?(item) || in_right_hand?(item) when 'both' in_left_hand?(item) && in_right_hand?(item) else DRC.("Unknown hand: #{which_hand}. Valid options are: left, right, either, both") false end end |
.in_hands?(item) ⇒ Boolean
Checks if an item is in either hand.
621 622 623 |
# File 'documented/dragonrealms/commons/common-items.rb', line 621 def in_hands?(item) in_hand?(item, 'either') end |
.in_left_hand?(item) ⇒ Boolean
Checks if an item is in the left hand.
630 631 632 |
# File 'documented/dragonrealms/commons/common-items.rb', line 630 def in_left_hand?(item) in_hand?(item, 'left') end |
.in_right_hand?(item) ⇒ Boolean
Checks if an item is in the right hand.
639 640 641 |
# File 'documented/dragonrealms/commons/common-items.rb', line 639 def in_right_hand?(item) in_hand?(item, 'right') end |
.inside?(item, container = nil) ⇒ Boolean
Taps item to determine if it’s in the given container. Checks if an item is inside a specified container.
580 581 582 |
# File 'documented/dragonrealms/commons/common-items.rb', line 580 def inside?(item, container = nil) tap(item, container) =~ /inside/ end |
.lift?(item = nil, stow = nil) ⇒ Boolean
Implementing a suggestion by Gildaren for a simple predicate method You can pass this only an item and it will attempt to lift that item and return true/false You can pass this both an item and true and it will lift that item and return the result of stow_item? on that item You can pass this both an item and the name of a container and return the result of put_away_item? on that item and that container Lifts an item and optionally stows it.
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1176 def lift?(item = nil, stow = nil) item = item.split.last # Necessary until adjectives are implemented for lift case DRC.bput("lift #{item}", LIFT_SUCCESS_PATTERNS, LIFT_FAILURE_PATTERNS) when *LIFT_SUCCESS_PATTERNS if stow.is_a?(String) put_away_item?(item, stow) elsif stow stow_item?(item) else true end else false end end |
.look_in_container(container) ⇒ Array?
Gets a list of items by LOOK in the container. Returns a list (empty or otherwise) if able to look in the container. Returns nil if unable to determine if container’s contents (e.g. can’t open it or look in it). Gets a list of items by looking in the container.
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1298 def look_in_container(container) container = "my #{container}" unless container.nil? || container =~ /^my /i contents = DRC.bput("look in #{container}", CONTAINER_IS_CLOSED_PATTERNS, RUMMAGE_SUCCESS_PATTERNS, RUMMAGE_FAILURE_PATTERNS) case contents when *RUMMAGE_FAILURE_PATTERNS return nil when *CONTAINER_IS_CLOSED_PATTERNS return nil unless open_container?(container) look_in_container(container) else contents .match(/In the .* you see (?:some|an|a) (?<items>.*)\./)[:items] .split(/(?:,|and) (?:some|an|a)/) .map(&:strip) end end |
.lower_item?(item) ⇒ Boolean
Lowers the item to the ground. Determines which hand is holding the item then lowers it to your feet slot. Lowers an item to the ground from your hands.
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1153 def lower_item?(item) return false unless in_hands?(item) item_regex = /\b#{item}\b/ hand = (DRC.left_hand =~ item_regex) ? 'left' : 'right' case DRC.bput("lower ground #{hand}", *LOWER_SUCCESS_PATTERNS, *LOWER_FAILURE_PATTERNS) when *LOWER_SUCCESS_PATTERNS true else false end end |
.open_container?(container) ⇒ Boolean
Opens a specified container.
1393 1394 1395 1396 1397 1398 1399 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1393 def open_container?(container) case DRC.bput("open #{container}", OPEN_CONTAINER_SUCCESS_PATTERNS, OPEN_CONTAINER_FAILURE_PATTERNS) when *OPEN_CONTAINER_SUCCESS_PATTERNS return true end return false end |
.put_away_item?(item, container = nil) ⇒ Boolean
Puts away an item, optionally into a specific container. If no container specified then uses the default stow location. Can provide an array of containers to try, too, in case some might be full. Puts away an item into a specified container.
1329 1330 1331 1332 1333 1334 1335 1336 1337 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1329 def put_away_item?(item, container = nil) if container.is_a?(Array) container.each do |c| return true if put_away_item_safe?(item, c) end return false end put_away_item_safe?(item, container) end |
.put_away_item_safe?(item, container = nil) ⇒ Boolean
Same as ‘put_away_item_unsafe?’ but ensures that the container argument is prefixed with ‘my’ qualifier. Safely puts away an item with ‘my’ prefix.
1347 1348 1349 1350 1351 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1347 def put_away_item_safe?(item, container = nil) item = "my #{item}" if item && !(item =~ /^my /i) container = "my #{container}" unless container.nil? || container =~ /^my /i put_away_item_unsafe?(item, container) end |
.put_away_item_unsafe?(item, container = nil, preposition = "in") ⇒ Boolean
Puts away an item, optionally into a specific container, optionally using a container preposition (e.g. “ON shelf”) If no container specified then uses the default stow location. If no preposition specified, defaults to “in” (e.g. “IN cabinet”) Puts away an item without safety checks.
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1364 def put_away_item_unsafe?(item, container = nil, preposition = "in") command = "put #{item} #{preposition} #{container}" if container command = "stow #{item}" unless container result = DRC.bput(command, CONTAINER_IS_CLOSED_PATTERNS, PUT_AWAY_ITEM_SUCCESS_PATTERNS, PUT_AWAY_ITEM_FAILURE_PATTERNS, PUT_AWAY_ITEM_RETRY_PATTERNS) case result when *CONTAINER_IS_CLOSED_PATTERNS return false unless container && open_container?(container) return put_away_item_unsafe?(item, container) when *PUT_AWAY_ITEM_RETRY_PATTERNS return put_away_item_unsafe?(item, container) when *PUT_AWAY_ITEM_SUCCESS_PATTERNS return true when *PUT_AWAY_ITEM_FAILURE_PATTERNS return false else return false end end |
.remove_and_stow_pouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container = nil) ⇒ Boolean
Removes and stows a gem pouch.
1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1509 def remove_and_stow_pouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container = nil) unless remove_item?("#{gem_pouch_adjective} #{gem_pouch_noun}") DRC.("Unable to remove existing pouch.") return false end if put_away_item?("#{gem_pouch_adjective} #{gem_pouch_noun}", full_pouch_container) return true elsif stow_item?("#{gem_pouch_adjective} #{gem_pouch_noun}") return true else return false end end |
.remove_item?(item) ⇒ Boolean
Removes an item you’re wearing. Removes an item you’re wearing.
1064 1065 1066 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1064 def remove_item?(item) remove_item_safe?(item) end |
.remove_item_safe?(item) ⇒ Boolean
Same as ‘remove_item_unsafe?’ but ensures that the item name is prefixed with ‘my’ qualifier. Safely removes an item with ‘my’ prefix.
1075 1076 1077 1078 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1075 def remove_item_safe?(item) item = "my #{item}" if item && !(item =~ /^my /i) remove_item_unsafe?(item) end |
.remove_item_unsafe?(item) ⇒ Boolean
Removes an item you’re wearing. Removes an item without safety checks.
1086 1087 1088 1089 1090 1091 1092 1093 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1086 def remove_item_unsafe?(item) case DRC.bput("remove #{item}", REMOVE_ITEM_SUCCESS_PATTERNS, REMOVE_ITEM_FAILURE_PATTERNS) when *REMOVE_ITEM_SUCCESS_PATTERNS return true else return false end end |
.rummage_container(container) ⇒ Array?
Gets a list of items by RUMMAGE the container. Returns a list (empty or otherwise) if able to rummage the container. Returns nil if unable to determine if container’s contents (e.g. can’t open it or rummage it). Gets a list of items by rummaging the container.
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1272 def rummage_container(container) container = "my #{container}" unless container.nil? || container =~ /^my /i contents = DRC.bput("rummage #{container}", CONTAINER_IS_CLOSED_PATTERNS, RUMMAGE_SUCCESS_PATTERNS, RUMMAGE_FAILURE_PATTERNS) case contents when *RUMMAGE_FAILURE_PATTERNS return nil when *CONTAINER_IS_CLOSED_PATTERNS return nil unless open_container?(container) rummage_container(container) else contents .match(/You rummage through .* and see (?:a|an|some) (?<items>.*)\./)[:items] # Get string of just the comma separated item list .sub(/ and (?=a|an|some)/, ", ") # replace " and " for the last item into " , " .split(/, (?:a|an|some) /) # Split at a, an, or some, but only when it follows a comma end end |
.search?(item) ⇒ Boolean
Searches for an item in the inventory.
559 560 561 |
# File 'documented/dragonrealms/commons/common-items.rb', line 559 def search?(item) /(?:An?|Some) .+ is (?:in|being)/ =~ DRC.bput("inv search #{item}", /^You can't seem to find anything/, /(?:An?|Some) .+ is (?:in|being)/) end |
.stow_hand(hand) ⇒ Boolean
Stows an item from a specified hand.
846 847 848 849 850 851 852 853 854 855 856 857 858 |
# File 'documented/dragonrealms/commons/common-items.rb', line 846 def stow_hand(hand) braid_regex = /The braided (.+) is too long/ case DRC.bput("stow #{hand}", braid_regex, CONTAINER_IS_CLOSED_PATTERNS, STOW_ITEM_SUCCESS_PATTERNS, STOW_ITEM_FAILURE_PATTERNS, STOW_ITEM_RETRY_PATTERNS) when braid_regex dispose_trash(DRC.get_noun(Regexp.last_match(1))) when *STOW_ITEM_RETRY_PATTERNS stow_hand(hand) when *STOW_ITEM_SUCCESS_PATTERNS true else false end end |
.stow_hands ⇒ Boolean
Stows items in both hands if possible.
836 837 838 839 |
# File 'documented/dragonrealms/commons/common-items.rb', line 836 def stow_hands (!DRC.left_hand || stow_hand('left')) && (!DRC.right_hand || stow_hand('right')) end |
.stow_item?(item) ⇒ Boolean
Stows an item into its default container. See STORE HELP for details. Same as ‘stow_item_safe?’. Stows an item into its default container.
1106 1107 1108 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1106 def stow_item?(item) stow_item_safe?(item) end |
.stow_item_safe?(item) ⇒ Boolean
Stows an item into its default container. See STORE HELP for details. Same as ‘stow_item_unsafe?’ but ensures that the item argument is prefixed with ‘my ’. Safely stows an item with ‘my’ prefix.
1118 1119 1120 1121 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1118 def stow_item_safe?(item) item = "my #{item}" if item && !(item =~ /^my /i) stow_item_unsafe?(item) end |
.stow_item_unsafe?(item) ⇒ Boolean
Stows an item into its default container. See STORE HELP for details. Unless you include the ‘my ’ prefix in the item then this may try to stow an item on the ground rather than something in your inventory. Stows an item without safety checks.
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1131 def stow_item_unsafe?(item) case DRC.bput("stow #{item}", CONTAINER_IS_CLOSED_PATTERNS, STOW_ITEM_SUCCESS_PATTERNS, STOW_ITEM_FAILURE_PATTERNS, STOW_ITEM_RETRY_PATTERNS) when *STOW_ITEM_RETRY_PATTERNS return stow_item_unsafe?(item) when *STOW_ITEM_SUCCESS_PATTERNS return true else return false end end |
.swap_out_full_gempouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container = nil, spare_gem_pouch_container = nil, should_tie_gem_pouches = false) ⇒ Boolean
GEM POUCH HANDLING ROUTINES
Swaps out a full gem pouch for a spare.
1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1476 def swap_out_full_gempouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container = nil, spare_gem_pouch_container = nil, should_tie_gem_pouches = false) unless DRC.left_hand.nil? || DRC.right_hand.nil? DRC.("No free hand. Not swapping pouches now.") return false end unless remove_and_stow_pouch?(gem_pouch_adjective, gem_pouch_noun, full_pouch_container) DRC.("Remove and stow pouch routine failed.") return false end unless get_item?("#{gem_pouch_adjective} #{gem_pouch_noun}", spare_gem_pouch_container) DRC.("No spare pouch found.") return false end unless wear_item?("#{gem_pouch_adjective} #{gem_pouch_noun}") DRC.("Could not wear new pouch.") return false end tie_gem_pouch(gem_pouch_adjective, gem_pouch_noun) if should_tie_gem_pouches return true end |
.tap(item, container = nil) ⇒ String?
Taps an item and returns the match string. If no container specified then generically taps whatever’s in your immediate inventory. Taps an item to check its status.
608 609 610 611 612 613 614 |
# File 'documented/dragonrealms/commons/common-items.rb', line 608 def tap(item, container = nil) return nil unless item from = container from = "from #{container}" if container && !(container =~ /^(in|on|under|behind|from) /i) DRC.bput("tap my #{item} #{from}", *TAP_SUCCESS_PATTERNS, *TAP_FAILURE_PATTERNS) end |
.tie_gem_pouch(gem_pouch_adjective, gem_pouch_noun) ⇒ Boolean
Ties a gem pouch.
1529 1530 1531 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1529 def tie_gem_pouch(gem_pouch_adjective, gem_pouch_noun) DRC.bput("tie my #{gem_pouch_adjective} #{gem_pouch_noun}", 'you tie', "it's empty?", 'has already been tied off') end |
.tie_item?(item, container = nil) ⇒ Boolean
Ties an item to a specified container.
987 988 989 990 991 992 993 994 995 |
# File 'documented/dragonrealms/commons/common-items.rb', line 987 def tie_item?(item, container = nil) place = container ? "to my #{container}" : nil case DRC.bput("tie my #{item} #{place}", TIE_ITEM_SUCCESS_PATTERNS, TIE_ITEM_FAILURE_PATTERNS) when *TIE_ITEM_SUCCESS_PATTERNS true else false end end |
.untie_item?(item, container = nil) ⇒ Boolean
Unties an item from a specified container.
1003 1004 1005 1006 1007 1008 1009 1010 1011 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1003 def untie_item?(item, container = nil) place = container ? "from my #{container}" : nil case DRC.bput("untie my #{item} #{place}", UNTIE_ITEM_SUCCESS_PATTERNS, UNTIE_ITEM_FAILURE_PATTERNS) when *UNTIE_ITEM_SUCCESS_PATTERNS true else false end end |
.wear_item?(item) ⇒ Boolean
Wears an item from your hands. Wears an item from your hands.
1023 1024 1025 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1023 def wear_item?(item) wear_item_safe?(item) end |
.wear_item_safe?(item) ⇒ Boolean
Same as ‘wear_item_unsafe?’ but ensures that the item name is prefixed with ‘my’ qualifier. Safely wears an item with ‘my’ prefix.
1034 1035 1036 1037 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1034 def wear_item_safe?(item) item = "my #{item}" if item && !(item =~ /^my /i) wear_item_unsafe?(item) end |
.wear_item_unsafe?(item) ⇒ Boolean
Wears an item from your hands. Wears an item without safety checks.
1045 1046 1047 1048 1049 1050 1051 1052 |
# File 'documented/dragonrealms/commons/common-items.rb', line 1045 def wear_item_unsafe?(item) case DRC.bput("wear #{item}", WEAR_ITEM_SUCCESS_PATTERNS, WEAR_ITEM_FAILURE_PATTERNS) when *WEAR_ITEM_SUCCESS_PATTERNS return true else return false end end |
.wearing?(item) ⇒ Boolean
Taps items to check if you’re wearing it. Checks if an item is currently being worn.
569 570 571 |
# File 'documented/dragonrealms/commons/common-items.rb', line 569 def wearing?(item) tap(item) =~ /wearing/ end |