Module:Common: Difference between revisions

Split purchase icon type derivation into own function, for referencing by other modules
(Update for v1.3)
(Split purchase icon type derivation into own function, for referencing by other modules)
Line 139: Line 139:
end
end


-- getPurchaseIcon: Accepts the same arguments as Icons.Icon(), except the first parameter is a
-- getPurchaseIconType: Given a purchase from shop dtaa, returns the icon type to be used within
-- shop purchase rather than the icon/linked page name
-- Icons.Icon() to retrieve the purchase's icon
function p.getPurchaseIcon(iconArgs)
function p.getPurchaseIconType(purchase)
local purchase = iconArgs[1]
local purchaseName = p.getPurchaseName(purchase)
local purchType = p.getPurchaseType(purchase)
local purchType = p.getPurchaseType(purchase)
local iconType = nil
if purchType == 'Item Bundle' then
if purchType == 'Item Bundle' then
local upgBundles = {
local upgBundles = {
Line 156: Line 153:
}
}
if Shared.contains(upgBundles, purchase.id) then
if Shared.contains(upgBundles, purchase.id) then
iconType = 'upgrade'
return 'upgrade'
else
else
iconType = 'item'
return 'item'
end
end
else
else
iconType = string.lower(purchType)
return string.lower(purchType)
end
end
end
-- getPurchaseIcon: Accepts the same arguments as Icons.Icon(), except the first parameter is a
-- shop purchase rather than the icon/linked page name
function p.getPurchaseIcon(iconArgs)
local purchase = iconArgs[1]
local purchaseName = p.getPurchaseName(purchase)
local iconType = p.getPurchaseIconType(purchase)
-- Amend iconArgs before passing to Icons.Icon()
-- Amend iconArgs before passing to Icons.Icon()
iconArgs[1] = purchaseName
iconArgs[1] = purchaseName