From 0db8993ce2ce18b325d4d1d5daf5b90768f8b6e1 Mon Sep 17 00:00:00 2001 From: Mike Klobutcher <19937263+ThatRasputin@users.noreply.github.com> Date: Wed, 18 Dec 2024 00:28:30 -0500 Subject: [PATCH] I believe I found the issue causing the rummage error Ethun encountered. I had left something in regarding shops that I didn't think was interfering, and it wasn't in something else I did in my own, but looks like it was here. --- sorter.lic | 57 +----------------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/sorter.lic b/sorter.lic index d88f45b19..8cd026ced 100644 --- a/sorter.lic +++ b/sorter.lic @@ -31,17 +31,6 @@ class Sorter sorted_items = sort_items(items) @use_table ? display_table(sorted_items, container_name) : display_default(sorted_items, container_name) nil # Suppress the original line output - elsif line =~ /^On (?:an?|the) (.*?), you see:/ - container_name = $1.strip - shop_items = [] - while (item_line = get) !~ /\[Type SHOP \[GOOD\] or click an item to see some details about it\.\]/ - if item_line =~ /(.*?)<\/d>/ - shop_items << $1.strip - end - end - sorted_items = sort_shop_items(shop_items) - display_shop_table(sorted_items, container_name) - nil else line # Allow non-matching lines to pass through end @@ -64,7 +53,6 @@ class Sorter clean_item = item.sub(/^\s*?\b(?:a|an|some|and|the)\b\s/, '').chomp('.').strip noun = DRC.get_noun(clean_item) type = get_item_type(clean_item, noun) - if sorted[type] if sorted[type][clean_item] sorted[type][clean_item][:qty] += 1 @@ -78,38 +66,15 @@ class Sorter sorted end - def sort_shop_items(items) - sorted = {} - items.each do |item| - if item =~ /(.*) for (.*?) (.*?) Kronars$/ - full_description = $1.strip - price = $2 - currency = $3 - clean_item = full_description.sub(/^\s*?\b(?:a|an|some|and|the)\b\s/, '') - noun = DRC.get_noun(clean_item) - type = get_item_type(clean_item, noun) - sorted[type] ||= {} - sorted[type][clean_item] = { - noun: noun, - price: "#{price} #{currency}", - full_description: full_description - } - end - end - sorted - end - def get_item_type(item, noun) item_data = get_data('sorting').to_h.merge(get_data('items').to_h) category = 'Other' - item_data.each do |key, value| if noun =~ /#{value.join('$|').concat('$')}/i || item =~ /(?:#{value.join('$|').concat('$')})/i category = key.to_s.sub(/_nouns|_types/, '').capitalize break end end - category end @@ -117,46 +82,26 @@ class Sorter table = Terminal::Table.new do |t| t.title = "Contents of #{container_name.strip}" t.style = { border_x: "-", border_i: "+", border_y: "|" } - if sorted_items.empty? t << [{ value: "This container is empty", alignment: :center, colspan: 2 }] else t.headings = ['Item', 'Qty.'] sorted_types = sorted_items.keys.sort_by { |type| type == "Other" ? [1, type] : [0, type] } - sorted_types.each do |type| items = sorted_items[type] t << :separator t << [{ value: type.strip, alignment: :center, colspan: 2 }] t << :separator - items.each do |data| + items.each do |item, data| t << [data[:full_description].strip, data[:qty]] end end end end - table_string = table.to_s.gsub('[[MONSTERBOLD]]', monsterbold_start).gsub('[[/MONSTERBOLD]]', monsterbold_end) Lich::Messaging.mono(table_string) end - def display_shop_table(sorted_items, container_name) - table = Terminal::Table.new do |t| - t.title = "Items for sale on #{container_name}" - t.headings = ['Item', 'Type', 'Price'] - sorted_items.each do |type, items| - t << :separator - t << [{ value: type, alignment: :center, colspan: 3 }] - t << :separator - items.each do |data| - t << [data[:full_description], data[:noun], data[:price]] - end - end - end - - Lich::Messaging.mono(table.to_s) - end - def display_default(sorted_items, container_name) output = "#{container_name}:\n" sorted_items.sort.each do |category_name, category_contents|