Skip to content

Commit

Permalink
Fixes #180, #181: Party Loot related issues, misc fixes (#182) (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mctalian authored Nov 11, 2024
1 parent d535a9e commit 69c87ad
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
9 changes: 8 additions & 1 deletion Features/ItemLoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ function ItemLoot.Element:new(...)
local t
element.key, t, element.icon, element.quantity, element.sellPrice, element.unit = ...

if not G_RLF.db.global.enablePartyLoot then
element.unit = nil
end

function element:isPassingFilter(itemName, itemQuality)
if not G_RLF.db.global.itemQualityFilter[itemQuality] then
element:getLogger():Debug(
Expand Down Expand Up @@ -119,7 +123,10 @@ function ItemLoot.Element:new(...)
element.secondaryTextFn = function(...)
if element.unit then
local name, server = UnitName(element.unit)
return " " .. name .. "-" .. server
if server then
return " " .. name .. "-" .. server
end
return " " .. name
end
local quantity = ...
if not element.sellPrice or element.sellPrice == 0 then
Expand Down
2 changes: 2 additions & 0 deletions Features/LootDisplayProperties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ G_RLF.LootDisplayProperties = {
"key",
"textFn",
"secondaryTextFn",
"unit",
"sellPrice",
"isLink",
"icon",
"quantity",
Expand Down
23 changes: 10 additions & 13 deletions Features/Reputation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,16 @@ function Rep.Element:new(...)
elseif element.repType == RepType.Paragon then
local currentValue, threshold, _, hasRewardPending, tooLowLevelForParagon =
C_Reputation.GetFactionParagonInfo(element.factionId)
if tooLowLevelForParagon then
normalRep()
else
if hasRewardPending then
local bagSize = G_RLF.db.global.fontSize
str = str .. "|A:ParagonReputation_Bag:" .. bagSize .. ":" .. bagSize .. ":0:0|a "
end
if currentValue ~= nil and currentValue > 0 then
str = str .. currentValue
end
if threshold ~= nil and threshold > 0 then
str = str .. "/" .. threshold
end

if hasRewardPending then
local bagSize = G_RLF.db.global.fontSize
str = str .. "|A:ParagonReputation_Bag:" .. bagSize .. ":" .. bagSize .. ":0:0|a "
end
if currentValue ~= nil and currentValue > 0 then
str = str .. currentValue
end
if threshold ~= nil and threshold > 0 then
str = str .. "/" .. threshold
end
else
normalRep()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ function LootDisplayRowMixin:Reset()
self.Icon:Reset()

self.UnitPortrait:SetTexture(nil)
self.SecondaryText:SetText(nil)

-- Reset amount text behavior
self.PrimaryText:SetScript("OnEnter", nil)
Expand Down Expand Up @@ -519,7 +520,7 @@ function LootDisplayRowMixin:UpdateWithHistoryData(data)
self.unit = data.unit
self.PrimaryText:SetText(data.rowText)
self.PrimaryText:SetTextColor(unpack(data.textColor))
if self.unit and data.secondaryText then
if self.unit and data.secondaryText and G_RLF.db.global.enabledSecondaryRowText then
self.secondaryText = data.secondaryText
self.SecondaryText:SetText(self.secondaryText)
end
Expand Down
6 changes: 4 additions & 2 deletions SmokeTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ local function runItemLootSmokeTest()
G_RLF:Print("Item not cached, skipping ItemLoot test")
else
runTestSafely(e.Show, "LootDisplay: Item", e, testObj.name, testObj.quality)
e = module.Element:new(testObj.id, testObj.link, testObj.icon, amountLooted)
e = module.Element:new(testObj.id, testObj.link, testObj.icon, amountLooted, testObj.sellPrice)
runTestSafely(e.Show, "LootDisplay: Item Quantity Update", e, testObj.name, testObj.quality)
e = module.Element:new(testObj.id, testObj.link, testObj.icon, amountLooted, nil, "player")
runTestSafely(e.Show, "LootDisplay: Item Unit", e, testObj.name, testObj.quality)
end
end

Expand Down Expand Up @@ -217,7 +219,7 @@ local function testLootDisplay()
local frame = LootDisplayFrame
assertEqual(frame ~= nil, true, "LootDisplayFrame")
C_Timer.After(G_RLF.db.global.fadeOutDelay + 3, function()
assertEqual(#frame.rowHistory, 5, "LootDisplayFrame: rowHistory")
assertEqual(#frame.rowHistory, 6, true, "LootDisplayFrame: rowHistory")
displayResults()
end)
end
Expand Down
8 changes: 8 additions & 0 deletions TestMode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ local function generateRandomLoot()
local e = module.Element:new(item.id, item.link, item.icon, amountLooted, item.sellPrice)
e:Show(item.name, item.quality)

-- 10% chance of iitem loot to show up as a party member
if rng < 0.3 then
local unit = "player"
local module = G_RLF.RLF:GetModule("ItemLoot")
local e = module.Element:new(item.id, item.link, item.icon, amountLooted, item.sellPrice, unit)
e:Show(item.name, item.quality)
end

-- 15% chance to show currency
elseif rng > 0.7 and rng <= 0.85 then
local currency = testCurrencies[math.random(#testCurrencies)]
Expand Down

0 comments on commit 69c87ad

Please sign in to comment.