Module:Sports roster/WNBA

local pp = {}

local basketball_positions = {
	['PG'] = '<span data-sort-value="1.0">[[Point guard|PG]]</span>',
	['G'] = '<span data-sort-value="1.5">[[Guard (basketball)|G]]</span>',
	['SG'] = '<span data-sort-value="2.0">[[Shooting guard|SG]]</span>',
	['PG/SG'] = 'CG', ['PG-SG'] = 'CG', ['SG/PG'] = 'CG', ['SG-PG'] = 'CG', ['CG'] = 'CG', ['C-G'] = 'CG',
	['CG'] = '<span data-sort-value="2.5">[[Combo guard|C/G]]</span>',
	['SG/SF'] = 'GF', ['SG-SF'] = 'GF', ['SF/SG'] = 'GF', ['SF-SG'] = 'GF', ['G/F'] = 'GF', ['G-F'] = 'GF', ['F/G'] = 'GF', ['F-G'] = 'GF',
	['GF'] = '<span data-sort-value="2.5">[[Swingman|G/F]]</span>',
	['SF'] = '<span data-sort-value="3.0">[[Small forward|SF]]</span>',
	['SF/PF'] = 'CM', ['SF-PF'] = 'CM', ['PF/SF'] = 'CM', ['PF-SF'] = 'CM', ['C/M'] = 'CM', ['C-M'] = 'CM',
	['CM'] = '<span data-sort-value="3.5">[[Cornerman|C/M]]</span>',
	['F'] = '<span data-sort-value="4.0">[[Forward (basketball)|F]]</span>',
	['PF'] = '<span data-sort-value="4.5">[[Power forward (basketball)|PF]]</span>',
	['PF/C'] = '<span data-sort-value="4.75">[[Power forward (basketball)|PF]]/[[Center (basketball)|C]]</span>',
	['PG/SF'] = 'PTF', ['PG/PF'] = 'PTF', ['PG-SF'] = 'PTF', ['PG-PF'] = 'PTF', ['PT/F'] = 'PTF', ['PT-F'] = 'PTF', 
	['PTF'] = '<span data-sort-value="5.0">[[Point forward|PT/F]]</span>',
	['F/C'] = 'FC', ['F-C'] = 'FC', ['C/F'] = 'FC', ['C-F'] = 'FC', ['CF'] = 'FC',
	['FC'] = '<span data-sort-value="5.5">[[Forward-center|F/C]]</span>',
	['C'] = '<span data-sort-value="6.0">[[Center (basketball)|C]]</span>'
}

local ordinal = require('Module:Ordinal')._ordinal

-- Roster format
function pp.headings(args, keys)
	local h = mw.html.create('tr')
	if keys['starter'] then
		h:tag('th'):tag('abbr'):attr('title', 'Starter'):wikitext('S.')
	end
	if keys['pos'] then
		h:tag('th'):tag('abbr'):attr('title', 'Position'):wikitext('Pos.')
	end
	if keys['num'] then
		h:tag('th'):tag('abbr'):attr('title', 'Number'):wikitext('No.')
	end
	if keys['nat'] then
		h:tag('th'):tag('abbr'):attr('title', 'Nationality'):wikitext('Nat.')
	end
	h:tag('th'):wikitext('Name')
	if keys['ft'] or keys['in'] then
		h:tag('th'):wikitext('Height')
	end
	if keys['lbs'] then
		h:tag('th'):wikitext('Weight')
	end
	if keys['DOB'] then
		h:tag('th'):tag('abbr'):attr('title', 'Date of birth'):wikitext('DOB')
	end
	if keys['college'] or keys['school'] or keys['from'] then
		h:tag('th'):wikitext('From')
	end
	if keys['yrs'] then
		if args['allstars'] then
			h:tag('th'):tag('abbr'):wikitext('Selection')
		else
			h:tag('th'):tag('abbr'):attr('title', 'Years'):wikitext('Yrs')
		end
	end
	return tostring(h)
end

function pp.players_roster(args, players, keys)
	local tracking = ''
	local res = mw.html.create('')
	for k,v in ipairs(players) do
		local r = res:tag('tr'):css('text-align', 'center')
		if keys['starter'] then
			r:tag('td'):wikitext(v['starter'] and '\'\'\'(S)\'\'\'' or '')
		end
		if keys['pos'] then
			local pos = v['pos']
			if basketball_positions[pos] then
				pos = basketball_positions[pos]
				if basketball_positions[pos] then
					pos = basketball_positions[pos]
				end
			end
			r:tag('td'):wikitext(pos or '')
		end
		if keys['num'] then
			r:tag('td'):wikitext(v['num'] or '')
		end
		if keys['nat'] then
			r:tag('td'):wikitext(v['nat'] or '')
		end
		
		local name = v['name'] or ''
		if (v['inj'] or 'no') == 'yes' then
			name = name .. '&nbsp;[[File:Cruz Roja.svg|8px|Injured|link=]]'
		end
		if v['note'] then
			name = name .. '&nbsp;' .. "'''(" .. v['note'] .. "''')"
		end
		r:tag('td'):css('text-align', 'left'):wikitext(name)
		
		if keys['ft'] or keys['in'] then
			local h = ''
			if v['ft'] and tonumber(v['ft']) then
				local inches = 12*tonumber(v['ft']) + (tonumber(v['in']) or 0)
				local cm = math.floor(2.54*inches + 0.5)
				h = '<span data-sort-value="' .. inches .. '">'
					.. tonumber(v['ft']) .. '\' ' .. (tonumber(v['in']) or 0) .. '"'
					.. ' (' .. (cm / 100) .. 'm)</span>'
			end
			r:tag('td')
				:css('text-align', 'right')
				:css('white-space', 'nowrap')
				:wikitext(h)
		end
		
		if keys['lbs'] then
			local w = ''
			if v['lbs'] and tonumber(v['lbs']) then
				local kg = math.floor(0.45359237*tonumber(v['lbs']) + 0.5)
				w = tonumber(v['lbs']) .. ' lb '
					.. ' (' .. kg .. 'kg)'
			end
			r:tag('td')
				:css('text-align', 'right')
				:css('white-space', 'nowrap')
				:wikitext(w)
		end

		if keys['DOB'] then
			local DOB = v['DOB'] or ''
			DOB = mw.ustring.gsub(DOB, '^%s*(%d)%-(%d%d?)%-(%d%d%d%d)%s*$', '0%1-%2-%3')
			DOB = mw.ustring.gsub(DOB, '^%s*(%d%d?)%-(%d)%-(%d%d%d%d)%s*$', '%1-0%2-%3')
			DOB = mw.ustring.gsub(DOB, '^%s*(%d%d)%-(%d%d)%-(%d%d%d%d)%s*$', '%3-%1-%2')
			DOB = mw.ustring.gsub(DOB, '^%s*(%d%d%d%d)%-(%d)%-(%d%d?)%s*$', '%1-0%2-%3')
			DOB = mw.ustring.gsub(DOB, '^%s*(%d%d%d%d)%-(%d%d?)%-(%d)%s*$', '%1-%2-0%3')
			r:tag('td'):wikitext(DOB)
		end
		
		if keys['college'] or keys['school'] or keys['from'] then
			if v['college'] or v['school'] then
				r:tag('td'):css('text-align', 'left'):wikitext(v['college'] or v['school'])
			elseif v['from'] then
				r:tag('td'):css('text-align', 'left'):wikitext('[[' .. v['from'] .. ']]')
			else
				r:tag('td')
			end
		end
		
		if keys['yrs'] then
			if args['allstars'] then
				r:tag('td'):wikitext(ordinal(v['yrs'] or '', false, false))
			elseif v['yrs'] == 'R' then
				r:tag('td'):wikitext('<span data-sort-value="0">R</span>')
			else
				r:tag('td'):wikitext(v['yrs'])
			end
		end
	end
		
	return tostring(res) .. tracking
end

function pp.coaches_roster(coaches)
	local res = ''
	local role = ''
	for k,v in ipairs(coaches) do
		if v['role'] ~= role then
			role = v['role']
			res = res .. '\n; ' .. role
		end
		if v['nat2'] and v['nat'] then
			v['nat'] = v['nat'] .. '/' .. v['nat2']
		end
		res = res .. '\n: ' .. (v['nat'] or '') .. ' ' .. (v['name'] or '')
		if v['college'] then
			res = res .. ' (' .. v['college'] .. ')'
		elseif v['from'] then
			res = res .. ' (' .. v['from'] .. ')'
		end
	end
	return res
end

function pp.staff_roster(staff)
	local res = ''
	local role = ''
	for k,v in ipairs(staff) do
		if v['role'] ~= role then
			role = v['role']
			res = res .. '\n; ' .. role
		end
		if v['nat2'] and v['nat'] then
			v['nat'] = v['nat'] .. '/' .. v['nat2']
		end
		res = res .. '\n: ' .. (v['nat'] or '') .. ' ' .. (v['name'] or '')
		if v['college'] then
			res = res .. ' (' .. v['college'] .. ')'
		elseif v['from'] then
			res = res .. ' (' .. v['from'] .. ')'
		end
	end
	return res
end

function pp.legend(args)
	local res = '\n----'
	res = res .. '\n;Legend'
	for k,v in ipairs(args['allstars'] and {
		{'S', 'Starter'},
		{'IR', 'Injury replacement'},
		{'RS', 'Replacement for injured starter'}
		} or {
		{'C', 'Team captain'}, 
		{'DP', 'Unsigned draft pick'},
		{'FA', 'Free agent'},
		{'S', 'Suspended'},
		}) do
		res = res .. "\n*'''(" .. v[1] .. ")''' " .. v[2]
	end
	if args['otherlegend'] then
		res = res .. '\n*' .. args['otherlegend']
	end
	if args['otherlegend2'] then
		res = res .. '\n*' .. args['otherlegend2']
	end
	if args['otherlegend3'] then
		res = res .. '\n*' .. args['otherlegend3']
	end
	res = res .. '\n*[[File:Cruz Roja.svg|8px|Injured|link=]] Injured'
	local team = args['rosterteam']
	if not team then
		team = string.lower(args['team'])
		team = mw.ustring.gsub(team, '^.*%s(%S+)%s*$', '%1')
	end
	if args['roster_url'] then
		res = res .. '\n----\n&nbsp; <span class="plainlinks">[' .. args['roster_url'] .. ' WNBA roster page]</span>'
	elseif args['season'] then
	elseif team then
		res = res .. '\n----\n&nbsp; <span class="plainlinks">[http://' .. team .. '.wnba.com/roster WNBA roster page]</span>'
	end
	if args['notes'] then
		res = res .. ';Notes\n' .. args['notes']
	end
	return res
end

function pp.above(args, keys)
	if args['season'] then
		return args['season'] .. ' [[' .. args['team'] .. ']] roster'
	end
	return '[[' .. args['team'] .. ']] roster'
end

function pp.abovestyle(frame, args, keys)
	if args['season'] and args['bg1'] then
		return 'background-color:' .. args['bg1'] .. '; color:' .. (args['color1'] or 'black') .. ';'
	end
	return frame:expandTemplate{title = 'WNBA color cell', args = { args['team']}}
end

function pp.headingstyle(frame, args, keys)
	if args['season'] and (args['bg2'] or args['bg1']) then
		return 'background-color:' .. (args['bg2'] or args['bg1']) .. '; color:' .. (args['color2'] or args['color1'] or 'black') .. ';'
	end
	return frame:expandTemplate{title = 'WNBA color cell2', args = { args['team']}}
end

function pp.footer(args, keys)
	if args['nofooter'] or args['no_footer'] or args['season'] then
		return ''
	end
	return "\n;[[Eastern Conference (WNBA)|East]]"
.. "\n: [[Atlanta Dream|ATL]]"
.. "\n: [[Chicago Sky|CHI]]"
.. "\n: [[Connecticut Sun|CON]]"
.. "\n: [[Indiana Fever|IND]]"
.. "\n: [[New York Liberty|NY]]"
.. "\n: [[Toronto Tempo|TOR]]"
.. "\n: [[Washington Mystics|WAS]]"
.. "\n;[[Western Conference (WNBA)|West]]"
.. "\n: [[Dallas Wings|DAL]]"
.. "\n: [[Golden State Valkyries|GS]]"
.. "\n: [[Las Vegas Aces|LV]]"
.. "\n: [[Los Angeles Sparks|LA]]"
.. "\n: [[Minnesota Lynx|MIN]]"
.. "\n: [[Phoenix Mercury|PHO]]"
.. "\n: [[Portland Fire|POR]]"
.. "\n: [[Seattle Storm|SEA]]"
end

function pp.footerstyle(frame, args, keys)
	return 'border:1px #aaa solid;'
end

-- Navbox format

function pp.players_list(args, players, keys)
	local r = ''
	for k,v in ipairs(players) do
		r = r .. '\n*' .. (v['num'] or '') .. ' ' .. (v['name'] or '')
	end
	return r
end

function pp.coaches_list(coaches)
	local res = ''
	local role = ''
	for k,v in ipairs(coaches) do
		if v['role'] ~= role then
			role = v['role']
			res = res .. '\n; ' .. role
		end
		res = res .. '\n: ' .. (v['name'] or '')
	end
	return res
end

function pp.title(args, keys)
	return '[[' .. args['team'] .. ']] current roster'
end

function pp.titlestyle(frame, args, keys)
	return frame:expandTemplate{title = 'WNBA color cell', args = { args['team'], border = '2'}}
end

function pp.below(args, keys)
	return pp.footer(args, keys)
end

function pp.belowstyle(frame, args, keys)
	return 'background:transparent; box-shadow: inset 0 1px 0 0 #aaa;'
end

return pp

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.