Module:NFL Draft

-- this module implements -- Template:NFLDraft-row -- Template:NFLDraft-header -- Template:NFLDraft-footer local p = {}

local afbpositions = require('Module:American football positions')._main local yesno = require('Module:Yesno')

local row_colors = { ["compensatory"] = "d9e9f9", ["supplemental"] = "ffdddd", ["expansion"] = "a9f5d0", ["resolution"] = "ccf9cc" }

local doubledagger = ""

local function anchor(value) if value and value ~= '' then return ' ' end return '' end

local function sortname(first, last, link, nolink) last = last or '' first = first or '' link = link or '' local name = first .. ' ' .. last if not (nolink or (first == '-') or (last == '-')) then if link ~= '' then name =  .. name ..  else name =  .. name ..  end end name = ' ' .. name .. ' '	return '" .. name .. ' ' end

local function get_round_color(round, numrounds) -- make sure numbers are within bounds round = tonumber(round) or -1 numrounds = tonumber(numrounds) or 7 numrounds = numrounds < 7 and 7 or numrounds numrounds = numrounds > 32 and 32 or numrounds -- linear color scale from F00 to F0A local c = {"F00", "F30", "F50", "F80", "FB0", "FE0", "FF0", "CF0", "9F0", "6F0", "4F0", "1F0", "0F1", "0F4", "0F6", "0F9", "0FC", "0FF", "0EF", "0BF", "08F", "05F", "03F", "00F", "20F", "50F", "70F", "A0F", "D0F", "F0F", "F0D", "F0A"} -- affine map from [1, numrounds] to [1, #c] local r = math.floor(1.5 + (round - 1) * (#c - 1) / (numrounds - 1)) return c[r] or "fff" end

function p._row(args) local rowtype = 'none' for k,v in ipairs({'resolution', 'expansion', 'supplemental', 'compensatory'}) do		if yesno(v) then rowtype = v end end local rowcolor = row_colors[rowtype] local root = {} local txt = '' table.insert(root,'|-' .. (rowcolor and 'style="background:#' .. rowcolor .. '"' or '')) if not yesno(args['undrafted']) then local pickstyle = 'text-align:center;' table.insert(root,'|style="background:#' .. 			get_round_color(args['round'], args['numberofrounds']) .. '"|') txt = (args['round'] or '') if yesno(args['firstpickinround']) then txt = txt .. anchor('Round_' .. (args['round'] or '')) end if yesno(args['compensatory']) then txt = '|style="text-align:center;font-weight:bold;"| ' .. txt .. '&#42;'			pickstyle = pickstyle .. 'background-color:unset;' elseif yesno(args['supplemental']) then txt = '|style="text-align:center;font-weight:bold;"| ' .. txt .. '^'			pickstyle = pickstyle .. 'background-color:unset;' elseif yesno(args['expansion']) then txt = '|style="text-align:center;font-weight:bold;"| ' .. txt .. '¤'			pickstyle = pickstyle .. 'background-color:unset;' elseif yesno(args['resolution']) then txt = '|style="text-align:center;font-weight:bold;"| ' .. txt .. '×'			pickstyle = pickstyle .. 'background-color:unset;' else txt = '! ' .. txt end table.insert(root,txt) txt = args['picknum'] or '' if tonumber(txt) == 1 then txt = '1' elseif tonumber(txt) == 2 then txt = '1' elseif yesno(args['lastpick']) then txt =  .. txt  end txt = anchor('Pick_' .. (args['picknum'] or '')) .. txt table.insert(root,'!scope=row style="font-weight:bold;' .. pickstyle .. '"|' .. txt) end txt = args['team'] or '' if args['draftyear'] then txt =  .. txt ..  elseif args['teamdab'] then txt =  .. args['team'] ..  end table.insert(root,'| ' .. txt) txt = '' if args['last'] then local style = '' local name = sortname(args['first'], args['last'], args['dab'], (args['playerpageexists'] == 'no') and 1 or nil) .. (yesno(args['hof']) and doubledagger or '') .. (yesno(args['probowl']) and '†' or '') if yesno(args['hof']) then style = 'style="background:#FFCC00"|' elseif yesno(args['probowl']) then style = 'style="background:#faecc8"|' end txt = style .. name end table.insert(root,'|' .. txt) txt = '' if args['position'] then txt = afbpositions(args['position'], false) if args['position2'] then txt = txt .. '/' .. afbpositions(args['position2'], false) end end table.insert(root,'| ' .. txt) txt = '' if args['college'] and args['college']:lower ~= 'university' then if args['collegelink'] then if yesno(args['cfb page exists']) then txt =  					.. args['collegelink'] ..  else txt = mw.getCurrentFrame:expandTemplate{ title = 'cfb link',	args = { ['year'] = args['collegeyear'] or '', ['team'] = args['collegeteam'] or '', ['school'] = args['college'] or '', ['title'] = args['collegelink'] or '' } }			end else txt =  .. args['college'] ..  end end table.insert(root,'| ' .. txt) txt = '' if args['college'] and args['college']:lower ~= 'university' then if args['conference'] then txt = args['conference'] else local cfbconf = require('Module:College football conference')._main txt = cfbconf(args['collegeyear'], args['college']) end txt = 'style="text-align:center"|' .. txt end table.insert(root,'|' .. txt) txt = '' if args['note'] then txt = ' ' .. args['note'] .. ' '	end table.insert(root,'|' .. txt) return table.concat(root, '\n') end

local function abbr(a, d) return '' .. a .. ' ' end

function p._header(args) local root = {}

local style = 'scope=col style="background:#A8BDEC;%s"' table.insert(root, ' \n{| class="wikitable sortable plainrowheaders" border="1"') if args['caption'] then table.insert(root, '|+ ' .. args['caption']) end table.insert(root, '|-') local cstyle = string.format(style,'width:3px;') local pstyle = string.format(style, '') local nstyle = string.format(style, args['noteswidth'] and 'width:' .. args['noteswidth'] .. ';' or '') local oteam if not yesno(args['undrafted']) then table.insert(root, '! ' .. cstyle .. ' class="unsortable" |') table.insert(root, '! ' .. pstyle .. ' | ' .. abbr('Rnd.', 'Draft round')) table.insert(root, '! ' .. pstyle .. ' | ' .. abbr('Pick No.', 'Overall selection number')) oteam = abbr('NFL team', 'Team which made selection') else oteam = abbr('Original NFL team', 'Team which signed the player after the draft') end table.insert(root, '! ' .. pstyle .. ' | ' .. oteam) table.insert(root, '! ' .. pstyle .. ' | Player') table.insert(root, '! ' .. pstyle .. ' | ' .. abbr('Pos.', 'Football position played')) table.insert(root, '! ' .. pstyle .. ' | ' .. abbr('College', 'Most recent college attended')) table.insert(root, '! ' .. pstyle .. ' | ' .. abbr('Conf.', 'Athletic conference of most recent college')) table.insert(root, '! ' .. nstyle .. ' class="unsortable" | Notes') table.insert(root, '|-')

return table.concat(root, '\n') end

function p._footer return '|-\n|}' end

function p.row(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame) return p._row(args) end

function p.header(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame) return p._header(args) end

function p.footer(frame) return p._footer end

return p