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

Add warband currency support #5229

Merged
merged 12 commits into from
Nov 12, 2024
51 changes: 51 additions & 0 deletions WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5126,6 +5126,57 @@ Private.GetCurrencyInfoForTrigger = function(trigger)
end
end

Private.ExecEnv.GetCurrencyAccountInfo = function(currencyId)
local currencyInfo = C_CurrencyInfo.GetCurrencyInfo(currencyId)

-- Gather currency data for account characters
if WeakAuras.IsRetail() and currencyInfo and currencyInfo.isAccountTransferable then
local dataReady = C_CurrencyInfo.IsAccountCharacterCurrencyDataReady()
local accountCurrencyData = dataReady and C_CurrencyInfo.FetchCurrencyDataFromAccountCharacters(currencyId)

if dataReady and accountCurrencyData then
currencyInfo.accountQuantity = currencyInfo.quantity
currencyInfo.realAccountQuantity = currencyInfo.quantity
if currencyInfo.transferPercentage then
currencyInfo.realCharacterQuantity = math.floor(currencyInfo.quantity * (currencyInfo.transferPercentage / 100))
end

currencyInfo.accountCurrencyData = accountCurrencyData
for _, currencyData in ipairs(currencyInfo.accountCurrencyData) do
if currencyData.quantity then
if currencyInfo.transferPercentage then
currencyData.realCharacterQuantity = math.floor(currencyData.quantity * (currencyInfo.transferPercentage / 100))
end
currencyInfo.realAccountQuantity = currencyInfo.realAccountQuantity + (currencyData.realCharacterQuantity or currencyData.quantity)
currencyInfo.accountQuantity = currencyInfo.accountQuantity + currencyData.quantity
end
end
else
C_CurrencyInfo.RequestCurrencyDataForAccountCharacters()
end
end

-- WORKAROUND https://github.com/WeakAuras/WeakAuras2/issues/5106
if currencyInfo and WeakAuras.IsCataClassic() then
if currencyInfo.quantityEarnedThisWeek then
currencyInfo.quantityEarnedThisWeek = currencyInfo.quantityEarnedThisWeek / 100
end
end

if currencyInfo then
currencyInfo.capped = currencyInfo.maxQuantity and currencyInfo.maxQuantity > 0 and currencyInfo.quantity >= currencyInfo.maxQuantity
currencyInfo.seasonCapped = currencyInfo.maxQuantity and currencyInfo.maxQuantity > 0 and currencyInfo.useTotalEarnedForMaxQty and currencyInfo.totalEarned >= currencyInfo.maxQuantity
currencyInfo.weeklyCapped = currencyInfo.maxWeeklyQuantity and currencyInfo.maxWeeklyQuantity > 0 and currencyInfo.quantityEarnedThisWeek >= currencyInfo.maxWeeklyQuantity
end

if not currencyInfo then
currencyInfo = C_CurrencyInfo.GetCurrencyInfo(1) --Currency Token Test Token 4
currencyInfo.iconFileID = "Interface\\Icons\\INV_Misc_QuestionMark" --We don't want the user to think their input was valid
end

return currencyInfo
end


local types = {}
tinsert(types, "custom")
Expand Down
Loading