From 9bd9e2c31165fe17ab455be101144efe141c3534 Mon Sep 17 00:00:00 2001 From: Derek Hoffmann Date: Fri, 5 Apr 2024 12:18:34 -0400 Subject: [PATCH 01/30] [combat-trainer.lic] Fix bug with whirlwind on startup and armor_hysteresis When using multiple armors, and armor_hysteresis, and whirlwind it currently doesn't free up a hand before trying to switch armor pieces in def armor_hysteresis? --- combat-trainer.lic | 2 ++ 1 file changed, 2 insertions(+) diff --git a/combat-trainer.lic b/combat-trainer.lic index 506c16b8a6..ac42776b36 100644 --- a/combat-trainer.lic +++ b/combat-trainer.lic @@ -91,9 +91,11 @@ class SetupProcess all_swap_pieces = @cycle_armors.keys.map { |armortype| @cycle_armors[armortype] }.flatten if @cycle_armors.keys.all? { |skill| DRSkill.getxp(skill) > 32 } if @last_worn_type != @default_armor && @cycle_armors.keys.include?(@default_armor) + game_state.sheath_whirlwind_offhand @equipment_manager.worn_items(all_swap_pieces).each { |item| @equipment_manager.remove_item(item) } @equipment_manager.wear_items(@equipment_manager.desc_to_items(@cycle_armors[@default_armor])) @last_worn_type = @default_armor + game_state.wield_whirlwind_offhand end end true From bed67da003559efd17d6d24106cd08a495104a73 Mon Sep 17 00:00:00 2001 From: Derek Hoffmann Date: Fri, 5 Apr 2024 14:04:06 -0400 Subject: [PATCH 02/30] add missing variable to method armor_hysteresis? --- combat-trainer.lic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/combat-trainer.lic b/combat-trainer.lic index ac42776b36..8c64c59b98 100644 --- a/combat-trainer.lic +++ b/combat-trainer.lic @@ -84,7 +84,7 @@ class SetupProcess private - def armor_hysteresis? + def armor_hysteresis?(game_state) return false unless @armor_hysteresis return false if @cycle_armors.keys.any? { |skill| DRSkill.getxp(skill) < 25 } @@ -115,7 +115,7 @@ class SetupProcess end def check_armor_swap(game_state) - return if armor_hysteresis? + return if armor_hysteresis?(game_state) return if Time.now - @last_cycle_time < @cycle_armors_time return if game_state.loaded From d2dc43c5033ce82ca6cd2a5d1197ad68a010eadf Mon Sep 17 00:00:00 2001 From: Mahtra Date: Wed, 29 May 2024 16:20:21 +1200 Subject: [PATCH 03/30] [scripts][dependency] Remove support for lich4, dev mode, etc... --- dependency.lic | 164 +++++-------------------------------------------- 1 file changed, 16 insertions(+), 148 deletions(-) diff --git a/dependency.lic b/dependency.lic index fbbe2e33b4..9ce6ee9d80 100644 --- a/dependency.lic +++ b/dependency.lic @@ -10,7 +10,7 @@ require 'ostruct' require 'digest/sha1' require 'monitor' -$DEPENDENCY_VERSION = '1.6.6' +$DEPENDENCY_VERSION = '1.7.0' $MIN_RUBY_VERSION = '3.2.2' no_pause_all @@ -20,6 +20,7 @@ while Script.running?('repository') echo("Repository is running, pausing for 10 seconds.") pause 10 end + class Object # IMPORT FUTURE LAWLZ def itself @@ -184,13 +185,21 @@ install = args.install class ScriptManager attr_reader :autostarts - attr_accessor :developer, :ignore_dependency def initialize(debug) unless XMLData.game =~ /^DR/ echo("This script is not intended for usage with games other than Dragonrealms. Exiting now") exit end + unless LICH_VERSION.match?(/^5/) + _respond("*****************************************************************************") + _respond("* Unsupported Lich versions detected. *") + _respond("* Please see https://github.com/rpherbig/dr-scripts/wiki/First-Time-Setup *") + _respond("* For an update path. *") + _respond("*****************************************************************************") + exit + end + @debug = debug @paste_bin_token = 'dca351a27a8af501a8d3123e29af7981' @paste_bin_url = 'https://pastebin.com/api/api_post.php' @@ -199,9 +208,7 @@ class ScriptManager @status_branch = Settings['status_branch'] || 'master' update_status_url # Gating setting lich_url on lich version - unless LICH_VERSION.match?(/^5/) - @lich_url = 'https://api.github.com/repos/dragon-realms/dr-lich/git/trees/master' - end + UserVars.autostart_scripts ||= [] UserVars.autostart_scripts.uniq! UserVars.autostart_scripts = UserVars.autostart_scripts - ['dependency'] @@ -210,15 +217,10 @@ class ScriptManager Settings['autostart'] = Settings['autostart'] - ['dependency'] # Setting Settings['lich_fork_sha'] to nil if using lich5. This setting isn't used anymore. - if LICH_VERSION.match?(/^5/) - Settings['lich_fork_sha'] = nil if Settings['lich_fork_sha'] - end Settings['base_versions'] ||= {} CharSettings['next_ruby_version_check_datetime'] = Time.now - @developer = Settings['dependency-developer'] || false - @ignore_dependency = Settings['ignore-dependency'] || false @add_autos = [] @remove_autos = [] update_autostarts @@ -228,11 +230,6 @@ class ScriptManager @request_authorization = manage_github_token @versions = nil - - # Gating lich fork code to non-lich5 - unless LICH_VERSION.match?(/^5/) - @enable_fork = LICH_VERSION =~ /f/ - end end def updated_dependency? @@ -307,8 +304,6 @@ class ScriptManager def run_queue validate_supported_ruby_version - Settings['dependency-developer'] = @developer - Settings['ignore-dependency'] = @ignore_dependency Settings['status_repo'] = @status_repo Settings['status_branch'] = @status_branch update = false @@ -323,16 +318,6 @@ class ScriptManager @remove_autos.each { |script| Settings['autostart'].delete(script) } @remove_autos = [] end - # No lich fork with lich5 - unless LICH_VERSION.match?(/^5/) - if @disable_fork - stop_download_lich - @disable_fork = nil - elsif @enable_fork - download_lich - @enable_fork = nil - end - end submit_thieving_update(*@thievery_queue.pop) unless @thievery_queue.empty? submit_shop_update(@shop_update_queue.pop) unless @shop_update_queue.empty? @@ -388,46 +373,12 @@ class ScriptManager end end - unless LICH_VERSION.match?(/^5/) - def queue_lich - @enable_fork = true - end - - def unqueue_lich - @disable_fork = true - end - - def download_lich - return if @developer - - lich_data = make_request(@lich_url)['tree'].find { |data| data['path'] == 'lich.rbw' } - if LICH_VERSION =~ /f/ && Settings['lich_fork_sha'] == lich_data['sha'] - echo('latest version of lich fork already downloaded.') - return - end - blob = make_request(lich_data['url']) - File.open('lich.rbw', 'w') { |file| file.print(Base64.decode64(blob['content'])) } - Settings['lich_fork_sha'] = lich_data['sha'] - echo('New version of lich installed, please restart Lich.') - end - - def stop_download_lich - Settings['lich_fork_sha'] = nil - end - end - def download_script(filename, force = false) return if filename.nil? || filename.empty? - if filename == 'dependency.lic' && @ignore_dependency - respond 'ignoring dependency download due to ignore_dependency setting' - respond "use '#{$clean_lich_char}e check_dependency' to check the value." - return - end echo("downloading:#{filename}") if @debug info = get_file_status(filename) return unless info - return if @developer return if get_versions[filename] == info['sha'] && !force echo("info:#{info}") if @debug @@ -480,8 +431,6 @@ class ScriptManager end def check_base_files - return if @developer - verify_or_make_dir File.join(SCRIPT_DIR, 'profiles') profile_tree_url = get_status['tree'].find { |element| element['path'] == 'profiles' }['url'] make_request(profile_tree_url)['tree'] @@ -496,8 +445,6 @@ class ScriptManager end def check_data_files - return if @developer - verify_or_make_dir File.join(SCRIPT_DIR, 'data') profile_tree_url = get_status['tree'].find { |element| element['path'] == 'data' }['url'] make_request(profile_tree_url)['tree'] @@ -873,9 +820,10 @@ class SlackbotManager private def register_slackbot - return if @slackbot - return unless @username + return unless @slackbot.nil? + return unless @username.nil? + echo("Registering Slackbot") custom_require.call('slackbot') @slackbot = SlackBot.new end @@ -1622,7 +1570,7 @@ def verify_script(script_names) .each do |name| echo "Failed to find a script named '#{name}'" echo "Please report this to " - echo "or to Discord " + echo "or to Discord " state = false end state @@ -1665,11 +1613,6 @@ end def replace_all managed_scripts .each do |script| - if script == 'dependency.lic' && $manager.ignore_dependency - respond 'ignoring replace dependency due to ignore_dependency setting' - respond "use '#{$clean_lich_char}e check_dependency' to check the value." - next - end new_name = "#{script}.#{Time.now.to_i}.bak" respond "Renaming existing script #{script} to #{new_name}" File.rename(File.join(SCRIPT_DIR, "#{script}"), File.join(SCRIPT_DIR, "#{new_name}")) @@ -1711,73 +1654,6 @@ def stop_autostart(script_names) end end -def set_dev_mode - echo "Now turning dev mode on" - $manager.developer = true - echo "Developer mode now set to: #{$manager.developer}" -end - -def unset_dev_mode - echo "Now turning dev mode off" - $manager.developer = false - echo "Developer mode now set to: #{$manager.developer}" -end - -def check_dev_mode - echo "Developer mode set to: #{$manager.developer}" -end - -def toggle_developer_mode - echo "THIS METHOD IS NO LONGER USED. USE '#{$clean_lich_char}e set_dev_mode' and '#{$clean_lich_char}e unset_dev_mode'." -end - -def ignore_dependency - echo "Now ignoring dependency updates" - $manager.ignore_dependency = true - echo "ignore_dependency now set to: #{$manager.ignore_dependency}" -end - -def unignore_dependency - echo "Now processing dependency updates" - $manager.ignore_dependency = false - echo "ignore_dependency now set to: #{$manager.ignore_dependency}" -end - -def check_dependency - echo "ignore_dependency is set to: #{$manager.ignore_dependency}" - echo "Use '#{$clean_lich_char}e ignore_dependency' and '#{$clean_lich_char}e unignore_dependency' to change." -end - -unless LICH_VERSION.match?(/^5/) - def use_lich_fork - echo 'Now switching onto the DR lich fork...' - start_script('repository', ['unset-lich-updatable']) - pause 1 while Script.running?('repository') - echo 'Turning off updates from main lich branch on go2...' - start_script('repository', ['unset-updatable', 'go2']) - $manager.queue_lich - end - - def use_lich_main - echo 'Now switching onto the lich mainline...' - start_script('repository', ['set-lich-updatable']) - pause 1 while Script.running?('repository') - - echo 'Turning updates from main lich branch on go2 back on...' - start_script('repository', ['set-updatable', 'go2']) - pause 1 while Script.running?('repository') - - start_script('repository', ['download-lich']) - pause - pause 1 while Script.running?('repository') - echo('New version of lich installed, please restart Lich.') - end - - def toggle_lich_fork - echo "THIS METHOD IS NO LONGER USED. USE #{$clean_lich_char}e use_lich_fork and #{$clean_lich_char}e use_lich_main" - end -end - def set_custom_status_repo(repo, branch = 'master') $manager.set_custom_status_repo(repo, branch) end @@ -1912,14 +1788,6 @@ $manager.check_data_files $manager.start_scripts $manager.make_map_edits -if LICH_VERSION.match?(/^4/) - _respond("*****************************************************************************") - _respond("* Lich version 4 detected. This version of lich was deprecated in mid-2022. *") - _respond("* Please see https://github.com/rpherbig/dr-scripts/wiki/First-Time-Setup *") - _respond("* For an update path. *") - _respond("*****************************************************************************") -end - if $manager.updated_dependency? echo('Update found for dependency.lic') update_d From 435cae7632b8189385f29c144b9e31e3657d4603 Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Thu, 30 May 2024 12:16:07 +1200 Subject: [PATCH 04/30] Fixing Slackbot registration --- dependency.lic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dependency.lic b/dependency.lic index 9ce6ee9d80..4b17dea9c3 100644 --- a/dependency.lic +++ b/dependency.lic @@ -10,7 +10,7 @@ require 'ostruct' require 'digest/sha1' require 'monitor' -$DEPENDENCY_VERSION = '1.7.0' +$DEPENDENCY_VERSION = '1.7.1' $MIN_RUBY_VERSION = '3.2.2' no_pause_all @@ -820,8 +820,8 @@ class SlackbotManager private def register_slackbot + return unless @username return unless @slackbot.nil? - return unless @username.nil? echo("Registering Slackbot") custom_require.call('slackbot') From fb176cb94eb0761cb55f8bc77affab29d0ee278e Mon Sep 17 00:00:00 2001 From: Mahtra Date: Thu, 30 May 2024 12:34:55 +1200 Subject: [PATCH 05/30] [scripts][help-me][validate] Remove references to dev mode --- help-me.lic | 2 -- validate.lic | 7 ------- 2 files changed, 9 deletions(-) diff --git a/help-me.lic b/help-me.lic index 7ef59b4fa2..7d672e5eb8 100644 --- a/help-me.lic +++ b/help-me.lic @@ -39,8 +39,6 @@ class HelpMe message_body += "\n" message_body += "Game Client: #{$frontend}" message_body += "\n" - message_body += "Dev Mode: #{$manager.developer}" - message_body += "\n" Dir[File.join(SCRIPT_DIR, 'profiles/*.yaml')].map { |item| File.path(item) }.select { |path| path.include?("#{checkname}-") }.each do |path| message_body += "\n****" * 3 diff --git a/validate.lic b/validate.lic index 560ea4c0c0..08d99675bd 100644 --- a/validate.lic +++ b/validate.lic @@ -17,13 +17,6 @@ class DRYamlValidator setup_data - if $manager.developer - respond("") - echo "**WARNING**: You are on developer or dev mode. That suggests you are a developer." - echo "**WARNING**: If you are on dev mode, you should be capable of solving most issues yourself." - echo "**WARNING**: Support by Lich contributors will be limited or declined." - end - respond("") respond(" CHECKING: That #{checkname}-setup.yaml exists in the proper folder.") if profiles.grep(/#{checkname}-setup/).empty? From 887a227be08898a84f0da7a5e2cafb48d33b7391 Mon Sep 17 00:00:00 2001 From: Mahtra Date: Mon, 3 Jun 2024 03:01:03 +1200 Subject: [PATCH 06/30] [scripts][pick]If using skeleton key, exit if can't get key --- pick.lic | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pick.lic b/pick.lic index c7207e98ac..634c9472b8 100644 --- a/pick.lic +++ b/pick.lic @@ -415,7 +415,10 @@ class Pick def try_unlock_box_with_key(box) return unless @settings.use_skeleton_key - return unless DRCI.get_item_if_not_held?(@settings.skeleton_key) + unless DRCI.get_item_if_not_held?(@settings.skeleton_key) + echo("Couldn't get skeleton key. Exiting.") + exit + end result = DRC.bput("turn my #{@settings.skeleton_key} at my #{box['noun']}", "^You turn", "that doesn't seem to do much", "I could not find", "What were you referring") waitrt? From a6defa3c3e323240f67c23e33983ad6eb1e38eeb Mon Sep 17 00:00:00 2001 From: Mahtra Date: Mon, 3 Jun 2024 03:02:46 +1200 Subject: [PATCH 07/30] rubocop --- pick.lic | 1 + 1 file changed, 1 insertion(+) diff --git a/pick.lic b/pick.lic index 634c9472b8..f6c1c13021 100644 --- a/pick.lic +++ b/pick.lic @@ -415,6 +415,7 @@ class Pick def try_unlock_box_with_key(box) return unless @settings.use_skeleton_key + unless DRCI.get_item_if_not_held?(@settings.skeleton_key) echo("Couldn't get skeleton key. Exiting.") exit From 990f6334c724a40d0f1b296189c31493561eeef2 Mon Sep 17 00:00:00 2001 From: mikejc Date: Sun, 2 Jun 2024 16:57:09 -0400 Subject: [PATCH 08/30] [script][remedy] Added stamp and cube functionality --- remedy.lic | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/remedy.lic b/remedy.lic index a51663e5bf..52620fec0a 100644 --- a/remedy.lic +++ b/remedy.lic @@ -15,6 +15,8 @@ class Remedy @belt = @settings.alchemy_belt @training_spells = @settings.crafting_training_spells @stock = get_data('crafting')['remedies'][@settings.hometown] + @stamp = @settings.mark_crafted_goods + @cube = @settings.cube_armor_piece arg_definitions = [ [ @@ -177,6 +179,8 @@ class Remedy DRCC.stow_crafting_item("remed book", @bag, @forging_belt) end + DRC.bput("touch my #{@cube}", /^Warm vapor swirls around your head in a misty halo/, /^A thin cloud of vapor manifests with no particular effect./, /^Touch what/) if @cube + if ('red flower').include?(@herb1) @herb1 = 'dried flower' unless DRCI.exists?('red flower') elsif ('blue flower').include?(@herb1) @@ -397,11 +401,18 @@ class Remedy DRC.bput('release symb', "But you haven't", 'You release', 'Repeat this command') end + def stamp_item(noun) + DRCC.get_crafting_item('stamp', @bag, @bag_items, @belt) + DRC.bput("mark my #{noun} with my stamp", 'carefully hammer the stamp', 'You cannot figure out how to do that', 'too badly damaged', /score the surface with the stamp/) + DRCC.stow_crafting_item('stamp', @bag, @belt) + end + def finish waitrt? stow_item(DRC.left_hand) fput("get my #{@noun} from my #{@container}") stow_item(DRC.right_hand) + stamp_item(@noun) if @stamp magic_cleanup exit end From 2f1cd01d27c1dfb22ed8aca6c1a5225fd46c8e71 Mon Sep 17 00:00:00 2001 From: hat071af Date: Sun, 2 Jun 2024 18:29:20 -0700 Subject: [PATCH 09/30] Update base-spells.yaml Added catch for case when using tattoo_tm: to target a tm spell after invoking it from a tattoo fails due to lack of target. --- data/base-spells.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/base-spells.yaml b/data/base-spells.yaml index 33d9d10ade..b7dd0db984 100644 --- a/data/base-spells.yaml +++ b/data/base-spells.yaml @@ -142,6 +142,8 @@ prep_messages: - Please don't do that here - You cannot use the tattoo while maintaining the effort to stay hidden - As you attempt to prepare the spell, a sense of overwhelming peace washes over you +# You tried to target a spell but there is nothing left to face +- There is nothing else to face cast_messages: - Converging in midair, angular ripples assemble a slender hexagonal rod whorled with faintly shifting fractals From 0ece4c54d2725967fa0ac962c3050bf83539588f Mon Sep 17 00:00:00 2001 From: mikejc Date: Tue, 4 Jun 2024 01:52:41 -0400 Subject: [PATCH 10/30] [script][inventory-manager] first pass at rewrite --- inventory-manager.lic | 185 ++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 117 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index b299de26e8..1d287722ba 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -6,6 +6,26 @@ custom_require.call(%w[common]) class InventoryManager def initialize + @INVENTORY_IGNORES = ['[', + '<', + 'Roundtime', + 'You have', + 'Vault Inventory', + 'Done', + 'The last note', + 'a brass hook', + 'a steel wire rack', + 'a small shelf', + 'a top drawer', + 'a middle drawer', + 'a bottom drawer', + 'a large shelf', + 'Inside a', + 'Page', + 'Stored Deeds', + 'Currently store', + 'Maximum:'] + @active_character = Char.name.to_sym @item_db_path = "data/inventory.yaml" @@ -21,8 +41,7 @@ class InventoryManager { name: 'vault_regular', regex: /vault_regular/i, optional: true, description: "Rummages your vault to save items NOTE: must be standing by your open vault." }, { name: 'storage_box', regex: /storage_box/i, optional: true, description: "Rummages caravan storage box for items." }, { name: 'family_vault', regex: /family_vault/i, optional: true, description: "Rummages your family vault to save items NOTE: must be standing by your open vault." }, - { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." }, - { name: 'eddy', regex: /eddy/i, optional: true, description: "Save the contents of an eddy (HE 436 Gift)." } + { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." } ], [ { name: 'search', regex: /search/i, description: 'Start a search across all characters for specified item.' }, @@ -50,8 +69,6 @@ class InventoryManager add_family_vault elsif args.register add_register_inv - elsif args.eddy - add_eddy_inv elsif args.storage_box add_storage_box_inv elsif args.save @@ -111,122 +128,86 @@ class InventoryManager end end - def add_vault_book_inv + def checkInventory(command, end_pattern, inventory_type, rummage_length = 0) + using_sorter = false + if Script.running?('sorter') + stop_script('sorter') + using_sorter = true + end + if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? 'vault' } + @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? inventory_type } else @item_data[@active_character] = [] end - unless DRCI.get_item_if_not_held?("vault book") - DRC.message "Unable to find your vault book, exiting!" - exit - end - - DRC.bput('read my vault book', 'Vault Inventory:') - while (line = get) - break if line =~ /The last note/i + capture = Lich::Util.issue_command(command, end_pattern) - item = line.lstrip.concat(' (vault)') - @item_data[@active_character] << item - end + lines = capture + if command.start_with?("rummage") + container = capture[0] + lines = container[rummage_length, container.length-(rummage_length+1)].split(",") - DRCI.stow_item?("vault book") + last_item = lines.length - 1 - DRC.message("Saving vault data for #{@active_character}!") - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - end + last_two_items = lines[last_item].split(" and ") - def add_current_inv - if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| (line.include?('vault') || line.include?('eddy')) } - else - @item_data[@active_character] = [] + lines[last_item] = last_two_items[0] + lines[last_item + 1] = last_two_items[1] end - DRC.bput('inv list', 'You have:') - while (line = get) - break if line =~ /Roundtime/i - + lines.each_with_index do |line, itr| item = line.lstrip + + next if item.empty? + next if item.start_with?(*@INVENTORY_IGNORES) + if item[0].eql? '-' item[0] = '' item.concat(' (in container)') - else + elsif inventory_type == 'character' item.concat(' (worn)') end + + item.concat(" (#{inventory_type})") + @item_data[@active_character] << item end - DRC.message "Saving inventory data for #{@active_character}!" - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - end + DRC.message("Saving #{inventory_type} data for #{@active_character}!") + File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml(line_width: -1)) } - def add_register_inv - if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? 'register' } - else - @item_data[@active_character] = [] + if using_sorter + start_script('sorter') unless Script.running?('sorter') end + end - case DRC.bput("get my register", 'You get', 'What were', 'You are already holding that') - when 'What were' - DRC.message "Unable to find your register, exiting!" + def add_vault_book_inv + unless DRCI.get_item_if_not_held?("vault book") + DRC.message "Unable to find your vault book, exiting!" exit end - DRC.bput("turn my register to contents", 'You flip your deed register', 'already at the table of contents') - - case DRC.bput("read my register", 'Stored Deeds', 'stored any deeds in this register') - when 'stored any deeds in this register' - exit - when 'Stored Deeds' - while (line = get) - break if line =~ /Currently stored/i - - item = line.lstrip.concat(' (register)') - @item_data[@active_character] << item - end - end + checkInventory("read my vault book", /^Vault Inventory:/, 'vault') - DRC.bput('stow my register', 'You put') + DRCI.stow_item?("vault book") + end - DRC.message "Saving register data for #{@active_character}!" - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } + def add_current_inv + checkInventory("inv list", /^You have:/, 'character') end - def add_eddy_inv - if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? 'eddy' } - else - @item_data[@active_character] = [] + def add_register_inv + unless DRCI.get_item_if_not_held?("register") + DRC.message "Unable to find your register, exiting!" + exit end - using_sorter = false - if Script.running?('sorter') - stop_script('sorter') - using_sorter = true - end + DRC.bput("turn my register to contents", 'You flip your deed register', 'already at the table of contents') - item_list = DRC.bput('look in my watery portal', /In the swirling eddy .*/i, 'What were') - .slice!("In the swirling eddy you see") - .split(",") - item_list.each_with_index do |item, itr| - if itr < item_list.length - 1 - @item_data[@active_character] << item.lstrip.concat(' (eddy)') - else - item.split("and") - .each do |item2| - @item_data[@active_character] << item2.strip.concat(" (eddy)").tr('.', '') - end - end - end + checkInventory("read my register", /^Stored Deeds:/, 'register') - DRC.message "Saving eddy data for #{@active_character}!" - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - if using_sorter - start_script('sorter') unless Script.running?('sorter') - end + DRCI.stow_item?("register") end def add_storage_box_inv @@ -298,37 +279,7 @@ class InventoryManager end def add_vault_regular_inv - if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? 'vault' } - else - @item_data[@active_character] = [] - end - - using_sorter = false - if Script.running?('sorter') - stop_script('sorter') - using_sorter = true - end - - item_list = DRC.bput('rummage vault', /through a secure vault and see .*/i, 'What were') - .slice!("You rummage through a secure vault and see") - .split(",") - item_list.each_with_index do |item, itr| - if itr < item_list.length - 1 - @item_data[@active_character] << item.lstrip.concat(' (vault)') - else - item.split("and") - .each do |item2| - @item_data[@active_character] << item2.strip.concat(" (vault)").tr('.', '') - end - end - end - - DRC.message("Saving vault data for #{@active_character}!") - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - if using_sorter - start_script('sorter') unless Script.running?('sorter') - end + checkInventory("rummage vault", /^You rummage through a secure vault/, 'vault', 42) end def list_character_inv(name) From c4f9a69ba72d23d16b5a2a319d968b29d120378c Mon Sep 17 00:00:00 2001 From: mikejc Date: Tue, 4 Jun 2024 02:05:35 -0400 Subject: [PATCH 11/30] rubocop fixes --- inventory-manager.lic | 58 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 1d287722ba..da0ff5c3b5 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -6,25 +6,25 @@ custom_require.call(%w[common]) class InventoryManager def initialize - @INVENTORY_IGNORES = ['[', - '<', - 'Roundtime', - 'You have', - 'Vault Inventory', - 'Done', - 'The last note', - 'a brass hook', - 'a steel wire rack', - 'a small shelf', - 'a top drawer', - 'a middle drawer', - 'a bottom drawer', - 'a large shelf', - 'Inside a', - 'Page', - 'Stored Deeds', - 'Currently store', - 'Maximum:'] + @inventory_ignores = ['[', + '<', + 'Roundtime', + 'You have', + 'Vault Inventory', + 'Done', + 'The last note', + 'a brass hook', + 'a steel wire rack', + 'a small shelf', + 'a top drawer', + 'a middle drawer', + 'a bottom drawer', + 'a large shelf', + 'Inside a', + 'Page', + 'Stored Deeds', + 'Currently store', + 'Maximum:'] @active_character = Char.name.to_sym @item_db_path = "data/inventory.yaml" @@ -128,7 +128,7 @@ class InventoryManager end end - def checkInventory(command, end_pattern, inventory_type, rummage_length = 0) + def check_inventory(command, end_pattern, inventory_type, rummage_length = 0) using_sorter = false if Script.running?('sorter') stop_script('sorter') @@ -136,7 +136,7 @@ class InventoryManager end if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? inventory_type } + @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? inventory_type } else @item_data[@active_character] = [] end @@ -146,7 +146,7 @@ class InventoryManager lines = capture if command.start_with?("rummage") container = capture[0] - lines = container[rummage_length, container.length-(rummage_length+1)].split(",") + lines = container[rummage_length, container.length - (rummage_length + 1)].split(",") last_item = lines.length - 1 @@ -156,11 +156,11 @@ class InventoryManager lines[last_item + 1] = last_two_items[1] end - lines.each_with_index do |line, itr| + lines.each do |line| item = line.lstrip next if item.empty? - next if item.start_with?(*@INVENTORY_IGNORES) + next if item.start_with?(*@inventory_ignores) if item[0].eql? '-' item[0] = '' @@ -168,7 +168,7 @@ class InventoryManager elsif inventory_type == 'character' item.concat(' (worn)') end - + item.concat(" (#{inventory_type})") @item_data[@active_character] << item @@ -188,13 +188,13 @@ class InventoryManager exit end - checkInventory("read my vault book", /^Vault Inventory:/, 'vault') + check_inventory("read my vault book", /^Vault Inventory:/, 'vault') DRCI.stow_item?("vault book") end def add_current_inv - checkInventory("inv list", /^You have:/, 'character') + check_inventory("inv list", /^You have:/, 'character') end def add_register_inv @@ -205,7 +205,7 @@ class InventoryManager DRC.bput("turn my register to contents", 'You flip your deed register', 'already at the table of contents') - checkInventory("read my register", /^Stored Deeds:/, 'register') + check_inventory("read my register", /^Stored Deeds:/, 'register') DRCI.stow_item?("register") end @@ -279,7 +279,7 @@ class InventoryManager end def add_vault_regular_inv - checkInventory("rummage vault", /^You rummage through a secure vault/, 'vault', 42) + check_inventory("rummage vault", /^You rummage through a secure vault/, 'vault', 42) end def list_character_inv(name) From 106ef5b2aad141b470e39d632760b14921562269 Mon Sep 17 00:00:00 2001 From: mikejc Date: Tue, 4 Jun 2024 11:07:36 -0400 Subject: [PATCH 12/30] updating storage box and family vault logic --- inventory-manager.lic | 64 ++----------------------------------------- 1 file changed, 2 insertions(+), 62 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index da0ff5c3b5..4991c318cb 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -211,71 +211,11 @@ class InventoryManager end def add_storage_box_inv - if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? 'caravan_box' } - else - @item_data[@active_character] = [] - end - - using_sorter = false - if Script.running?('sorter') - stop_script('sorter') - using_sorter = true - end - - item_list = DRC.bput('rummage storage box', /through a storage box and see .*/i, 'What were') - .slice!("You rummage through a storage box and see") - .split(",") - item_list.each_with_index do |item, itr| - if itr < item_list.length - 1 - @item_data[@active_character] << item.lstrip.concat(' (caravan_box)') - else - item.split("and") - .each do |item2| - @item_data[@active_character] << item2.strip.concat(" (caravan_box)").tr('.', '') - end - end - end - - DRC.message("Saving caravan box data for #{@active_character}!") - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - if using_sorter - start_script('sorter') unless Script.running?('sorter') - end + check_inventory("rummage storage boc", /^You rummage through a storage box/, 'caravan_box', 41) end def add_family_vault - if @item_data['Family'] - @item_data['Family'] = @item_data['Family'].select { |line| !line.include? 'Family' } - else - @item_data['Family'] = [] - end - - using_sorter = false - if Script.running?('sorter') - stop_script('sorter') - using_sorter = true - end - - item_list = DRC.bput('rummage vault', /through a vault and see .*/i, 'What were') - .slice!("You rummage through a vault and see") - .split(",") - item_list.each_with_index do |item, itr| - if itr < item_list.length - 1 - @item_data['Family'] << item.lstrip.concat(' (Family)') - else - item.split("and") - .each do |item2| - @item_data['Family'] << item2.strip.concat(" (Family)").tr('.', '') - end - end - end - - DRC.message("Saving family vault data!") - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - if using_sorter - start_script('sorter') unless Script.running?('sorter') - end + check_inventory("rummage vault", /^You rummage through a secure vault/, 'Family vault', 42) end def add_vault_regular_inv From 11d4fdeb08f3bb8d8dbe5baef73a4df10b3efc9c Mon Sep 17 00:00:00 2001 From: mikejc Date: Tue, 4 Jun 2024 12:36:32 -0400 Subject: [PATCH 13/30] restore eddy, add versioning, cleanup --- inventory-manager.lic | 46 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 4991c318cb..c528182441 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -41,7 +41,8 @@ class InventoryManager { name: 'vault_regular', regex: /vault_regular/i, optional: true, description: "Rummages your vault to save items NOTE: must be standing by your open vault." }, { name: 'storage_box', regex: /storage_box/i, optional: true, description: "Rummages caravan storage box for items." }, { name: 'family_vault', regex: /family_vault/i, optional: true, description: "Rummages your family vault to save items NOTE: must be standing by your open vault." }, - { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." } + { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." }, + { name: 'eddy', regex: /eddy/i, optional: true, description: "Save the contents of an eddy (HE 436 Gift)." } ], [ { name: 'search', regex: /search/i, description: 'Start a search across all characters for specified item.' }, @@ -69,6 +70,8 @@ class InventoryManager add_family_vault elsif args.register add_register_inv + elsif args.eddy + add_eddy_inv elsif args.storage_box add_storage_box_inv elsif args.save @@ -101,6 +104,30 @@ class InventoryManager end @item_data = OpenStruct.new(YAML.load_file(@item_db_path)).to_h + + @version_string = 'version'.to_sym + + version = @item_data[@version_string][0] + + if version != '2.00' + @item_data.each do |k, v| + v.each { |item| + next if valid_data_row(item) + + item.concat(" (character)") + } + end + @item_data[@version_string] = ['2.00'] + File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml(line_width: -1)) } + end + end + + def valid_data_row(item) + if item.include?('(vault)') || item.include?('(register)') || item.include?('(eddy)') || item.include?('(caravan_box)') || item.include?('(Family)') + true + else + false + end end def get_inv_count(desc) @@ -136,7 +163,7 @@ class InventoryManager end if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? inventory_type } + @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? "(#{inventory_type})" } else @item_data[@active_character] = [] end @@ -210,12 +237,16 @@ class InventoryManager DRCI.stow_item?("register") end + def add_eddy_inv + checkInventory("inv eddy", /^Inside a/, 'eddy') + end + def add_storage_box_inv check_inventory("rummage storage boc", /^You rummage through a storage box/, 'caravan_box', 41) end def add_family_vault - check_inventory("rummage vault", /^You rummage through a secure vault/, 'Family vault', 42) + check_inventory("rummage vault", /^You rummage through a secure vault/, 'Family', 42) end def add_vault_regular_inv @@ -226,6 +257,7 @@ class InventoryManager if name.nil? DRC.message "There is inventory data for:" @item_data.each do |k, v| + next if k == @version_string inv_count = 0 v.each do |_data| inv_count += 1 @@ -247,6 +279,7 @@ class InventoryManager def search_for_item(item) total_found = 0 @item_data.each do |k, v| + next if k == @version_string total_found = 0 DRC.message "Checking #{k}:" v.each { |data| @@ -259,10 +292,11 @@ class InventoryManager end end - def remove_character_data(name) - @item_data.delete(name.capitalize.to_sym) + def remove_character_data(name_to_remove) + return if name_to_remove == "version" + @item_data.delete(name_to_remove.capitalize.to_sym) File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - DRC.message "Removed #{name.capitalize}'s data!" + DRC.message "Removed #{name_to_remove.capitalize}'s data!" end end From c5aedc404ad83418b973f6422d1da5bef47810e3 Mon Sep 17 00:00:00 2001 From: mikejc Date: Tue, 4 Jun 2024 12:38:18 -0400 Subject: [PATCH 14/30] rubocop --- inventory-manager.lic | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index c528182441..60a10efc61 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -110,7 +110,7 @@ class InventoryManager version = @item_data[@version_string][0] if version != '2.00' - @item_data.each do |k, v| + @item_data.each do |_k, v| v.each { |item| next if valid_data_row(item) @@ -258,6 +258,7 @@ class InventoryManager DRC.message "There is inventory data for:" @item_data.each do |k, v| next if k == @version_string + inv_count = 0 v.each do |_data| inv_count += 1 @@ -280,6 +281,7 @@ class InventoryManager total_found = 0 @item_data.each do |k, v| next if k == @version_string + total_found = 0 DRC.message "Checking #{k}:" v.each { |data| @@ -294,6 +296,7 @@ class InventoryManager def remove_character_data(name_to_remove) return if name_to_remove == "version" + @item_data.delete(name_to_remove.capitalize.to_sym) File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } DRC.message "Removed #{name_to_remove.capitalize}'s data!" From eabe6dd2a8592318e842211548dfcc7df949045a Mon Sep 17 00:00:00 2001 From: mikejc Date: Tue, 4 Jun 2024 17:38:43 -0400 Subject: [PATCH 15/30] minor cleanup and added an eddy warning --- inventory-manager.lic | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 60a10efc61..91f160b7e6 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -35,7 +35,6 @@ class InventoryManager { name: 'desc', regex: /\w+/i, optional: true, description: "Optional specific count by description. Use quotes for multiple word strings, i.e., \"purple pouch\"." } ], [ - { name: 'save', regex: /save/i, description: "Save new or update current character's items to the database." }, { name: 'vault_book', regex: /vault_book/i, optional: true, description: "Retrieves, reads, and save from vault book." }, { name: 'vault_regular', regex: /vault_regular/i, optional: true, description: "Rummages your vault to save items NOTE: must be standing by your open vault." }, @@ -71,6 +70,7 @@ class InventoryManager elsif args.register add_register_inv elsif args.eddy + DRC.message('*WARNING: Character inventory includes items found within Eddy. Using both will duplicate Eddy items.') add_eddy_inv elsif args.storage_box add_storage_box_inv @@ -85,7 +85,7 @@ class InventoryManager elsif args.list list_character_inv(args.name) else - DRC.message 'Type ;inventory-manager help for a usage guide' + DRC.message('Type ;inventory-manager help for a usage guide') end end @@ -98,8 +98,8 @@ class InventoryManager end if !File.exist?(@item_db_path) - DRC.message "Something very wrong is occuring. You don't have a file to open and I can't create one!" - DRC.message "item-db saves the file to: /lich/scripts/itemDB/inventory.yaml" + DRC.message("Something very wrong is occuring. You don't have a file to open and I can't create one!") + DRC.message("item-db saves the file to: /lich/scripts/itemDB/inventory.yaml") exit end @@ -142,7 +142,7 @@ class InventoryManager count += 1 closed += 1 if item.match?(/(closed)/) end - DRC.message "You have #{count} items, #{closed} of which are (closed) containers." + DRC.message("You have #{count} items, #{closed} of which are (closed) containers.") else # Counting items matching the description, i.e., inv count pouch DRC.bput("inv search #{desc}", 'You rummage') @@ -151,7 +151,7 @@ class InventoryManager count += 1 end - DRC.message "You have #{count} items matching \"#{desc}\"." + DRC.message("You have #{count} items matching \"#{desc}\".") end end @@ -211,7 +211,7 @@ class InventoryManager def add_vault_book_inv unless DRCI.get_item_if_not_held?("vault book") - DRC.message "Unable to find your vault book, exiting!" + DRC.message("Unable to find your vault book, exiting!") exit end @@ -226,7 +226,7 @@ class InventoryManager def add_register_inv unless DRCI.get_item_if_not_held?("register") - DRC.message "Unable to find your register, exiting!" + DRC.message("Unable to find your register, exiting!") exit end @@ -255,7 +255,7 @@ class InventoryManager def list_character_inv(name) if name.nil? - DRC.message "There is inventory data for:" + DRC.message("There is inventory data for:") @item_data.each do |k, v| next if k == @version_string @@ -263,17 +263,17 @@ class InventoryManager v.each do |_data| inv_count += 1 end - DRC.message "#{k} - #{inv_count}" + DRC.message("#{k} - #{inv_count}") end return end name_sym = name.capitalize.to_sym if @item_data.has_key?(name_sym) - DRC.message "Inventory for #{name.capitalize}" - @item_data[name_sym].each { |item| DRC.message " - #{item}" } + DRC.message("Inventory for #{name.capitalize}") + @item_data[name_sym].each { |item| DRC.message(" - #{item}") } else - DRC.message "No data found for the character #{name.capitalize}!" + DRC.message("No data found for the character #{name.capitalize}!") end end @@ -283,14 +283,14 @@ class InventoryManager next if k == @version_string total_found = 0 - DRC.message "Checking #{k}:" + DRC.message("Checking #{k}:") v.each { |data| if data.downcase.include?(item) total_found += 1 - DRC.message "Match #{total_found}): #{data}" + DRC.message("Match #{total_found}): #{data}") end } - DRC.message "Found #{total_found} matches on #{k}\n" + DRC.message("Found #{total_found} matches on #{k}\n") end end @@ -299,7 +299,7 @@ class InventoryManager @item_data.delete(name_to_remove.capitalize.to_sym) File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } - DRC.message "Removed #{name_to_remove.capitalize}'s data!" + DRC.message("Removed #{name_to_remove.capitalize}'s data!") end end From fb853716b370938b0914d4d64ca1c4de32d393da Mon Sep 17 00:00:00 2001 From: mikejc Date: Thu, 6 Jun 2024 02:22:47 -0400 Subject: [PATCH 16/30] adding scroll stacker support --- inventory-manager.lic | 65 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 91f160b7e6..8494fa90bf 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -2,7 +2,7 @@ Documentation: https://elanthipedia.play.net/Lich_script_repository#inventory-manager =end -custom_require.call(%w[common]) +custom_require.call(%w[common common-items]) class InventoryManager def initialize @@ -41,7 +41,8 @@ class InventoryManager { name: 'storage_box', regex: /storage_box/i, optional: true, description: "Rummages caravan storage box for items." }, { name: 'family_vault', regex: /family_vault/i, optional: true, description: "Rummages your family vault to save items NOTE: must be standing by your open vault." }, { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." }, - { name: 'eddy', regex: /eddy/i, optional: true, description: "Save the contents of an eddy (HE 436 Gift)." } + { name: 'eddy', regex: /eddy/i, optional: true, description: "Save the contents of an eddy (HE 436 Gift)." }, + { name: 'scrolls', regex: /scrolls/i, optional: true, description: "Save spell scrolls tracked with sort-scrolls or stack-scrolls"} ], [ { name: 'search', regex: /search/i, description: 'Start a search across all characters for specified item.' }, @@ -58,6 +59,7 @@ class InventoryManager ] args = parse_args(arg_definitions) + @settings = get_settings setup @@ -74,6 +76,8 @@ class InventoryManager add_eddy_inv elsif args.storage_box add_storage_box_inv + elsif args.scrolls + add_scrolls elsif args.save add_current_inv elsif args.count @@ -253,6 +257,63 @@ class InventoryManager check_inventory("rummage vault", /^You rummage through a secure vault/, 'vault', 42) end + def add_scrolls + stacker_container = (@settings.scroll_sorter['stacker_container'] || @settings.stacker_container) + unless stacker_container + DRC.message("You have no stacker_container defined for sort-scrolls!") + exit + end + + if @item_data[@active_character] + @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? "(spell_scroll)" } + else + @item_data[@active_character] = [] + end + + stacker = @settings.scroll_sorter['stacker'] + scroll_stackers = @settings.scroll_stackers + + DRCI.open_container?("my #{stacker_container}") + + spells = [] + + if stacker + 10.times do |n| + DRCI.get_item_safe?("tenth #{stacker}", stacker_container) + spells.concat(check_scroll_stacker(stacker)) + DRCI.put_away_item?(stacker, stacker_container) + end + else + for scroll_stacker in scroll_stackers + DRCI.get_item_safe?(scroll_stacker, stacker_container) + spells.concat(check_scroll_stacker(scroll_stacker)) + DRCI.put_away_item?(scroll_stacker, stacker_container) + end + end + + for spell in spells.sort + @item_data[@active_character] << spell + end + + DRC.message("Saving spell_scroll data for #{@active_character}!") + File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml(line_width: -1)) } + + DRCI.close_container?("my #{stacker_container}") if @settings.scroll_sorter['close_container'] + end + + def check_scroll_stacker(stacker) + spells = [] + capture = Lich::Util.issue_command("flip my #{stacker.split.last}", /^You flip through the #{stacker.split.last}, checking each section before closing it.$/) + capture.each do |line| + if line =~ /The (.+) section has (\d+)/ + spell = "#{Regexp.last_match(1)} (#{Regexp.last_match(2)})" + spell.concat(" (spell_scroll)") + spells << spell + end + end + spells + end + def list_character_inv(name) if name.nil? DRC.message("There is inventory data for:") From 4e5f7f8c085c2ab0a151d67df2ded1382f03ff40 Mon Sep 17 00:00:00 2001 From: mikejc Date: Thu, 6 Jun 2024 02:25:21 -0400 Subject: [PATCH 17/30] rubocop --- inventory-manager.lic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 8494fa90bf..b919edcbaf 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -42,7 +42,7 @@ class InventoryManager { name: 'family_vault', regex: /family_vault/i, optional: true, description: "Rummages your family vault to save items NOTE: must be standing by your open vault." }, { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." }, { name: 'eddy', regex: /eddy/i, optional: true, description: "Save the contents of an eddy (HE 436 Gift)." }, - { name: 'scrolls', regex: /scrolls/i, optional: true, description: "Save spell scrolls tracked with sort-scrolls or stack-scrolls"} + { name: 'scrolls', regex: /scrolls/i, optional: true, description: "Save spell scrolls tracked with sort-scrolls or stack-scrolls." } ], [ { name: 'search', regex: /search/i, description: 'Start a search across all characters for specified item.' }, @@ -278,7 +278,7 @@ class InventoryManager spells = [] if stacker - 10.times do |n| + 10.times do DRCI.get_item_safe?("tenth #{stacker}", stacker_container) spells.concat(check_scroll_stacker(stacker)) DRCI.put_away_item?(stacker, stacker_container) From 97288c264e8a1684eec0c74b33f7af757f58afa6 Mon Sep 17 00:00:00 2001 From: mikejc Date: Thu, 6 Jun 2024 02:39:17 -0400 Subject: [PATCH 18/30] add container name to character inventory --- inventory-manager.lic | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index b919edcbaf..e340772613 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -187,17 +187,22 @@ class InventoryManager lines[last_item + 1] = last_two_items[1] end + container = "" lines.each do |line| item = line.lstrip + next if item.empty? next if item.start_with?(*@inventory_ignores) if item[0].eql? '-' item[0] = '' - item.concat(' (in container)') - elsif inventory_type == 'character' - item.concat(' (worn)') + item.concat(" (in container - #{container})") + else + container = item.include?("eddy") ? "eddy" : DRC.get_noun(item) + if inventory_type == 'character' + item.concat(' (worn)') + end end item.concat(" (#{inventory_type})") From 5f0c921323e267024089619c8efe2a40cf9a8be1 Mon Sep 17 00:00:00 2001 From: mikejc Date: Thu, 6 Jun 2024 02:40:52 -0400 Subject: [PATCH 19/30] rubocop --- inventory-manager.lic | 1 - 1 file changed, 1 deletion(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index e340772613..837362e849 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -191,7 +191,6 @@ class InventoryManager lines.each do |line| item = line.lstrip - next if item.empty? next if item.start_with?(*@inventory_ignores) From 922725bae829194bb29e1c7da872d4d311c82b1e Mon Sep 17 00:00:00 2001 From: mikejc Date: Thu, 6 Jun 2024 03:03:28 -0400 Subject: [PATCH 20/30] container tracking for vault books --- inventory-manager.lic | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 837362e849..f73459583d 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -197,10 +197,14 @@ class InventoryManager if item[0].eql? '-' item[0] = '' item.concat(" (in container - #{container})") - else - container = item.include?("eddy") ? "eddy" : DRC.get_noun(item) - if inventory_type == 'character' - item.concat(' (worn)') + elsif inventory_type == 'character' + container = (item.include?("eddy") ? "eddy" : item).to_s + item.concat(' (worn)') + elsif command == "read my vault book" + if line =~ /\s{6}(?:a|an|some) / + item.concat(" (in container - #{container})") + else + container = item.to_s end end From b281abe0f8f60d0444f501a516689dd89cb49908 Mon Sep 17 00:00:00 2001 From: Briarleigh <77058868+Kiriawen@users.noreply.github.com> Date: Thu, 6 Jun 2024 13:30:16 -0500 Subject: [PATCH 21/30] Update circlecheck.lic removing Utility from the barbarian restricted skills to bring CC inline with actual req's --- circlecheck.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circlecheck.lic b/circlecheck.lic index abec25212c..ac22ea55e1 100644 --- a/circlecheck.lic +++ b/circlecheck.lic @@ -339,7 +339,7 @@ $GuildReqs = { }, hard_reqs: ['Evasion', 'Parry Ability', 'Expertise', 'Inner Fire', 'Tactics'], - restricted: ['Sorcery', 'Thievery', 'Utility', 'Targeted Magic', 'Offhand Weapon'] + restricted: ['Sorcery', 'Thievery', 'Targeted Magic', 'Offhand Weapon'] }, 'Necromancer' => { From 22aa7727b1de05f8031e32f4e216ec20a0676413 Mon Sep 17 00:00:00 2001 From: mikejc Date: Thu, 6 Jun 2024 23:44:54 -0400 Subject: [PATCH 22/30] adding home inventory per request --- inventory-manager.lic | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index f73459583d..bdf598d923 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -24,7 +24,8 @@ class InventoryManager 'Page', 'Stored Deeds', 'Currently store', - 'Maximum:'] + 'Maximum:', + 'The home contains'] @active_character = Char.name.to_sym @item_db_path = "data/inventory.yaml" @@ -42,7 +43,8 @@ class InventoryManager { name: 'family_vault', regex: /family_vault/i, optional: true, description: "Rummages your family vault to save items NOTE: must be standing by your open vault." }, { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." }, { name: 'eddy', regex: /eddy/i, optional: true, description: "Save the contents of an eddy (HE 436 Gift)." }, - { name: 'scrolls', regex: /scrolls/i, optional: true, description: "Save spell scrolls tracked with sort-scrolls or stack-scrolls." } + { name: 'scrolls', regex: /scrolls/i, optional: true, description: "Save spell scrolls tracked with sort-scrolls or stack-scrolls." }, + { name: 'home', regex: /home/i, optional: true, description: "Save home inventory." } ], [ { name: 'search', regex: /search/i, description: 'Start a search across all characters for specified item.' }, @@ -78,6 +80,8 @@ class InventoryManager add_storage_box_inv elsif args.scrolls add_scrolls + elsif args.home + add_home elsif args.save add_current_inv elsif args.count @@ -206,6 +210,14 @@ class InventoryManager else container = item.to_s end + elsif inventory_type == "home" + if !item.start_with?("Attached:") + item = clean_home_string(item) + container = item.to_s + else + item = clean_home_string(item) + item.concat(" (attached to #{container})") + end end item.concat(" (#{inventory_type})") @@ -221,6 +233,11 @@ class InventoryManager end end + def clean_home_string(string) + colon = string.index(":") + 2 + string[colon..-2] + end + def add_vault_book_inv unless DRCI.get_item_if_not_held?("vault book") DRC.message("Unable to find your vault book, exiting!") @@ -309,6 +326,10 @@ class InventoryManager DRCI.close_container?("my #{stacker_container}") if @settings.scroll_sorter['close_container'] end + def add_home + check_inventory("home recall", /^The home contains:/, 'home') + end + def check_scroll_stacker(stacker) spells = [] capture = Lich::Util.issue_command("flip my #{stacker.split.last}", /^You flip through the #{stacker.split.last}, checking each section before closing it.$/) @@ -359,7 +380,7 @@ class InventoryManager DRC.message("Match #{total_found}): #{data}") end } - DRC.message("Found #{total_found} matches on #{k}\n") + DRC.message("Found #{total_found} match#{(total_found > 1 ? 'es' : '')} on #{k}\n") end end From fee24a7121706c7e2a6381ca2ffb33a1b8e68e76 Mon Sep 17 00:00:00 2001 From: BinuDR <36463075+BinuDR@users.noreply.github.com> Date: Thu, 6 Jun 2024 23:16:01 -0500 Subject: [PATCH 23/30] [script] bescort.lic - cleanup and added flying mount to ice road Did a bunch of clean up of code repetition of get_settings throughout the script. Changed the flying mount section to use `DRCI.get_item?()` and `DRCI.put_away_item?()` instead of `DRC.bput()` and `@equipment_manager.empty_hands`. Added flying mount functionality to the ice road. --- bescort.lic | 102 ++++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/bescort.lic b/bescort.lic index 70b8fb3105..2bac60a369 100644 --- a/bescort.lic +++ b/bescort.lic @@ -237,6 +237,7 @@ class Bescort @settings = get_settings @equipment_manager = EquipmentManager.new(@settings) + @flying_mount = @settings.flying_mount pause @@ -323,7 +324,7 @@ class Bescort mode = mode.downcase case mode when 'mount' - DRC.bput("get my #{type}", /You get/, /You pick up/, /You are already holding/, /What were you referring/) + DRCI.get_item?(type) case type when /broom|dirigible/i case DRC.bput("mount my #{type}", /You mount your/, /You are already mounted/, /What were you referring/) @@ -349,15 +350,14 @@ class Bescort case type when /broom|dirigible/i DRC.bput('dismount', /Your .* floats down to the ground/, /You climb off/) - @equipment_manager.empty_hands when /carpet|rug/i DRC.bput('dismount', /Your .* floats down to the ground/, /You climb off/) DRC.bput("roll #{type}", /You roll up/, /You can't roll/) - DRC.bput("stow my #{type}", /You put/, /You pick up/, /Stow what?/) else DRC.message("#{type} is not a valid type of flying mount.") exit end + DRCI.put_away_item?(type) end end @@ -468,18 +468,16 @@ class Bescort manual_go2(start_room) move('go stream bank') # Once in the stream then you're in a safe room, get mount or remove gear. - flying_mount = @settings.flying_mount @equipment_manager.empty_hands - have_changed_gear = flying_mount ? false : @equipment_manager.wear_equipment_set?('swimming') - if flying_mount - use_flying_mount(flying_mount, 'mount') + have_changed_gear = @flying_mount ? false : @equipment_manager.wear_equipment_set?('swimming') + if @flying_mount + use_flying_mount(@flying_mount, 'mount') move(moveset.first) # mount travels all three rooms at once else moveset.each { |dir| swim(dir) } end - use_flying_mount(flying_mount, 'dismount') if flying_mount + use_flying_mount(@flying_mount, 'dismount') if @flying_mount # While in the stream then you're in a safe room, dismount or wear gear. - @equipment_manager.empty_hands @equipment_manager.wear_equipment_set?('standard') if have_changed_gear move('go stream bank') # You're now among cave trolls! @@ -1076,13 +1074,12 @@ class Bescort end def faldesu(mode) - flying_mount = @settings.flying_mount unless mode =~ /haven|crossing/i echo 'You must specify haven or crossing for traversing the faldesu river' exit end - if flying_mount + if @flying_mount swim_faldesu(mode =~ /haven/i) return end @@ -1108,40 +1105,45 @@ class Bescort path = mode == 'shard' ? $ICE_PATH_SHARD : $ICE_PATH_HIB @equipment_manager.empty_hands - settings = get_settings - footwear = settings.footwear + footwear = @settings.footwear move_fast = false footwear_removed = false skates_worn = false - # If the footwear setting has been defined then respect that - # and only try to remove it. If you're not wearing this item - # then obviously nothing on your feet will be removed. - # You might: - # - have incorrect yaml - # - put something else on (or nothing on) - # - already wearing your skates - if footwear - if DRCI.remove_item?(footwear) - footwear_removed = true - DRCI.put_away_item?(footwear) + if @flying_mount + move_fast = true + use_flying_mount(@flying_mount, 'mount', 'glide') + path = mode == 'shard' ? %w[se se sw sw se] : %w[nw ne ne nw sw] + else + # If the footwear setting has been defined then respect that + # and only try to remove it. If you're not wearing this item + # then obviously nothing on your feet will be removed. + # You might: + # - have incorrect yaml + # - put something else on (or nothing on) + # - already wearing your skates + if footwear + if DRCI.remove_item?(footwear) + footwear_removed = true + DRCI.put_away_item?(footwear) + end end - end - # If you have some skates then try to get and wear them. - # Note, if you're already wearing the skates then we won't - # be able to "get" them, and that's why the attempt to wear - # is not conditional upon you getting them to your hands. - if DRCI.exists?('skates') - DRCI.get_item?('skates') - if DRCI.wear_item?('skates') - skates_worn = true - else - DRCI.put_away_item?('skates') + # If you have some skates then try to get and wear them. + # Note, if you're already wearing the skates then we won't + # be able to "get" them, and that's why the attempt to wear + # is not conditional upon you getting them to your hands. + if DRCI.exists?('skates') + DRCI.get_item?('skates') + if DRCI.wear_item?('skates') + skates_worn = true + else + DRCI.put_away_item?('skates') + end end - end - move_fast = skates_worn + move_fast = skates_worn + end # Despite our best efforts, if bescort starts moving you fast # and the game gives you warnings to slow down, SLOW DOWN! @@ -1174,6 +1176,10 @@ class Bescort DRCI.get_item?(footwear) DRCI.wear_item?(footwear) end + + if @flying_mount + use_flying_mount(@flying_mount, 'dismount') + end end def swim(dir) @@ -1183,13 +1189,12 @@ class Bescort end def swim_faldesu(north) - flying_mount = @settings.flying_mount start = north ? 1375 : 473 manual_go2(start) moveset = north ? %w[north northwest northeast] : %w[south southwest southeast] move 'dive river' - if flying_mount - use_flying_mount(flying_mount, 'mount') + if @flying_mount + use_flying_mount(@flying_mount, 'mount') if north move n move nw @@ -1198,8 +1203,7 @@ class Bescort move sw end move 'go bridge' - use_flying_mount(flying_mount, 'dismount') - @equipment_manager.empty_hands + use_flying_mount(@flying_mount, 'dismount') else swim(moveset[0]) while XMLData.room_exits.include?(moveset[0]) swim(moveset[1]) while XMLData.room_exits.include?('east') @@ -1477,9 +1481,8 @@ class Bescort end def segoltha(mode) - flying_mount = @settings.flying_mount @equipment_manager.empty_hands - have_changed_gear = flying_mount ? false : @equipment_manager.wear_equipment_set?('swimming') + have_changed_gear = @flying_mount ? false : @equipment_manager.wear_equipment_set?('swimming') move_count = 0 if mode =~ /^n/i dir_of_travel = 'north' @@ -1495,8 +1498,8 @@ class Bescort exit end - if flying_mount - use_flying_mount(flying_mount, 'mount', 'skim') + if @flying_mount + use_flying_mount(@flying_mount, 'mount', 'skim') if dir_of_travel == 'south' move 'go bank' move 'west' @@ -1511,7 +1514,7 @@ class Bescort move 'east' move 'go slope' end - use_flying_mount(flying_mount, 'dismount') + use_flying_mount(@flying_mount, 'dismount') return end @@ -1640,7 +1643,7 @@ class Bescort DRCA.release_cyclics unless DRCA.cast_spell({ 'abbrev' => 'rezz', 'mana' => 5, - 'cyclic' => true }, get_settings) + 'cyclic' => true }, @settings) echo('Failed to cast Resurrection! Try again or use the puzzle to enter.') exit end @@ -2014,7 +2017,6 @@ class Bescort def get_fare?(amount, town, room) return false unless @settings.bescort_fare_handling - settings = get_settings echo 'GETTING MONEY, YOU SLOB.' echo "Heading to #{town} for public transportation fare" pause 1 @@ -2025,7 +2027,7 @@ class Bescort echo 'You might be a necromancer! Get some money manually!' return false end - settings.hometown = town + @settings.hometown = town succeeded = false DRCM.minimize_coins(amount).each { |each_amount| succeeded = DRCM.get_money_from_bank(each_amount, settings) } echo "Put some fare money in the #{town} bank!" unless succeeded From 49b0fd829b724617b9c8c6603f8b15d7335b954f Mon Sep 17 00:00:00 2001 From: mikejc Date: Fri, 7 Jun 2024 15:37:22 -0400 Subject: [PATCH 24/30] added comments and some general cleanup --- inventory-manager.lic | 75 +++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index bdf598d923..a087254517 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -113,6 +113,9 @@ class InventoryManager @item_data = OpenStruct.new(YAML.load_file(@item_db_path)).to_h + # The legacy version of this script posted character inventory without an identifier. + # Adding a version check and 'upgrade' mechanism to fix these entries, otherwise they would exist + # forever unless the entire character was deleted. @version_string = 'version'.to_sym version = @item_data[@version_string][0] @@ -138,24 +141,43 @@ class InventoryManager end end + def get_item_data(inventory_type) + if @item_data[@active_character] + @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? "(#{inventory_type})" } + else + @item_data[@active_character] = [] + end + end + + def save_item_data(inventory_type) + DRC.message("Saving #{inventory_type} data for #{@active_character}!") + # .to_yaml limits to 80 chars by default, line_width: -1 bypasses this limit + File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml(line_width: -1)) } + end + def get_inv_count(desc) count, closed = 0, 0 - # Counting all items in inventory if desc.nil? - DRC.bput('inv list', 'You have:') - while (line = get) - break if line =~ /INVENTORY HELP/i - + # Counting all items in inventory + capture = Lich::Util.issue_command('inv list', /^You have:/) + capture.each do |line| item = line.lstrip + + next if item.empty? + next if item.start_with?(*@inventory_ignores) + count += 1 closed += 1 if item.match?(/(closed)/) end DRC.message("You have #{count} items, #{closed} of which are (closed) containers.") else # Counting items matching the description, i.e., inv count pouch - DRC.bput("inv search #{desc}", 'You rummage') - while (line = get) - break if line =~ /INVENTORY HELP/i + capture = Lich::Util.issue_command("inv search #{desc}", /rummage about your person/) + capture.each do |line| + item = line.lstrip + + next if item.empty? + next if item.start_with?(*@inventory_ignores) count += 1 end @@ -170,15 +192,12 @@ class InventoryManager using_sorter = true end - if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? "(#{inventory_type})" } - else - @item_data[@active_character] = [] - end + get_item_data(inventory_type) capture = Lich::Util.issue_command(command, end_pattern) lines = capture + # when rummaging, this block splits the items, including the last two that are split by and instead of a comma if command.start_with?("rummage") container = capture[0] lines = container[rummage_length, container.length - (rummage_length + 1)].split(",") @@ -198,13 +217,16 @@ class InventoryManager next if item.empty? next if item.start_with?(*@inventory_ignores) + # if the item starts with a -, it's in a container if item[0].eql? '-' item[0] = '' item.concat(" (in container - #{container})") elsif inventory_type == 'character' + # We don't want the inventory_type here as it's extra noise, so we do a .to_s so container doesn't get updated by changing item later container = (item.include?("eddy") ? "eddy" : item).to_s item.concat(' (worn)') elsif command == "read my vault book" + # When reading the vault book, items in a container are prefixed by 6 spaces if line =~ /\s{6}(?:a|an|some) / item.concat(" (in container - #{container})") else @@ -225,8 +247,7 @@ class InventoryManager @item_data[@active_character] << item end - DRC.message("Saving #{inventory_type} data for #{@active_character}!") - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml(line_width: -1)) } + save_item_data(inventory_type) if using_sorter start_script('sorter') unless Script.running?('sorter') @@ -234,6 +255,7 @@ class InventoryManager end def clean_home_string(string) + # We remove the category by finding the : in the string, plus drop the period at the end colon = string.index(":") + 2 string[colon..-2] end @@ -285,15 +307,11 @@ class InventoryManager def add_scrolls stacker_container = (@settings.scroll_sorter['stacker_container'] || @settings.stacker_container) unless stacker_container - DRC.message("You have no stacker_container defined for sort-scrolls!") + DRC.message("You have no stacker_container defined for sort-scrolls or stack-scrolls!") exit end - if @item_data[@active_character] - @item_data[@active_character] = @item_data[@active_character].select { |line| !line.include? "(spell_scroll)" } - else - @item_data[@active_character] = [] - end + get_item_data(spell_scroll) stacker = @settings.scroll_sorter['stacker'] scroll_stackers = @settings.scroll_stackers @@ -303,12 +321,14 @@ class InventoryManager spells = [] if stacker + # stacker is defined, so they're using sort-scrolls - get all ten books and parse them 10.times do DRCI.get_item_safe?("tenth #{stacker}", stacker_container) spells.concat(check_scroll_stacker(stacker)) DRCI.put_away_item?(stacker, stacker_container) end else + # no stacker variable, so they are using stack-scrolls. loop through their scroll stackers and parse them for scroll_stacker in scroll_stackers DRCI.get_item_safe?(scroll_stacker, stacker_container) spells.concat(check_scroll_stacker(scroll_stacker)) @@ -320,16 +340,11 @@ class InventoryManager @item_data[@active_character] << spell end - DRC.message("Saving spell_scroll data for #{@active_character}!") - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml(line_width: -1)) } + save_item_data(spell_scroll) DRCI.close_container?("my #{stacker_container}") if @settings.scroll_sorter['close_container'] end - def add_home - check_inventory("home recall", /^The home contains:/, 'home') - end - def check_scroll_stacker(stacker) spells = [] capture = Lich::Util.issue_command("flip my #{stacker.split.last}", /^You flip through the #{stacker.split.last}, checking each section before closing it.$/) @@ -343,6 +358,10 @@ class InventoryManager spells end + def add_home + check_inventory("home recall", /^The home contains:/, 'home') + end + def list_character_inv(name) if name.nil? DRC.message("There is inventory data for:") @@ -388,7 +407,7 @@ class InventoryManager return if name_to_remove == "version" @item_data.delete(name_to_remove.capitalize.to_sym) - File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml) } + File.open(@item_db_path, 'w') { |file| file.write(@item_data.to_yaml(line_width: -1)) } DRC.message("Removed #{name_to_remove.capitalize}'s data!") end end From d5ab2b902134f61267e77afead0979bbd313989c Mon Sep 17 00:00:00 2001 From: mikejc Date: Sat, 8 Jun 2024 17:21:34 -0400 Subject: [PATCH 25/30] add trader shops and shadow servants --- inventory-manager.lic | 90 ++++++++++++++++++++++++++++------------ profiles/base-empty.yaml | 1 + profiles/base.yaml | 25 +++++++++++ 3 files changed, 90 insertions(+), 26 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index a087254517..3847749b6a 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -6,27 +6,6 @@ custom_require.call(%w[common common-items]) class InventoryManager def initialize - @inventory_ignores = ['[', - '<', - 'Roundtime', - 'You have', - 'Vault Inventory', - 'Done', - 'The last note', - 'a brass hook', - 'a steel wire rack', - 'a small shelf', - 'a top drawer', - 'a middle drawer', - 'a bottom drawer', - 'a large shelf', - 'Inside a', - 'Page', - 'Stored Deeds', - 'Currently store', - 'Maximum:', - 'The home contains'] - @active_character = Char.name.to_sym @item_db_path = "data/inventory.yaml" @@ -44,7 +23,9 @@ class InventoryManager { name: 'register', regex: /register/i, optional: true, description: "Reads contents of deed register." }, { name: 'eddy', regex: /eddy/i, optional: true, description: "Save the contents of an eddy (HE 436 Gift)." }, { name: 'scrolls', regex: /scrolls/i, optional: true, description: "Save spell scrolls tracked with sort-scrolls or stack-scrolls." }, - { name: 'home', regex: /home/i, optional: true, description: "Save home inventory." } + { name: 'home', regex: /home/i, optional: true, description: "Save home inventory." }, + { name: 'servant', regex: /servant/i, optional: true, description: "Save shadow servant inventory." }, + { name: 'shop', regex: /shop/i, optional: true, description: "Save your Trader shop inventory." } ], [ { name: 'search', regex: /search/i, description: 'Start a search across all characters for specified item.' }, @@ -62,6 +43,7 @@ class InventoryManager args = parse_args(arg_definitions) @settings = get_settings + @inventory_ignores = @settings.inventory_manager_ignores setup @@ -82,6 +64,10 @@ class InventoryManager add_scrolls elsif args.home add_home + elsif args.servant + add_shadow_servant + elsif args.shop + add_trader_shop elsif args.save add_current_inv elsif args.count @@ -225,14 +211,14 @@ class InventoryManager # We don't want the inventory_type here as it's extra noise, so we do a .to_s so container doesn't get updated by changing item later container = (item.include?("eddy") ? "eddy" : item).to_s item.concat(' (worn)') - elsif command == "read my vault book" + elsif command == 'read my vault book' || inventory_type == 'shadow_servant' # When reading the vault book, items in a container are prefixed by 6 spaces if line =~ /\s{6}(?:a|an|some) / item.concat(" (in container - #{container})") else container = item.to_s end - elsif inventory_type == "home" + elsif inventory_type == 'home' if !item.start_with?("Attached:") item = clean_home_string(item) container = item.to_s @@ -311,7 +297,7 @@ class InventoryManager exit end - get_item_data(spell_scroll) + get_item_data('spell_scroll') stacker = @settings.scroll_sorter['stacker'] scroll_stackers = @settings.scroll_stackers @@ -340,7 +326,7 @@ class InventoryManager @item_data[@active_character] << spell end - save_item_data(spell_scroll) + save_item_data('spell_scroll') DRCI.close_container?("my #{stacker_container}") if @settings.scroll_sorter['close_container'] end @@ -362,6 +348,58 @@ class InventoryManager check_inventory("home recall", /^The home contains:/, 'home') end + def add_shadow_servant + unless DRStats.moon_mage? + DRC.message("You're not a Moon Mage!") + exit + end + + unless DRRoom.npcs.include?('Servant') + DRC.message("Your Shadow Servant isn't present.") + exit + end + + DRC.bput('prepare PG', 'You raise') + pause 3 + + check_inventory('cast servant', /^Within the belly/, 'shadow_servant') + end + + def add_trader_shop + unless DRStats.trader? + DRC.message("You're not a Trader!") + exit + end + + get_item_data('trader_shop') + + surfaces = Hash.new + capture = Lich::Util.issue_command("shop customer", /^The following items contain goods for sale:/) + capture.each do |line| + line = line.lstrip + + # this extracts the command from the shop surface and uses that to find what's on/in it + # because the surfaces aren't always just 'a glass table' (ex: a knotted flax cargo net) + # command looks like shop #123456789 + if line =~ /^(.*?)<\/d>/ + surfaces[Regexp.last_match(2)] = Regexp.last_match(1) + end + end + + for surface in surfaces + capture = Lich::Util.issue_command(surface[1], /, you see:/) + capture.each do |line| + line = line.lstrip + + if line =~ /^(.*?)<\/d>/ + @item_data[@active_character] << "#{Regexp.last_match(2)} (#{surface[0]}) (trader_shop)" + end + end + end + + save_item_data('trader_shop') + end + def list_character_inv(name) if name.nil? DRC.message("There is inventory data for:") diff --git a/profiles/base-empty.yaml b/profiles/base-empty.yaml index c1746a6385..2a4f750e55 100644 --- a/profiles/base-empty.yaml +++ b/profiles/base-empty.yaml @@ -62,6 +62,7 @@ empty_values: hunting_info: [] hunting_nemesis: [] ignored_npcs: [] + inventory_manager_ignores: [] lichbot_buffs: [] listen_skills: [] lockpick_buffs: {} diff --git a/profiles/base.yaml b/profiles/base.yaml index 3b9ba15824..ad61face91 100644 --- a/profiles/base.yaml +++ b/profiles/base.yaml @@ -2174,6 +2174,31 @@ sorter: sort_look_items_command: true ignore_categories: lootables|trash +# https://elanthipedia.play.net/Lich_script_repository#inventory-manager +inventory_manager_ignores: + - '[' + - '<' + - 'Roundtime' + - 'You have' + - 'Vault Inventory' + - 'Done' + - 'The last note' + - 'a brass hook' + - 'a steel wire rack' + - 'a small shelf' + - 'a top drawer' + - 'a middle drawer' + - 'a bottom drawer' + - 'a large shelf' + - 'Inside a' + - 'Page' + - 'Stored Deeds' + - 'Currently store' + - 'Maximum:' + - 'The home contains' + - 'Within the belly' + - 'Your Servant is holding' + stabbity: # Settings for script card-collector, defines bag to draw cards from(fresh) and bag to store duplicates and your case (duplicates) From 8afea6c52db87d691bd2191e38bc9eeeacdeeb53 Mon Sep 17 00:00:00 2001 From: mikejc Date: Sat, 8 Jun 2024 17:27:22 -0400 Subject: [PATCH 26/30] forcing rubocop to run again --- inventory-manager.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 3847749b6a..e54800d081 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -211,7 +211,7 @@ class InventoryManager # We don't want the inventory_type here as it's extra noise, so we do a .to_s so container doesn't get updated by changing item later container = (item.include?("eddy") ? "eddy" : item).to_s item.concat(' (worn)') - elsif command == 'read my vault book' || inventory_type == 'shadow_servant' + elsif (command == 'read my vault book' || inventory_type == 'shadow_servant') # When reading the vault book, items in a container are prefixed by 6 spaces if line =~ /\s{6}(?:a|an|some) / item.concat(" (in container - #{container})") From 1b955935cbd7045cb39a804515d797d0b257168b Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:02:33 +1200 Subject: [PATCH 27/30] Update inventory-manager.lic --- inventory-manager.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index e54800d081..36dab00811 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -386,7 +386,7 @@ class InventoryManager end end - for surface in surfaces + surfaces.each do |surface| capture = Lich::Util.issue_command(surface[1], /, you see:/) capture.each do |line| line = line.lstrip From 0678b459d5bdfbbc2ccee16204ad7135ce03f0c4 Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:02:43 +1200 Subject: [PATCH 28/30] Update inventory-manager.lic --- inventory-manager.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index 36dab00811..c53c52b25d 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -315,7 +315,7 @@ class InventoryManager end else # no stacker variable, so they are using stack-scrolls. loop through their scroll stackers and parse them - for scroll_stacker in scroll_stackers + scroll_stackers.each do |scroll_stacker| DRCI.get_item_safe?(scroll_stacker, stacker_container) spells.concat(check_scroll_stacker(scroll_stacker)) DRCI.put_away_item?(scroll_stacker, stacker_container) From ab838c9fb70e98428829dd96245eed0af10b4e9a Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:05:21 +1200 Subject: [PATCH 29/30] Update inventory-manager.lic --- inventory-manager.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index c53c52b25d..ea65722643 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -322,7 +322,7 @@ class InventoryManager end end - for spell in spells.sort + spells.sort.each do |spell| @item_data[@active_character] << spell end From 1c68c96b4601be81bc3062816938494cdf7f0e82 Mon Sep 17 00:00:00 2001 From: mikejc Date: Sat, 8 Jun 2024 18:06:54 -0400 Subject: [PATCH 30/30] updated syntax for three loops --- inventory-manager.lic | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inventory-manager.lic b/inventory-manager.lic index e54800d081..ea65722643 100644 --- a/inventory-manager.lic +++ b/inventory-manager.lic @@ -315,14 +315,14 @@ class InventoryManager end else # no stacker variable, so they are using stack-scrolls. loop through their scroll stackers and parse them - for scroll_stacker in scroll_stackers + scroll_stackers.each do |scroll_stacker| DRCI.get_item_safe?(scroll_stacker, stacker_container) spells.concat(check_scroll_stacker(scroll_stacker)) DRCI.put_away_item?(scroll_stacker, stacker_container) end end - for spell in spells.sort + spells.sort.each do |spell| @item_data[@active_character] << spell end @@ -386,7 +386,7 @@ class InventoryManager end end - for surface in surfaces + surfaces.each do |surface| capture = Lich::Util.issue_command(surface[1], /, you see:/) capture.each do |line| line = line.lstrip