Module:F1 2021 Results
MyWikiBiz, Author Your Legacy — Saturday November 23, 2024
Jump to navigationJump to searchThis will be a replacement for the very complex F1R2021 template. This is currently a work in progress.
Usage
{{#invoke:F1 2021 Results|function_name}}
local p = {}; local data = { ["VER"] = { ["_points"] = 105, ["BHR"] = "2", ["EMI"] = "1", ["POR"] = "2", ["ESP"] = "2", ["MON"] = "1", ["AZE"] = "", }, ["NOR"] = { ["_points"] = 56, ["BHR"] = "4", ["EMI"] = "3", ["POR"] = "5", ["ESP"] = "8", ["MON"] = "3", ["AZE"] = "", }, ["ALO"] = { ["_points"] = 5, ["BHR"] = "Ret", ["EMI"] = "10", ["POR"] = "8", ["ESP"] = "17", ["MON"] = "13", ["AZE"] = "", }, } local colorCodes = { ["1"] = "#FFFFBF", ["2"] = "#DFDFDF", ["3"] = "#FFDF9F", ["Ret"] = "#EFCFFF", ["NC"] = "#CFCFFF", ["DNQ"] = "#FFCFCF", ["DNPQ"] = "#FFCFCF", ["DSQ"] = "#000000; color:white", ["DNS"] = "#FFFFFF", ["C"] = "#FFFFFF", } local function getColor(result) local colorFromTable = colorCodes[result] if colorFromTable ~= nil then return colorFromTable end local resultAsNumber = tonumber(result) if resultAsNumber ~= nil then if 4 <= resultAsNumber and resultAsNumber <= 10 then return "#DFFFDF" elseif 11 <= resultAsNumber then return "#CFCFFF" end end return "none" end function p.getRaceResult(frame) local driverCode = frame.args[1] local raceCode = frame.args[2] local result = data[driverCode][raceCode] local color = getColor(result) return 'style="background:' .. color .. ';"|' .. result end function p.getPoints(frame) local driverCode = frame.args[1] return data[driverCode]["_points"] end function p.test() -- For debug only mw.log(p.getRaceResult({args={"VER", "BHR"}})) mw.log(p.getPoints({args={"VER"}})) end return p