Skip to content

Commit

Permalink
Merge branch 'rpherbig:master' into desertkaz-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
desertkaz authored Jul 15, 2024
2 parents 1fb19e9 + e4df590 commit b50c320
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
32 changes: 25 additions & 7 deletions inventory-manager.lic
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ class InventoryManager
],
[
{ name: 'search', regex: /search/i, description: 'Start a search across all characters for specified item.' },
{ name: 'item', regex: /\w+/i, optional: false, description: 'Item to find.' }
{ name: 'item', regex: /\w+/i, optional: false, description: 'Item to find.' },
{ name: 'nest', regex: /nest|-n/i, optional: true, description: 'Print the nesting container data', default: false }
],
[
{ name: 'list', regex: /list/i, description: "Print out a list of names in the database." },
{ name: 'name', regex: /\w+/i, optional: true, description: "List full inventory for specified character. (Can spam!)" }
{ name: 'name', regex: /\w+/i, optional: true, description: "List full inventory for specified character. (Can spam!)" },
{ name: 'nest', regex: /nest|-n/i, optional: true, description: 'Print the nesting container data', default: false }
],
[
{ name: 'remove', regex: /remove/i, description: "Remove character's inventory." },
Expand Down Expand Up @@ -84,9 +86,9 @@ class InventoryManager
elsif args.remove
remove_character_data(args.name)
elsif args.search
search_for_item(args.item)
search_for_item(args.item, args.nest)
elsif args.list
list_character_inv(args.name)
list_character_inv(args.name, args.nest)
else
DRC.message('Type ;inventory-manager help for a usage guide')
end
Expand Down Expand Up @@ -471,7 +473,7 @@ class InventoryManager
save_item_data('trader_shop')
end

def list_character_inv(name)
def list_character_inv(name, nested)
if name.nil?
DRC.message("There is inventory data for:")
@item_data.each do |k, v|
Expand All @@ -489,20 +491,28 @@ class InventoryManager
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}") }
@item_data[name_sym].each { |item|
if !nested
item = strip_nesting(item)
end
DRC.message(" - #{item}")
}
else
DRC.message("No data found for the character #{name.capitalize}!")
end
end

def search_for_item(item)
def search_for_item(item, nested)
total_found = 0
@item_data.each do |k, v|
next if k == @version_string

total_found = 0
DRC.message("Checking #{k}:")
v.each { |data|
if !nested
data = strip_nesting(data)
end
if data.downcase.include?(item)
total_found += 1
DRC.message("Match #{total_found}): #{data}")
Expand All @@ -512,6 +522,14 @@ class InventoryManager
end
end

def strip_nesting(item)
if (match = /^(?<tap>[a-z "':!-]*(?<closed>\(closed\))?)\s\((?<nest1>(?<nest2>nested container[A-Za-z "':!-]*)\s\()?(?<main>in container[a-z '-]*)\)?\)\s(?<origin>\(.*\))$/i.match(item))
return "#{match["tap"]} #{match["origin"]}"
else
return item
end
end

def remove_character_data(name_to_remove)
return if name_to_remove == "version"

Expand Down
2 changes: 1 addition & 1 deletion textsubs.lic
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ end

# Commas when dealing with coins
if settings.textsubs_use_plat_grouping
TextSubs.add('(?!.*>)\d{1,3}(?=(\d{4})+(?!\d)(?! platinum).*(Kronar|Dokora|Lirum))', '\&,')
TextSubs.add('(?!.*>)\d{1,3}(?=((\d{3})*(\d{4}))(?!\d)(?! platinum).*(Kronar|Dokora|Lirum))', '\&,')
TextSubs.add('(?!.*>)\d{1,3}(?=(\d{3})+(?!\d) platinum.*(Kronar|Dokora|Lirum))', '\&,')
else
TextSubs.add('(?!.*>)\d{1,3}(?=(\d{3})+(?!\d).*(Kronar|Dokora|Lirum))', '\&,')
Expand Down

0 comments on commit b50c320

Please sign in to comment.