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

Module:Rarity icon

From Sekaipedia
Revision as of 03:36, 22 January 2022 by ChaoticShadow (talk | contribs)

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

local getArgs = require('Module:Arguments').getArgs
local yesno   = require('Module:Yesno')
local data    = mw.loadData('Module:Rarity icon/data')

local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local rarity = string.lower(args[1] or '')
	local size = args['size'] or '30px'
	local trained = yesno(args['trained'], false)

	local icons = data
	
	if rarity == 'birthday' then
		return string.format('[[File:%s|x%s]]', icons['birthday'], size)
	elseif rarityNum and rarityNum >= 1 and rarityNum <= 5 then
		local starIcon = icons['star']
		
		if trained then
			starIcon = icons['star trained']
		end
		
		local ret = ''
		for i=1,rarityNum do
			ret = ret .. string.format('[[File:%s|x%s]] ', starIcon, size)
		end
		return ret
	elseif string.find(rarity, "^[1-5]$") or string.find(rarity, "^[1-5] trained$") then
		local count = tonumber(string.match(rarity, "[1-5]"))
		local trained = string.match(rarity, "trained")
		
		local starIcon = icons['star']
		
		if trained then
			starIcon = icons['star trained']
		end
		
		local ret = {}
		for i=1,count do
			table.insert(ret, string.format('[[File:%s|x%s|link=]]', starIcon, size))
		end
		return table.join(ret, ' ')
	end
	
	return nil
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.