Module:Shop: Difference between revisions

Fix buy limit game mode text, and add function to receive buy limits for certain game modes
(Use printError function)
(Fix buy limit game mode text, and add function to receive buy limits for certain game modes)
Line 52: Line 52:
elseif stat == 'buyLimit' then
elseif stat == 'buyLimit' then
return p._getPurchaseBuyLimit(purchase, not displayInline)
return p._getPurchaseBuyLimit(purchase, not displayInline)
elseif stat == 'buyLimitHardcore' then
return p._getPurchaseBuyLimitNumeric(purchase, 'melvorF:Hardcore')
elseif stat == 'description' then
elseif stat == 'description' then
return p._getPurchaseDescription(purchase)
return p._getPurchaseDescription(purchase)
Line 368: Line 370:
return p._getPurchaseContents(purchase, asList)
return p._getPurchaseContents(purchase, asList)
end
end
end
function p._getPurchaseBuyLimitNumeric(purchase, gamemodeID)
local buyLimit = (purchase.defaultBuyLimit > 0 and purchase.defaultBuyLimit)
if not Shared.tableIsEmpty(purchase.buyLimitOverrides) then
local gamemodeLimit = GameData.getEntityByProperty(purchase.buyLimitOverrides, 'gamemodeID', gamemodeID)
if gamemodeLimit ~= nil and gamemodeLimit.maximum ~= nil then
buyLimit = gamemodeLimit.maximum
end
end
return buyLimit
end
end


Line 383: Line 396:
             local gamemode = GameData.getEntityByID('gamemodes', buyLimit.gamemodeID)
             local gamemode = GameData.getEntityByID('gamemodes', buyLimit.gamemodeID)
             if gamemode ~= nil then
             if gamemode ~= nil then
local gamemodeName = Shared.splitString(gamemode.name, ' ')[1]
                 local gamemodeText = nil
                 local gamemodeText = nil
                 if Shared.contains(gamemodeHasIcon, gamemode.id) then
                 if Shared.contains(gamemodeHasIcon, gamemode.id) then
                     gamemodeText = Icons.Icon({gamemode.name, notext=(not asList or nil)})
                     gamemodeText = Icons.Icon({gamemodeName, notext=(not asList or nil)})
                 else
                 else
                     gamemodeText = '[[Game Mode#' .. gamemode.name .. '|' .. gamemode.name .. ']]'
                     gamemodeText = '[[Game Mode#' .. gamemodeName .. '|' .. gamemodeName .. ']]'
                 end
                 end
                 local limitText = (buyLimit.maximum == 0 and 'Unlimited') or Shared.formatnum(buyLimit.maximum)
                 local limitText = (buyLimit.maximum == 0 and 'Unlimited') or Shared.formatnum(buyLimit.maximum)