Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.9.1 #205

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions Features/Currency.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,30 @@ function Currency.Element:new(...)

element.isLink = true

local t
element.key, t, element.icon, element.quantity, element.totalCount, element.quality, element.totalEarned, element.cappedQuantity =
...
local currencyLink, currencyInfo, basicInfo = ...

if not currencyLink or not currencyInfo or not basicInfo then
return
end

element.key = currencyInfo.currencyID
element.icon = currencyInfo.iconFileID
element.quantity = basicInfo.displayAmount
element.totalCount = currencyInfo.quantity
element.quality = currencyInfo.quality
element.totalEarned = currencyInfo.totalEarned
element.cappedQuantity = currencyInfo.maxQuantity

if element.key == Constants.CurrencyConsts.ACCOUNT_WIDE_HONOR_CURRENCY_ID then
element.totalCount = UnitHonorLevel("player")
element.cappedQuantity = UnitHonorMax("player")
element.totalEarned = UnitHonor("player")
currencyLink = currencyLink:gsub(currencyInfo.name, _G.LIFETIME_HONOR)
end

element.textFn = function(existingQuantity, truncatedLink)
if not truncatedLink then
return t
return currencyLink
end
return truncatedLink .. " x" .. ((existingQuantity or 0) + element.quantity)
end
Expand All @@ -36,13 +53,15 @@ function Currency.Element:new(...)
numerator = element.totalCount
percentage = element.totalCount / element.cappedQuantity
end
local color
if percentage < 0.7 then
color = "|cFFFFFFFF"
elseif percentage >= 0.7 and percentage < 0.9 then
color = "|cFFFF9B00"
else
color = "|cFFFF0000"
local color = "|cFFFFFFFF"
if element.key ~= Constants.CurrencyConsts.ACCOUNT_WIDE_HONOR_CURRENCY_ID then
if percentage < 0.7 then
color = "|cFFFFFFFF"
elseif percentage >= 0.7 and percentage < 0.9 then
color = "|cFFFF9B00"
else
color = "|cFFFF0000"
end
end

return " " .. color .. numerator .. " / " .. element.cappedQuantity .. "|r"
Expand Down Expand Up @@ -120,16 +139,7 @@ function Currency:Process(eventName, currencyType, quantityChange)

self:fn(function()
local basicInfo = C_CurrencyInfo.GetBasicCurrencyInfo(currencyType, quantityChange)
local e = self.Element:new(
info.currencyID,
C_CurrencyInfo.GetCurrencyLink(currencyType),
info.iconFileID,
basicInfo.displayAmount,
info.quantity,
info.quality,
info.totalEarned,
info.maxQuantity
)
local e = self.Element:new(C_CurrencyInfo.GetCurrencyLink(currencyType), info, basicInfo)
e:Show()
end)
end
Expand All @@ -146,12 +156,6 @@ function Currency:PERKS_PROGRAM_CURRENCY_AWARDED(eventName, quantityChange)
self:Process(eventName, currencyType, quantityChange)
end

-- Handle Lifetime Honor
-- LIFETIME_HONOR
-- Constants.CurrencyConsts.ACCOUNT_WIDE_HONOR_CURRENCY_ID
-- print(UnitHonorLevel("player"))
-- print(UnitHonor("player") .. "/" .. UnitHonorMax("player"))

hiddenCurrencies = {
[2918] = true,
[2919] = true,
Expand Down
23 changes: 3 additions & 20 deletions GameTesting/IntegrationTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,10 @@ local function runCurrencyIntegrationTest()
local module = G_RLF.RLF:GetModule("Currency")
local testObj = TestMode.testCurrencies[2]
local amountLooted = 1
local e = module.Element:new(
testObj.id,
testObj.link,
testObj.icon,
amountLooted,
testObj.quantity,
testObj.quality,
testObj.totalEarned,
testObj.maxQuantity
)
testObj.basicInfo.displayAmount = amountLooted
local e = module.Element:new(testObj.link, testObj.info, testObj.basicInfo)
runTestSafely(e.Show, "LootDisplay: Currency")
e = module.Element:new(
testObj.id,
testObj.link,
testObj.icon,
amountLooted,
testObj.quantity,
testObj.quality,
testObj.totalEarned,
testObj.maxQuantity
)
e = module.Element:new(testObj.link, testObj.info, testObj.basicInfo)
runTestSafely(e.Show, "LootDisplay: Currency Quantity Update")
end

Expand Down
22 changes: 4 additions & 18 deletions GameTesting/TestMode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,9 @@ local function initializeTestCurrencies()
local basicInfo = C_CurrencyInfo.GetBasicCurrencyInfo(id, 100)
if info and link and info.currencyID and info.iconFileID then
table.insert(TestMode.testCurrencies, {
id = info.currencyID,
link = link,
icon = info.iconFileID,
quantity = info.quantity,
quality = info.quality,
totalEarned = info.totalEarned,
maxQuantity = info.maxQuantity,
info = info,
basicInfo = basicInfo,
})
end
end
Expand Down Expand Up @@ -153,8 +149,7 @@ function TestMode:GET_ITEM_INFO_RECEIVED(eventName, itemID, success)
end
end

G_RLF:ProfileFunction(getItem, "getItem")(itemID)
-- getItem(itemID)
getItem(itemID)

if #self.testItems == #testItemIds and not anyPendingRequests() then
allItemsInitialized = true
Expand Down Expand Up @@ -210,16 +205,7 @@ local function generateRandomLoot()
local currency = TestMode.testCurrencies[math.random(#TestMode.testCurrencies)]
local amountLooted = math.random(1, 500)
local module = G_RLF.RLF:GetModule("Currency")
local e = module.Element:new(
currency.id,
currency.link,
currency.icon,
amountLooted,
currency.quantity,
currency.quality,
currency.totalEarned,
currency.maxQuantity
)
local e = module.Element:new(currency.link, currency.info, currency.basicInfo)
e:Show()

-- 10% chance to show reputation (least frequent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,14 @@ local function rowHighlightBorder(row)
fadeIn:SetFromAlpha(0)
fadeIn:SetToAlpha(1)
fadeIn:SetDuration(0.2)
fadeIn:SetSmoothing("IN_OUT")

local fadeOut = b.HighlightAnimation:CreateAnimation("Alpha")
fadeOut:SetFromAlpha(1)
fadeOut:SetToAlpha(0)
fadeOut:SetDuration(0.2)
fadeOut:SetStartDelay(0.3)
fadeOut:SetSmoothing("IN_OUT")
fadeOut:SetScript("OnFinished", function()
row:ResetHighlightBorder()
end)
Expand Down
32 changes: 24 additions & 8 deletions spec/Features/Currency_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,37 @@ describe("Currency module", function()

it("shows loot if the currency info is valid", function()
ns.db.global.currencyFeed = true
local info = {
currencyID = 123,
description = "An awesome currency",
iconFileID = 123456,
quantity = 5,
quality = 2,
}
local link = "|c12345678|Hcurrency:123|r"
local basicInfo = {
name = "Best Coin",
description = "An awesome currency",
icon = 123456,
quality = 2,
displayAmount = 2,
actualAmount = 2,
}
_G.C_CurrencyInfo.GetCurrencyInfo = function()
return {
currencyID = 123,
description = "An awesome currency",
iconFileID = 123456,
quantity = 5,
quality = 2,
}
return info
end
_G.GetCurrencyLink = function(currencyType)
return link
end
_G.GetBasicCurrencyInfo = function(currencyType, quantity)
return basicInfo
end

local newElement = spy.on(CurrencyModule.Element, "new")

CurrencyModule:CURRENCY_DISPLAY_UPDATE(_, 123, 5, 2)

assert.spy(newElement).was.called_with(_, 123, "|c12345678|Hcurrency:123|r", 123456, 2, 5, 2, nil, nil)
assert.spy(newElement).was.called_with(_, "|c12345678|Hcurrency:123|r", info, basicInfo)
assert.stub(ns.SendMessage).was.called()
end)
end)
6 changes: 6 additions & 0 deletions spec/common_stubs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ function common_stubs.stub_WoWGlobals(spy)
ItemQuality = { Legendary = 5 },
}

_G.Constants = {
CurrencyConsts = {
ACCOUNT_WIDE_HONOR_CURRENCY_ID = 1585,
},
}

_G.C_CVar = {
SetCVar = function() end,
}
Expand Down
Loading