Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:PrizePool: Difference between revisions

From eSportsAmaze
Created page with "local p = {} local cargo = mw.ext.cargo local html = mw.html local lang = mw.getLanguage('en') -- Helper: Format Number with Commas (Indian Locale is handled by your JS, we just output raw number wrapped in span) local function formatCurrency(amount) if not amount then return "0" end -- We output the raw number inside the span. Your MediaWiki:Common.js 'indian-currency' script -- picks this up and adds the ₹ symbol and correct commas automatically. re..."
 
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}
local _id_counter = 0
local html = mw.html
local cargo = mw.ext.cargo
local cargo = mw.ext.cargo
local html = mw.html
local lang = mw.getLanguage('en')


-- Helper: Format Number with Commas (Indian Locale is handled by your JS, we just output raw number wrapped in span)
-- ============================================================
local function formatCurrency(amount)
-- HELPER: Number Formatters
-- ============================================================
 
-- Indian Format (1,00,000)
local function formatINR(amount)
    if not amount then return "0" end
    local n = tostring(math.floor(tonumber(amount) or 0))
    if #n <= 3 then return n end
    local last3 = n:sub(-3)
    local rest = n:sub(1, -4)
    -- Indian format: group remaining digits in pairs (from right)
    local formattedRest = rest:reverse():gsub("(%d%d)", "%1,"):reverse():gsub("^,", "")
    return formattedRest .. "," .. last3
end
 
-- Standard Format (100,000) - For USD, Yen, etc.
local function formatStd(amount)
     if not amount then return "0" end
     if not amount then return "0" end
     -- We output the raw number inside the span. Your MediaWiki:Common.js 'indian-currency' script
     local n = tostring(math.floor(tonumber(amount) or 0))
    -- picks this up and adds the ₹ symbol and correct commas automatically.
     return n:reverse():gsub("(%d%d%d)", "%1,"):reverse():gsub("^,", "")
     return '<span class="indian-currency">' .. amount .. '</span>'
end
end


-- Function 1: Display a Prize Row (for Tournament Pages)
-- ============================================================
function p.row(frame)
-- HELPER: Dual Currency Display & Calc
     local args = frame:getParent().args
-- ============================================================
    local place = args.place or "0"
-- Returns: { displayHTML, valueForDatabase (INR) }
     local money = args.money or "0"
local function processMoney(amount, currency, rate)
     local recipient = args.recipient or ""
     if not amount or amount == "" or amount == "0" then
     local team = args.recipient_team or args.team or ""
        return { display = "TBD", dbValue = 0 }
    end
 
     local val = 0
     local r = tonumber(rate) or 1
     local symbol = currency or ""
      
      
     local root = html.create('tr')
     if type(amount) == "string" then
   
        val = tonumber((amount:gsub(",", ""))) or 0
    -- 1. Rank Cell
     else
    local rankCell = root:tag('td'):addClass('col-rank')
        val = tonumber(amount) or 0
    if place == '1' then rankCell:wikitext('🏆')
    elseif place == '2' then rankCell:wikitext('🥈')
    elseif place == '3' then rankCell:wikitext('🥉')
     else rankCell:tag('span'):addClass('prize-rank-number'):wikitext('#' .. place)
     end
     end
      
      
     -- 2. Money Cell
     -- Case 1: Input is INR (Primary = INR, Secondary = USD)
    root:tag('td'):addClass('col-money'):wikitext(formatCurrency(money))
    if symbol == "₹" or symbol == "INR" or symbol == "Rs" then
        local inrVal = val
        local usdVal = val * r -- Rate should be e.g. 0.011
       
        local mainStr = "₹ " .. formatINR(inrVal)
        local subStr = ""
       
        if r ~= 1 then
            subStr = '<br><small style="color:var(--text-muted); font-size:0.85em;">≈ $ ' .. formatStd(usdVal) .. '</small>'
        end
       
        return {
            display = '<span class="pz-val">' .. mainStr .. subStr .. '</span>',
            dbValue = inrVal
        }
      
      
     -- 3. Team/Recipient Cell
     -- Case 2: Input is Foreign (Primary = Foreign, Secondary = INR)
    local teamCell = root:tag('td'):addClass('col-team')
    else
     local flexDiv = teamCell:tag('div'):addClass('prize-team-flex')
        local localVal = val
        local inrVal = val * r -- Rate should be e.g. 90 (1 Unit = 90 INR)
       
        local mainStr = symbol .. " " .. formatStd(localVal)
        local subStr = '<br><small style="color:var(--text-muted); font-size:0.85em;">≈ ₹ ' .. formatINR(inrVal) .. '</small>'
       
        return {
            display = '<span class="pz-val">' .. mainStr .. subStr .. '</span>',
            dbValue = inrVal
        }
    end
end
 
-- Helper: Get Logo
local function getLogo(teamName)
    if not teamName or teamName == "" or teamName == "TBD" then return "" end
     local clean = teamName:gsub("'", "")
    local light = clean .. '.png'
    local dark = clean .. '_dark.png'
      
      
    -- Logo Logic
     local container = html.create('span')
     local logoName = (team ~= "" and team) or recipient
    local logoFile = logoName .. '.png'
    local logoBox = flexDiv:tag('span'):addClass('prize-logo-box')
      
      
     if mw.title.new('File:' .. logoFile).exists then
     if mw.title.new('File:' .. light).exists then
         logoBox:wikitext('[[File:' .. logoFile .. '|30px|link=' .. logoName .. ']]')
         container:wikitext('[[File:' .. light .. '|link=|class=logo-lightmode]]')
     else
     else
         logoBox:wikitext('[[File:Shield_team.png|30px|link=' .. logoName .. ']]')
         container:wikitext('[[File:Shield_team.png|link=|class=logo-lightmode]]')
     end
     end
      
      
    -- Name Logic
     if mw.title.new('File:' .. dark).exists then
     if recipient ~= "" then
         container:wikitext('[[File:' .. dark .. '|link=|class=logo-darkmode]]')
         flexDiv:tag('span'):addClass('prize-team-name'):wikitext('[[' .. recipient .. ']]')
    elseif mw.title.new('File:' .. light).exists then
        container:wikitext('[[File:' .. light .. '|link=|class=logo-darkmode]]')
     else
     else
         flexDiv:tag('span'):addClass('prize-team-name'):css('color','#888'):css('font-style','italic'):css('padding-left','5px'):wikitext('TBD')
         container:wikitext('[[File:Shield_team_dark.png|link=|class=logo-darkmode]]')
     end
     end
      
      
     return tostring(root)
     return tostring(container)
end
end


-- Function 2: Team History Table (For Team Pages)
function p.main(frame)
function p.history(frame)
     local args = frame:getParent().args
     local args = frame:getParent().args
    local teamName = args.team or mw.title.getCurrentTitle().text
      
      
     -- Query Cargo
     -- Global Settings
     local tables = "Tournament_Prizes"
     local currency = args.currency or ""
     local fields = "tournament, place, money"
     local rate = tonumber(args.rate) or 1
     local queryArgs = {
   
         where = "recipient = '" .. teamName .. "' OR recipient_team = '" .. teamName .. "'",
    local tournamentName = args.tournament or mw.title.getCurrentTitle().subpageText
         orderBy = "money DESC",
   
         limit = 50
    -- PRE-CHECK: Are there any awards?
     }
     local hasAnyAwards = false
    for i = 1, 20 do
         if args['award_' .. i] and args['award_' .. i] ~= "" then
            hasAnyAwards = true
            break
        end
    end
 
    -- Unique IDs for Toggling
    _id_counter = _id_counter + 1
    local uniqueID = "pp-" .. _id_counter
    local idContent = 'content-' .. uniqueID
    local idBtnShow = 'btn-show-' .. uniqueID
    local idBtnHide = 'btn-hide-' .. uniqueID
   
    local grid = html.create('div'):addClass('prize-section-grid')
   
    -- Adjust grid columns if no awards (Full width ranking)
    if not hasAnyAwards then
        grid:css('grid-template-columns', '1fr')
    end
   
    -- ==========================================
    -- COLUMN 1: RANKINGS (TEAMS)
    -- ==========================================
    local colRank = grid:tag('div'):addClass('prize-col-rank')
    colRank:tag('div'):addClass('prize-header'):wikitext('Prize Pool Distribution')
   
    local rankList = colRank:tag('div'):addClass('prize-list')
    local hasRankData = false
    local rankCount = 0
   
    for i = 1, 64 do
         if (args['team_'..i] and args['team_'..i] ~= "") or (args['prize_'..i] and args['prize_'..i] ~= "") then
            rankCount = rankCount + 1
         end
     end
      
      
     local results = cargo.query(tables, fields, queryArgs)
     local collapseLimit = 10
    local isCollapsible = (rankCount > collapseLimit)
      
      
     local container = html.create('div')
     local hiddenDiv = nil
    if isCollapsible then
        hiddenDiv = html.create('div')
            :addClass('mw-collapsible mw-collapsed')
            :attr('id', 'mw-customcollapsible-' .. idContent)
    end
      
      
     -- A. Calculate Total Earnings
     for i = 1, 64 do
    local totalMoney = 0
        local place = args['place_'..i] or (i .. '.')
    if #results > 0 then
        local team = args['team_'..i]
        for _, row in ipairs(results) do
        local rawPrize = args['prize_'..i]
             totalMoney = totalMoney + (tonumber(row.money) or 0)
        local seed = args['seed_'..i]
       
        if (team and team ~= "") or (rawPrize and rawPrize ~= "") then
            hasRankData = true
           
            -- Process Money (Display + DB Value)
            local moneyData = processMoney(rawPrize, currency, rate)
           
            -- DATABASE STORE (Always store INR value)
            if team and team ~= "" and cargo and cargo.store then
                cargo.store('PrizeMoney', {
                    tournament = tournamentName,
                    placement = i,
                    team = team,
                    prize = moneyData.dbValue, -- STORES INR
                    award = ''
                })
            end
           
            local targetContainer = rankList
            if isCollapsible and i > collapseLimit then
                targetContainer = hiddenDiv
            end
           
            local row = targetContainer:tag('div'):addClass('prize-row')
           
            local rankClass = 'rank-other'
            local rankIcon = place
            if i == 1 then rankClass = 'rank-1'; rankIcon = '🥇' end
            if i == 2 then rankClass = 'rank-2'; rankIcon = '🥈' end
            if i == 3 then rankClass = 'rank-3'; rankIcon = '🥉' end
           
            row:addClass(rankClass)
            row:tag('div'):addClass('pz-rank'):wikitext(rankIcon)
           
            local teamDiv = row:tag('div'):addClass('pz-team')
           
            if team and team ~= "" then
                teamDiv:wikitext(getLogo(team))
                teamDiv:wikitext('[[' .. team .. ']]')
            else
                teamDiv:wikitext('TBD'):css('color', 'var(--text-muted)'):css('font-weight', 'normal')
            end
           
            local infoDiv = row:tag('div'):addClass('pz-info')
              
            -- Prize Display
            if rawPrize and rawPrize ~= "" then
                infoDiv:tag('div'):addClass('pz-prize'):wikitext(moneyData.display)
            end
           
            if seed and seed ~= "" then
                infoDiv:tag('span'):addClass('pz-seed'):wikitext(seed)
            end
         end
         end
     end
     end
      
      
     -- B. Display Summary Box
     if not hasRankData then
    container:tag('div')
        rankList:tag('div'):addClass('prize-empty')
        :css('background', 'var(--bg-header)')
            :wikitext('<i class="fa-solid fa-trophy"></i><br>Prize Pool TBD')
         :css('padding', '10px')
    else
        :css('border', '1px solid var(--border-main)')
         if isCollapsible then
        :css('border-radius', '6px')
            rankList:wikitext(tostring(hiddenDiv))
        :css('margin-bottom', '10px')
            local toggleTargets = 'mw-customtoggle-' .. idContent .. ' mw-customtoggle-' .. idBtnShow .. ' mw-customtoggle-' .. idBtnHide
        :css('width', '100%')
           
        :css('max-width', '500px')
            colRank:tag('div')
         :css('font-weight', 'bold')
                :attr('id', 'mw-customcollapsible-' .. idBtnShow)
        :css('text-align', 'center')
                :addClass('prize-show-more mw-collapsible ' .. toggleTargets)  
         :css('font-size', '1.1em')
                :wikitext('View Full Distribution <i class="fa-solid fa-chevron-down"></i>')
        :wikitext('Total Estimated Earnings: ' .. formatCurrency(totalMoney))
               
            colRank:tag('div')
                :attr('id', 'mw-customcollapsible-' .. idBtnHide)
                :addClass('prize-show-more mw-collapsible mw-collapsed ' .. toggleTargets)
                :wikitext('Show Less <i class="fa-solid fa-chevron-up"></i>')
         end
    end
   
    -- ==========================================
    -- COLUMN 2: SPECIAL AWARDS (Conditionally Rendered)
    -- ==========================================
    if hasAnyAwards then
        local colAward = grid:tag('div'):addClass('prize-col-award')
         colAward:tag('div'):addClass('prize-header'):wikitext('Special Awards')
          
          
    -- C. Display History Table
        local awardList = colAward:tag('div'):addClass('prize-list')
    local tbl = container:tag('table')
        :addClass('wikitable flat-table sortable')
        :css('width', '100%')
        :css('max-width', '600px')
        :css('text-align', 'center')
          
          
    local header = tbl:tag('tr')
        for i = 1, 20 do
    header:tag('th'):css('text-align', 'left'):wikitext('Tournament')
            local awardName = args['award_'..i]
    header:tag('th'):wikitext('Ranked')
            local winner = args['award_'..i..'_winner']
    header:tag('th'):css('text-align', 'right'):wikitext('Prize Money')
            local team = args['award_'..i..'_team']
   
            local rawPrize = args['award_'..i..'_prize']
    if #results > 0 then
           
        for _, row in ipairs(results) do
            if awardName and awardName ~= "" then
            local tr = tbl:tag('tr')
               
            tr:tag('td'):css('text-align', 'left'):css('font-weight', 'bold'):wikitext('[[' .. row.tournament .. ']]')
                local moneyData = processMoney(rawPrize, currency, rate)
            tr:tag('td'):wikitext("'''" .. row.place .. "'''")
               
            tr:tag('td'):css('text-align', 'right'):wikitext(formatCurrency(row.money))
                if (winner or team) and cargo and cargo.store then
                    cargo.store('PrizeMoney', {
                        tournament = tournamentName,
                        placement = '',
                        team = team or '',
                        player = winner or '',
                        prize = moneyData.dbValue, -- STORES INR
                        award = awardName
                    })
                end
               
                local row = awardList:tag('div'):addClass('award-row')
               
                local info = row:tag('div'):addClass('award-info')
                info:tag('div'):addClass('award-name'):wikitext(awardName)
               
                local winDiv = info:tag('div'):addClass('award-winner')
               
                if winner and winner ~= "" then
                    if team and team ~= "" then winDiv:wikitext(getLogo(team)) end
                    winDiv:wikitext('[[' .. winner .. ']]')
                elseif team and team ~= "" then
                    winDiv:wikitext(getLogo(team))
                    winDiv:wikitext('[[' .. team .. ']]')
                else
                    winDiv:wikitext("TBD"):css('color', 'var(--text-muted)'):css('font-weight', 'normal')
                end
               
                if rawPrize and rawPrize ~= "" then
                    row:tag('div'):addClass('award-prize'):wikitext(moneyData.display)
                end
            end
         end
         end
    else
        container:tag('div'):css('padding','15px'):css('color','#666'):wikitext('No prize data recorded yet.')
     end
     end
      
      
     return tostring(container)
     return tostring(grid)
end
end


return p
return p

Latest revision as of 14:36, 12 March 2026

Documentation for this module may be created at Module:PrizePool/doc

local p = {}
local _id_counter = 0
local html = mw.html
local cargo = mw.ext.cargo

-- ============================================================
-- HELPER: Number Formatters
-- ============================================================

-- Indian Format (1,00,000)
local function formatINR(amount)
    if not amount then return "0" end
    local n = tostring(math.floor(tonumber(amount) or 0))
    if #n <= 3 then return n end
    local last3 = n:sub(-3)
    local rest = n:sub(1, -4)
    -- Indian format: group remaining digits in pairs (from right)
    local formattedRest = rest:reverse():gsub("(%d%d)", "%1,"):reverse():gsub("^,", "")
    return formattedRest .. "," .. last3
end

-- Standard Format (100,000) - For USD, Yen, etc.
local function formatStd(amount)
    if not amount then return "0" end
    local n = tostring(math.floor(tonumber(amount) or 0))
    return n:reverse():gsub("(%d%d%d)", "%1,"):reverse():gsub("^,", "")
end

-- ============================================================
-- HELPER: Dual Currency Display & Calc
-- ============================================================
-- Returns: { displayHTML, valueForDatabase (INR) }
local function processMoney(amount, currency, rate)
    if not amount or amount == "" or amount == "0" then 
        return { display = "TBD", dbValue = 0 } 
    end

    local val = 0
    local r = tonumber(rate) or 1
    local symbol = currency or "₹"
    
    if type(amount) == "string" then
        val = tonumber((amount:gsub(",", ""))) or 0
    else
        val = tonumber(amount) or 0
    end
    
    -- Case 1: Input is INR (Primary = INR, Secondary = USD)
    if symbol == "₹" or symbol == "INR" or symbol == "Rs" then
        local inrVal = val
        local usdVal = val * r -- Rate should be e.g. 0.011
        
        local mainStr = "₹ " .. formatINR(inrVal)
        local subStr = ""
        
        if r ~= 1 then
            subStr = '<br><small style="color:var(--text-muted); font-size:0.85em;">≈ $ ' .. formatStd(usdVal) .. '</small>'
        end
        
        return { 
            display = '<span class="pz-val">' .. mainStr .. subStr .. '</span>',
            dbValue = inrVal
        }
    
    -- Case 2: Input is Foreign (Primary = Foreign, Secondary = INR)
    else
        local localVal = val
        local inrVal = val * r -- Rate should be e.g. 90 (1 Unit = 90 INR)
        
        local mainStr = symbol .. " " .. formatStd(localVal)
        local subStr = '<br><small style="color:var(--text-muted); font-size:0.85em;">≈ ₹ ' .. formatINR(inrVal) .. '</small>'
        
        return { 
            display = '<span class="pz-val">' .. mainStr .. subStr .. '</span>',
            dbValue = inrVal
        }
    end
end

-- Helper: Get Logo
local function getLogo(teamName)
    if not teamName or teamName == "" or teamName == "TBD" then return "" end
    local clean = teamName:gsub("'", "")
    local light = clean .. '.png'
    local dark = clean .. '_dark.png'
    
    local container = html.create('span')
    
    if mw.title.new('File:' .. light).exists then
        container:wikitext('[[File:' .. light .. '|link=|class=logo-lightmode]]')
    else
        container:wikitext('[[File:Shield_team.png|link=|class=logo-lightmode]]')
    end
    
    if mw.title.new('File:' .. dark).exists then
        container:wikitext('[[File:' .. dark .. '|link=|class=logo-darkmode]]')
    elseif mw.title.new('File:' .. light).exists then
        container:wikitext('[[File:' .. light .. '|link=|class=logo-darkmode]]')
    else
        container:wikitext('[[File:Shield_team_dark.png|link=|class=logo-darkmode]]')
    end
    
    return tostring(container)
end

function p.main(frame)
    local args = frame:getParent().args
    
    -- Global Settings
    local currency = args.currency or "₹"
    local rate = tonumber(args.rate) or 1
    
    local tournamentName = args.tournament or mw.title.getCurrentTitle().subpageText
    
    -- PRE-CHECK: Are there any awards?
    local hasAnyAwards = false
    for i = 1, 20 do
        if args['award_' .. i] and args['award_' .. i] ~= "" then
            hasAnyAwards = true
            break
        end
    end

    -- Unique IDs for Toggling
    _id_counter = _id_counter + 1
    local uniqueID = "pp-" .. _id_counter
    local idContent = 'content-' .. uniqueID
    local idBtnShow = 'btn-show-' .. uniqueID
    local idBtnHide = 'btn-hide-' .. uniqueID
    
    local grid = html.create('div'):addClass('prize-section-grid')
    
    -- Adjust grid columns if no awards (Full width ranking)
    if not hasAnyAwards then
        grid:css('grid-template-columns', '1fr')
    end
    
    -- ==========================================
    -- COLUMN 1: RANKINGS (TEAMS)
    -- ==========================================
    local colRank = grid:tag('div'):addClass('prize-col-rank')
    colRank:tag('div'):addClass('prize-header'):wikitext('Prize Pool Distribution')
    
    local rankList = colRank:tag('div'):addClass('prize-list')
    local hasRankData = false
    local rankCount = 0
    
    for i = 1, 64 do
        if (args['team_'..i] and args['team_'..i] ~= "") or (args['prize_'..i] and args['prize_'..i] ~= "") then 
            rankCount = rankCount + 1 
        end
    end
    
    local collapseLimit = 10 
    local isCollapsible = (rankCount > collapseLimit)
    
    local hiddenDiv = nil
    if isCollapsible then
        hiddenDiv = html.create('div')
            :addClass('mw-collapsible mw-collapsed')
            :attr('id', 'mw-customcollapsible-' .. idContent)
    end
    
    for i = 1, 64 do
        local place = args['place_'..i] or (i .. '.')
        local team = args['team_'..i]
        local rawPrize = args['prize_'..i]
        local seed = args['seed_'..i]
        
        if (team and team ~= "") or (rawPrize and rawPrize ~= "") then
            hasRankData = true
            
            -- Process Money (Display + DB Value)
            local moneyData = processMoney(rawPrize, currency, rate)
            
            -- DATABASE STORE (Always store INR value)
            if team and team ~= "" and cargo and cargo.store then
                cargo.store('PrizeMoney', {
                    tournament = tournamentName,
                    placement = i,
                    team = team,
                    prize = moneyData.dbValue, -- STORES INR
                    award = ''
                })
            end
            
            local targetContainer = rankList
            if isCollapsible and i > collapseLimit then
                targetContainer = hiddenDiv
            end
            
            local row = targetContainer:tag('div'):addClass('prize-row')
            
            local rankClass = 'rank-other'
            local rankIcon = place
            if i == 1 then rankClass = 'rank-1'; rankIcon = '🥇' end
            if i == 2 then rankClass = 'rank-2'; rankIcon = '🥈' end
            if i == 3 then rankClass = 'rank-3'; rankIcon = '🥉' end
            
            row:addClass(rankClass)
            row:tag('div'):addClass('pz-rank'):wikitext(rankIcon)
            
            local teamDiv = row:tag('div'):addClass('pz-team')
            
            if team and team ~= "" then
                teamDiv:wikitext(getLogo(team))
                teamDiv:wikitext('[[' .. team .. ']]')
            else
                teamDiv:wikitext('TBD'):css('color', 'var(--text-muted)'):css('font-weight', 'normal')
            end
            
            local infoDiv = row:tag('div'):addClass('pz-info')
            
            -- Prize Display
            if rawPrize and rawPrize ~= "" then
                infoDiv:tag('div'):addClass('pz-prize'):wikitext(moneyData.display)
            end
            
            if seed and seed ~= "" then
                infoDiv:tag('span'):addClass('pz-seed'):wikitext(seed)
            end
        end
    end
    
    if not hasRankData then
        rankList:tag('div'):addClass('prize-empty')
            :wikitext('<i class="fa-solid fa-trophy"></i><br>Prize Pool TBD')
    else
        if isCollapsible then
            rankList:wikitext(tostring(hiddenDiv))
            local toggleTargets = 'mw-customtoggle-' .. idContent .. ' mw-customtoggle-' .. idBtnShow .. ' mw-customtoggle-' .. idBtnHide
            
            colRank:tag('div')
                :attr('id', 'mw-customcollapsible-' .. idBtnShow)
                :addClass('prize-show-more mw-collapsible ' .. toggleTargets) 
                :wikitext('View Full Distribution <i class="fa-solid fa-chevron-down"></i>')
                
            colRank:tag('div')
                :attr('id', 'mw-customcollapsible-' .. idBtnHide)
                :addClass('prize-show-more mw-collapsible mw-collapsed ' .. toggleTargets) 
                :wikitext('Show Less <i class="fa-solid fa-chevron-up"></i>')
        end
    end
    
    -- ==========================================
    -- COLUMN 2: SPECIAL AWARDS (Conditionally Rendered)
    -- ==========================================
    if hasAnyAwards then
        local colAward = grid:tag('div'):addClass('prize-col-award')
        colAward:tag('div'):addClass('prize-header'):wikitext('Special Awards')
        
        local awardList = colAward:tag('div'):addClass('prize-list')
        
        for i = 1, 20 do
            local awardName = args['award_'..i]
            local winner = args['award_'..i..'_winner']
            local team = args['award_'..i..'_team']
            local rawPrize = args['award_'..i..'_prize']
            
            if awardName and awardName ~= "" then
                
                local moneyData = processMoney(rawPrize, currency, rate)
                
                if (winner or team) and cargo and cargo.store then
                    cargo.store('PrizeMoney', {
                        tournament = tournamentName,
                        placement = '',
                        team = team or '',
                        player = winner or '',
                        prize = moneyData.dbValue, -- STORES INR
                        award = awardName
                    })
                end
                
                local row = awardList:tag('div'):addClass('award-row')
                
                local info = row:tag('div'):addClass('award-info')
                info:tag('div'):addClass('award-name'):wikitext(awardName)
                
                local winDiv = info:tag('div'):addClass('award-winner')
                
                if winner and winner ~= "" then
                    if team and team ~= "" then winDiv:wikitext(getLogo(team)) end
                    winDiv:wikitext('[[' .. winner .. ']]')
                elseif team and team ~= "" then
                    winDiv:wikitext(getLogo(team))
                    winDiv:wikitext('[[' .. team .. ']]')
                else
                    winDiv:wikitext("TBD"):css('color', 'var(--text-muted)'):css('font-weight', 'normal')
                end
                
                if rawPrize and rawPrize ~= "" then
                    row:tag('div'):addClass('award-prize'):wikitext(moneyData.display)
                end
            end
        end
    end
    
    return tostring(grid)
end

return p