From 0ece4c54d2725967fa0ac962c3050bf83539588f Mon Sep 17 00:00:00 2001 From: mikejc Date: Tue, 4 Jun 2024 01:52:41 -0400 Subject: [PATCH 01/19] [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 02/19] 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 03/19] 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 04/19] 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 05/19] 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 06/19] 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 07/19] 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 08/19] 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 09/19] 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 10/19] 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 11/19] 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 22aa7727b1de05f8031e32f4e216ec20a0676413 Mon Sep 17 00:00:00 2001 From: mikejc Date: Thu, 6 Jun 2024 23:44:54 -0400 Subject: [PATCH 12/19] 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 49b0fd829b724617b9c8c6603f8b15d7335b954f Mon Sep 17 00:00:00 2001 From: mikejc Date: Fri, 7 Jun 2024 15:37:22 -0400 Subject: [PATCH 13/19] 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 14/19] 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 15/19] 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 16/19] 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 17/19] 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 18/19] 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 19/19] 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