Module:AchievementIcons

From Liquipedia Fighting Games Wiki

local p = {}

local Arguments = require('Module:Arguments')
local LeagueIcon = require('Module:LeagueIcon')

local MAXPLAYERS = 10

function p.singleRow(frame)
	local args = Arguments.getArgs(frame)
	
	local output = ''
	local player = args.player or mw.title.getCurrentTitle().text
	local underscorePlayer = string.gsub(player, ' ', '_')
	
	local lpdbConditions = '[[liquipediatier::1]] AND [[liquipediatiertype::!Qualifier]] AND [[placement::1]] AND (([[mode::singles]] AND [[participant::' .. player .. ']]) OR ([[mode::doubles]] AND ([[players_p1::' .. player .. ']] OR [[players_p2::' .. player .. ']])) OR ([[mode::team]] AND '
	lpdbConditions = lpdbConditions .. '([[players_p1::' .. underscorePlayer .. ']]'
	for i=2,MAXPLAYERS do
		lpdbConditions = lpdbConditions .. ' OR [[players_p' .. i .. '::' .. underscorePlayer .. ']]'
	end
	lpdbConditions = lpdbConditions .. ')))'
mw.log(lpdbConditions)
	
	local data = mw.ext.LiquipediaDB.lpdb('placement', {
		conditions = lpdbConditions,
		query = 'icon, icondark, game, shortname, parent',
	  	order = 'date asc',
		limit = '100',
		})
mw.logObject(data)
	if #data == 0 then
		return
	end

  	for _, item in ipairs(data) do
		if item.icon ~= '' then
			local iconOutput = LeagueIcon.display({
				icon = item.icon,
				iconDark = item.icondark,
				--size = ...,
				link = item.parent,
				name = item.shortname,
				options = { noTemplate = true }
			})
			output = output .. iconOutput .. ' '
	  	end
	end
mw.log(output)
	return output
end

return p