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

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

local p = {}

-- Rarity border colors
local rarityColors = {
    Common = "#717471cc",     
    Uncommon = "#41eb6acc",   
    Rare = "#1ecbfccc",       
    Epic = "#d8299bcc",       
    Legendary = "#fbc700cc"
}

local rarityGradientBkg = {
	Common    = "linear-gradient(to right, rgb(153 159 165 / 10%) 0%, rgb(5 13 36) 100%)",
	Uncommon  = "linear-gradient(to right, rgb(86 203 134 / 20%) 0%, rgb(5 13 36) 100%)",
	Rare      = "linear-gradient(to right, rgb(30 150 252 / 20%) 0%, rgb(5 13 36) 100%)",
	Epic      = "linear-gradient(to right, rgb(216 41 155 / 20%) 0%, rgb(5 13 36) 100%)",
	Legendary = "linear-gradient(to right, rgb(251 199 0 / 20%) 0%, rgb(5 13 36) 100%)"
}

function p.render(frame)
    local args = frame:getParent().args
    local html = mw.html.create("div"):addClass("item-grid")

	local i = 1
    while args["image" .. i] and i < 100 do
        local isLimited = args["isLimited" .. i] or false
        local rarity = args["rarity" .. i] or "Common"
        local border = rarityColors[rarity] or rarityColors["Common"]

        local item = html:tag("div")
            :addClass("item-cell")
            :css("border", "1px solid " .. border)
        	:css("background", "" .. rarityGradientBkg[rarity])
        		
        if (isLimited == ("true" or "True")) then 
        item:tag("div")
        	:addClass("icon_timereset")
        	:wikitext("[[File:Icon_TimeReset.png|16px]]")
        end
        
        if rarity ~= "" then   --reformat this repetitive block if you can
        item:tag("div")
            :addClass("item-image")
            :wikitext(string.format("%s", args["image" .. i]))
        	:tag("div")
        		:addClass(string.format("curve-%s", rarity))
				:done()
		else
			item:tag("div")
            :addClass("item-image")
            :wikitext(string.format("%s", args["image" .. i]))
        end
	
		item:tag("div")
	    	    :addClass("item-name")
	    	    :wikitext(args["name" .. i] or "")
	    
        item:tag("div")
            :addClass("data-table")
        
        	:tag("div")
	    	    :addClass("category-icon")
	    	    :wikitext(args["category-icon" .. i] or "")
	    	    :done()
        	    
        	:tag("div")
        	    :addClass("item-price")
        	    :wikitext(args["price" .. i] or "")
        	    :done()
		i = i + 1
    end

    return tostring(html)
end

return p