diff --git a/info.lua b/info.lua index f3465f6..79cd248 100644 --- a/info.lua +++ b/info.lua @@ -46,7 +46,8 @@ function public.container_item(bag, slot) local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working? local tooltip = public.tooltip(function(tt) tt:SetBagItem(bag, slot) end) - local charges = private.item_charges(tooltip) + local max_charges = private.max_item_charges(item_id) + local charges = max_charges and private.item_charges(tooltip) local aux_quantity = charges or count return { @@ -67,7 +68,6 @@ function public.container_item(bag, slot) slot = item_info.slot, quality = item_info.quality, max_stack = item_info.max_stack, - aux_quantity = aux_quantity, count = count, locked = locked, @@ -75,7 +75,9 @@ function public.container_item(bag, slot) lootable = lootable, tooltip = tooltip, + max_charges = max_charges, charges = charges, + aux_quantity = aux_quantity, } end @@ -86,21 +88,20 @@ function public.auction_sell_item() local unit_vendor_price = vendor_price / count local tooltip = public.tooltip(function(tt) tt:SetAuctionSellItem() end) - local charges = private.item_charges(tooltip) - local aux_quantity = charges or count + local aux_quantity = charges > 1 and charges or count return { name = name, texture = texture, quality = quality, - aux_quantity = aux_quantity, stack_size = count, usable = usable, vendor_price = vendor_price, unit_vendor_price = unit_vendor_price, + tooltip = tooltip, - charges = charges, + aux_quantity = aux_quantity, } end end @@ -121,7 +122,8 @@ function public.auction(index, query_type) local duration = GetAuctionItemTimeLeft(query_type, index) local tooltip = public.tooltip(function(tt) tt:SetAuctionItem(query_type, index) end) - local charges = private.item_charges(tooltip) + local max_charges = private.max_item_charges(item_id) + local charges = max_charges and private.item_charges(tooltip) local aux_quantity = charges or count local blizzard_bid = high_bid > 0 and high_bid or start_price local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price @@ -161,7 +163,9 @@ function public.auction(index, query_type) sale_status = sale_status, duration = duration, usable = usable, + tooltip = tooltip, + max_charges = max_charges, charges = charges, aux_quantity = aux_quantity, } @@ -308,10 +312,6 @@ function public.tooltip(setter) end function private.item_charges(tooltip) - if public.tooltip_find(ITEM_SPELL_TRIGGER_ONUSE, tooltip) > 1 then -- it's presumably a recipe - return - end - for _, line in ipairs(tooltip) do local pattern1 = '^'..gsub(ITEM_SPELL_CHARGES, '%%d', '(%%d+)')..'$' local pattern2 = '^'..gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)')..'$' @@ -326,7 +326,33 @@ function private.item_charges(tooltip) if charges then return charges end - end + end + return 1 +end + +function private.max_item_charges(item_id) + return ({ + -- wizard oil + [20744] = 5, + [20746] = 5, + [20750] = 5, + [20749] = 5, + + -- mana oil + [20745] = 5, + [20747] = 5, + [20748] = 5, + + -- discombobulator + [4388] = 5, + + -- recombobulator + [4381] = 10, + [18637] = 10, + + -- ... TODO + + })[item_id] end function public.durability(tooltip) diff --git a/post_frame.lua b/post_frame.lua index 0bc533d..ec73e7a 100644 --- a/post_frame.lua +++ b/post_frame.lua @@ -20,8 +20,8 @@ function private.default_settings() stack_size = 1, start_price = 0, buyout_price = 0, - post_all = 1, - hidden = nil, + post_all = true, + hidden = false, } end @@ -554,7 +554,7 @@ function private.post_auctions() local unit_buyout_price = private.get_unit_buyout_price() local stack_size = private.stack_size_slider:GetValue() local stack_count - if private.post_all_checkbox:GetChecked() and not selected_item.charges then + if private.post_all_checkbox:GetChecked() and not selected_item.max_charges then stack_count = floor(selected_item.aux_quantity / stack_size) else stack_count = private.stack_count_slider:GetValue() @@ -578,7 +578,7 @@ function private.post_auctions() unit_start_price, unit_buyout_price, stack_count, - private.post_all_checkbox:GetChecked() and not selected_item.charges, + private.post_all_checkbox:GetChecked() and not selected_item.max_charges, function(posted, partial) local new_auction_record for i = 1, posted do @@ -619,7 +619,7 @@ function private.validate_parameters() return end - if private.stack_count_slider:GetValue() == 0 and (selected_item.charges or not private.post_all_checkbox:GetChecked()) then + if private.stack_count_slider:GetValue() == 0 and (selected_item.max_charges or not private.post_all_checkbox:GetChecked()) then private.post_button:Disable() return end @@ -696,13 +696,13 @@ function private.update_item_configuration() local deposit_factor = Aux.neutral and 0.25 or 0.05 local stack_size = private.stack_size_slider:GetValue() local stack_count - if private.post_all_checkbox:GetChecked() and not selected_item.charges then + if private.post_all_checkbox:GetChecked() and not selected_item.max_charges then stack_count = floor(selected_item.aux_quantity / stack_size) else stack_count = private.stack_count_slider:GetValue() end - local deposit = floor(selected_item.unit_vendor_price * deposit_factor * (selected_item.charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(private.duration_dropdown) / 120 - if private.post_all_checkbox:GetChecked() and not selected_item.charges then + local deposit = floor(selected_item.unit_vendor_price * deposit_factor * (selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(private.duration_dropdown) / 120 + if private.post_all_checkbox:GetChecked() and not selected_item.max_charges then local partial_stack = mod(selected_item.aux_quantity, stack_size) deposit = deposit + floor(selected_item.unit_vendor_price * deposit_factor * partial_stack) * UIDropDownMenu_GetSelectedValue(private.duration_dropdown) / 120 end @@ -728,7 +728,7 @@ end function private.quantity_update() if selected_item then - private.stack_count_slider:SetMinMaxValues(1, selected_item.charges and selected_item.availability[private.stack_size_slider:GetValue()] or floor(selected_item.availability[0] / private.stack_size_slider:GetValue())) + private.stack_count_slider:SetMinMaxValues(1, selected_item.max_charges and selected_item.availability[private.stack_size_slider:GetValue()] or floor(selected_item.availability[0] / private.stack_size_slider:GetValue())) end refresh = true end @@ -789,7 +789,7 @@ function private.set_item(item) private.hide_checkbox:SetChecked(settings.hidden) private.post_all_checkbox:SetChecked(settings.post_all) - private.stack_size_slider:SetMinMaxValues(1, selected_item.charges and 10 or selected_item.max_stack) + private.stack_size_slider:SetMinMaxValues(1, selected_item.max_charges or selected_item.max_stack) private.stack_size_slider:SetValue(settings.stack_size) private.quantity_update() private.stack_count_slider:SetValue(selected_item.aux_quantity) -- reduced to max possible @@ -836,9 +836,9 @@ function private.update_inventory_records() name = item_info.name, texture = item_info.texture, quality = item_info.quality, - charges = item_info.charges, aux_quantity = item_info.charges or item_info.count, max_stack = item_info.max_stack, + max_charges = item_info.max_charges, availability = availability, } else