Module:Sandbox/方之易小文/LuaTest
跳到导航
跳到搜索
local p = {} function p.main(frame) local days={{1028,1031,1104,1107,1112,0}, --预选阶段 {1117,1121,1125,1129,1203,1208,0}, --第一阶段(原:海蓝宝石) {1213,1217,1221,1225,1229,103,0}, --第二阶段(原:黄玉) {108,0}, --淘汰赛预赛 {112,0}, --胜者组第一轮&败者组第一轮 {116,0}, --胜者组半决赛&败者组第二轮 {120,0}, --胜者组决赛&败者组第三轮 {124,0}, --败者组第四轮 {128,0}, --总决赛 {201,0}, --决赛附加赛 {218,0}} --告别赛 local data={{'Preliminary','预选阶段','FF4500'}, {'Aquamarine','第一阶段','30C090'}, {'Topaz','第二阶段','D0A050'}, {'Preliminary Round','淘汰赛 - 预赛','E87B27'}, {'Winners&Losers Round 1','淘汰赛 - 第一轮','E87B27'}, {'Winners Semifinals & Losers Round 2','淘汰赛 - 胜者组半决赛&败者组第二轮','E87B27'}, {'Winners Finals & Losers Round 3','淘汰赛 - 胜者组决赛&败者组第三轮','E87B27'}, {'Losers Round 4','淘汰赛 - 败者组第四轮','E87B27'}, {'Finals','淘汰赛 - 总决赛','E87B27'}, {'Finals Plus','淘汰赛 - 决赛附加赛','E87B27'}, {'Farewell','告别赛','E87B27'}} local stage = 0 local round = 0 local en = '' local zh = '' local out = '' local args = tonumber(frame.args[1]) if (type(args) == 'nil') then return 0 end --根据 args 在 days 表中查找,以确定当前所处的阶段(stage)和轮次(round) for i, phase in ipairs(days) do for j, day in ipairs(phase) do if args == day then stage = i round = j end end end if stage == 0 then return 0 elseif days[stage][round+1] == 0 and data[stage][3] ~= 'FF4500' and data[stage][3] ~= 'E87B27' then en='style=\"width:250px;color:white;background:#'..data[stage][3]..'\"|'..data[stage][1]..' Necklace Showdown\n|' zh='-align=\"middle\"\n|style=\"width:250px;color:white;background:#'..data[stage][3]..'\"|<big><big>'..data[stage][2]..' - 项链及垂饰赛</big></big>' out = en..zh return out elseif days[stage][2] == 0 then en='style=\"width:250px;color:white;background:#'..data[stage][3]..'\"|'..data[stage][1]..'\n|' zh='-align=\"middle\"\n|style=\"width:250px;color:white;background:#'..data[stage][3]..'\"|<big><big>'..data[stage][2]..'</big></big>' out = en..zh return out else en='style=\"width:250px;color:white;background:#'..data[stage][3]..'\"|'..data[stage][1]..' '..round..'\n|' zh='-align=\"middle\"\n|style=\"width:250px;color:white;background:#'..data[stage][3]..'\"|<big><big>'..data[stage][2]..' - 第'..round..'轮</big></big>' out = en..zh return out end end return p