Module:Sandbox/Vozul Explained

require('strict')

local p = local getArgs = require('Module:Arguments').getArgslocal yesno = require('Module:Yesno')local americanFootballPositions = require('Module:American football positions')local collegeFootballConference = require('Module:College football conference')

local function hsvToHex(h, s, v) local c = v * s local x = c * (1 - math.abs((h/60) % 2 - 1)) local m = v - c local rgb if h < 60 then rgb = elseif h < 120 then rgb = elseif h < 180 then rgb = elseif h < 240 then rgb = elseif h < 300 then rgb = else rgb = end rgb =

return string.format('%02x%02x%02x', rgb.r, rgb.g, rgb.b)end

local function getRowRoundColor(round, numRounds) if not round then mw.addWarning('round not provided') return 'ffffff' elseif (round <= 0 or round > numRounds) then mw.addWarning('round should be positive and less than numberofrounds') return 'ffffff' end

local hueSteps = 360.0/numRounds local hue = math.floor((round - 1) * hueSteps) return hsvToHex(hue, 1.0, 1.0)end

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

function p._main(args) local row = local rowHasDifferntBg = true

if yesno(args.compensatory) then table.insert(row, 'bgcolor="#d9e9f9"') elseif yesno(args.supplemental) then table.insert(row, 'bgcolor="#ffdddd"') elseif yesno(args.expansion) then table.insert(row, 'bgcolor="#a9f5d0"') elseif yesno(args.resolution) then table.insert(row, 'bgcolor="#ccf9cc"') else rowHasDifferntBg = false end if not yesno(args.undrafted, false) then table.insert(row, '\n|') local numerofrounds = tonumber(args.numerofrounds) if not numerofrounds then numerofrounds = 7 end

table.insert(row, 'bgcolor="#') table.insert(row, getRowRoundColor(args.round, args.numberofrounds)) table.insert(row, '"| ')

-- round column table.insert(row, '\n!scope=row style="text-align:center; font-weight:bold;') if rowHasDifferntBg then table.insert(row, ' background-color:unset;') end

table.insert(row, '"') --closing quote for style

if yesno(args.firstpickinround) then table.insert(row, 'id="Round_') table.insert(row, tostring(args.round)) end

table.insert(row, '|') table.insert(row, tostring(args.round))

if yesno(args.compensatory) then table.insert(row, '*') elseif yesno(args.supplemental) then table.insert(row, '^"') elseif yesno(args.expansion) then table.insert(row, '¤') elseif yesno(args.resolution) then table.insert(row, '×"') end

-- num pick column table.insert(row, '\n!scope=row style="text-align:center; font-weight:bold;')

if rowHasDifferntBg then table.insert(row, 'background-color:unset;') end

table.insert(row, '" id=Pick_') table.insert(row, tostring(args.picknum)) table.insert(row, '|')

if args.picknum

1 then table.insert(row, '1') elseif args.picknum

2 then table.insert(row, '2') elseif yesno(args.lastpick) then table.insert(row, '') table.insert(row, tostring(args.picknum)) table.insert(row, '') else table.insert(row, tostring(args.picknum)) end end

-- team column table.insert(row, '\n|') elseif args.teamdab then table.insert(row, args.teamdab) table.insert(row, '|') end

table.insert(row, args.team) table.insert(row, '

')

-- Player column table.insert(row, '\n|') if args.last then if yesno(args.hof) then table.insert(row, 'bgcolor="#ffcc00" ') elseif yesno(args.probowl) then table.insert(row, 'bgcolor="#faecc8" ') end

table.insert(row, 'data-sort-value="') table.insert(row, string.lower(args.last)) table.insert(row, ', ') table.insert(row, string.lower(args.first)) table.insert(row, '"|')

if yesno(args.playerpageexists, true) then table.insert(row, '') end end

table.insert(row, args.first) table.insert(row, ' ') table.insert(row, args.last)

if yesno(args.playerpageexists, true) then table.insert(row, '

') end

if yesno(args.probowl) then table.insert(row, '') end if yesno(args.hof) then table.insert(row, '') end else table.insert(row, ' ') end

-- positon column table.insert(row, '\n| ') if args.position then table.insert(row, americanFootballPositions._main(args.position, false)) if args.position2 then table.insert(row, '/') table.insert(row, americanFootballPositions._main(args.position2, false)) end else table.insert(row, ' ') end

table.insert(row, '\n|')

-- college col if args.college then local collegeLink = args.collegelink if not args.collegelink then collegeLink = args.college end

if yesno(args['cfb page exists']) then table.insert(row, '') table.insert(row, collegeLink) table.insert(row, '') else table.insert(row, mw.getCurrentFrame:expandTemplate) end

-- conference column table.insert(row, '\n|') if args.conference then table.insert(row, args.conference) else table.insert(row, collegeFootballConference._main(args.collegeyear, args.college)) end end

-- note column table.insert(row, '\n|')

if args.note then table.insert(row, '') table.insert(row, args.note) table.insert(row, '') end

return table.concat(row)end

return p