モジュール:コンクエ表
このモジュールについての説明文ページを モジュール:コンクエ表/doc に作成できます
--[[
モジュール呼び出し用関数の引数リスト
|DateStart=
|DateEnd=
|Title=
|RedTeamName=
|Red1=
|Red2=
|Red3=
|Red4=
|Red5=
|Red6=
|Red7=
|Red8=
|BlueTeamName=
|Blue1=
|Blue2=
|Blue3=
|Blue4=
|Blue5=
|Blue6=
|Blue7=
|Blue8=
|GreenTeamName=
|Green1=
|Green2=
|Green3=
|Green4=
|Green5=
|Green6=
|Green7=
|Green8=
|RedWorld3ds=
|BlueWorld3ds=
|GreenWorld3ds=
|RedAsia3ds=
|BlueAsia3ds=
|GreenAsia3ds=
|RedAmericas3ds=
|BlueAmericas3ds=
|GreenAmericas3ds=
|RedEurope3ds=
|BlueEurope3ds=
|GreenEurope3ds=
|RedWorldWiiU=
|BlueWorldWiiU=
|GreenWorldWiiU=
|RedJapanWiiU=
|BlueJapanWiiU=
|GreenJapanWiiU=
|RedAmericasWiiU=
|BlueAmericasWiiU=
|GreenAmericasWiiU=
|RedEuropeWiiU=
|BlueEuropeWiiU=
|GreenEuropeWiiU=
]]--
--[[
デバッグ用コード例
=p.main(
mw.getCurrentFrame():newChild{
title="Module:コンクエ表",
args={["DateStart"]="2015/1/2",
["DateEnd"]="2015/1/5",
["Title"]="対決!健康 VS 剣豪",
["RedTeamName"]="健康チーム",
["Red1"]="Wii Fit トレーナー",
["Red2"]="ドクターマリオ",
["Red3"]="",
["Red4"]="",
["Red5"]="",
["BlueTeamName"]="剣豪チーム",
["Blue1"]="アイク",
["Blue2"]="メタナイト",
["Blue3"]="",
["Blue4"]="",
["Blue5"]="",
["GreenTeamName"]="",
["Green1"]="",
["Green2"]="",
["Green3"]="",
["Green4"]="",
["Green5"]="",
["RedWorld3ds"]="31",
["BlueWorld3ds"]="69",
["GreenWorld3ds"]="",
["RedAsia3ds"]="30",
["BlueAsia3ds"]="70",
["GreenAsia3ds"]="",
["RedAmericas3ds"]="34",
["BlueAmericas3ds"]="66",
["GreenAmericas3ds"]="",
["RedEurope3ds"]="28",
["BlueEurope3ds"]="72",
["GreenEurope3ds"]="",
["RedWorldWiiU"]="35",
["BlueWorldWiiU"]="65",
["GreenWorldWiiU"]="",
["RedJapanWiiU"]="33",
["BlueJapanWiiU"]="67",
["GreenJapanWiiU"]="",
["RedAmericasWiiU"]="36",
["BlueAmericasWiiU"]="64",
["GreenAmericasWiiU"]="",
["RedEuropeWiiU"]="30",
["BlueEuropeWiiU"]="70",
["GreenEuropeWiiU"]=""}
}
)
]]--
local p = {}
local RESULTS = { WIN = 3, LOSE = 2, NONE = 1 }
local FIGHTER_CLASSNAME = {
{"トゥーンリンク", "toon"},
{"クッパJr.", "jr"},
{"ゼロスーツサムス", "zeros"},
{"ブラックピット", "bpit"},
{"キャプテン・ファルコン", "cf"},
{"ドクターマリオ", "drmario"},
{"マリオ", "mario"},
{"ルイージ", "luigi"},
{"ピーチ", "peach"},
{"クッパ", "koopa"},
{"ヨッシー", "yoshi"},
{"ロゼッタ&チコ", "rosetta"},
{"ワリオ", "wario"},
{"Mr.ゲーム&ウォッチ", "gw"},
{"ドンキーコング", "dk"},
{"ディディーコング", "dd"},
{"リンク", "link"},
{"ゼルダ", "zelda"},
{"シーク", "sheik"},
{"ガノンドロフ", "ganon"},
{"サムス", "samus"},
{"ピット", "pit"},
{"パルテナ", "palutena"},
{"マルス", "marth"},
{"アイク", "ike"},
{"ルフレ", "reflet"},
{"カービィ", "kirby"},
{"デデデ", "dedede"},
{"メタナイト", "meta"},
{"リトル・マック", "mac"},
{"フォックス", "fox"},
{"ファルコ", "falco"},
{"ピカチュウ", "pikachu"},
{"リザードン", "lizardon"},
{"ルカリオ", "lucario"},
{"プリン", "purin"},
{"ゲッコウガ", "gekkouga"},
{"ダックハント", "duckhunt"},
{"ロボット", "rob"},
{"ネス", "ness"},
{"むらびと", "murabito"},
{"ピクミン&オリマー", "olimar"},
{"Wii Fit トレーナー", "wiifit"},
{"ルキナ", "lucina"},
{"シュルク", "shulk"},
{"パックマン", "pac"},
{"ロックマン", "rockman"},
{"ソニック", "sonic"},
{"ミュウツー", "mewtwo"},
{"リュカ", "lucas"},
{"ロイ", "roy"},
{"リュウ", "ryu"},
{"クラウド", "cloud"},
{"カムイ", "kamui"},
{"ベヨネッタ", "bayo"}
}
local DASH = "—"
---- utils ----
-- 引数がnil or 空文字 or ;ならtrue
local function isEmpty(a)
if a == nil or a == "" or a == ";" then
return true
end
return false
end
-- 引数の配列の各要素をisEmptyに渡してその結果が全てtrueならばtrue
local function isEmptyAll(a)
local nonEmptyFlag = false
for idx, val in pairs(a) do
if isEmpty(val) == false then
nonEmptyFlag = true
break
end
end
if nonEmptyFlag == true then
return false
end
return true
end
-- booleanがtrueの場合はtを返す。falseの場合はfを返す。
local function ifElse(boolean, tFn, fFn)
if boolean == true then
return tFn()
end
return fFn()
end
-- テーブルをディープコピー
-- https://monobook.org/wiki/Lua%E3%81%A7%E3%83%87%E3%82%A3%E3%83%BC%E3%83%97%E3%82%B3%E3%83%94%E3%83%BC%E3%82%92%E3%81%99%E3%82%8B
local function deepcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
-- tableなら再帰でコピー
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key)] = deepcopy(orig_value)
end
setmetatable(copy, deepcopy(getmetatable(orig)))
else
-- number, string, booleanなどはそのままコピー
copy = orig
end
return copy
end
-- 連想配列の指定したキーの値を取得する。キーは文字列で、何階層でも指定可能。キーが存在しなかった場合はnilを返す。
local function path(t, ...)
local current = t
for _, key in ipairs({...}) do
if type(current) ~= "table" then return nil end
current = current[key]
end
return current
end
-- 引数の文字列中の連続する半角スペース、改行、インデントを一つの半角スペースに変換
local function trimWhitespaces(str)
return str:gsub("%s+", " "):match("^%s*(.-)%s*$")
end
-- 引数の型が数値ならそのまま返す。文字列型の数値なら数値型に変換して返す。それ以外なら0を返す。
local function toNum(a)
local r = tonumber(a)
if r == nil then
return 0
end
return r
end
-- 対象のテーブルの値に、指定のvalが存在するかどうか。
-- https://秀丸マクロ.net/lua_tips/?Lua+implements_func_table
local function includes (tbl, val)
for k, v in pairs (tbl) do
if v==val then return true end
end
return false
end
-- 引数で受け取った複数のテーブルを結合して返す。
-- https://秀丸マクロ.net/lua_tips/?Lua+implements_func_table
local function mergeTables (...)
local r = {}
for _, l in ipairs ({...}) do
if type(l) == "table" then
-- 整数がキーの要素
for _, v in ipairs (l) do
table.insert (r, v)
end
-- 整数以外がキーの要素
for k, v in pairs (l) do
if not (type(k)=="number" and k%1==0) then
r[k] = v
end
end
end
end
return r
end
-- javascriptのfilter関数と同等機能
-- https://秀丸マクロ.net/lua_tips/?Lua+implements_func_table
local function filter(tbl, func)
local res = {}
for i, v in ipairs(tbl) do
if func(i, v) then
res[1+#res] = v --高速
end
end
for k, v in pairs(tbl) do
if func(k, v) then
-- 整数以外がキーの要素
if not (type(k)=="number" and k%1==0) then
res[k] = v
end
end
end
return res
end
-- テーブルからempty要素を除去
local function removeEmpties(tbl)
return filter(tbl, function(k, v) return isEmpty(v) == false end)
end
-- 文字列strに含まれるfind全てをreplaceに置換する
--[[
local function replaceAll(str, find, replace)
error(mw.dumpObject({a=type(str), b=type(find), c=type(replace)}))
return str:gsub(find:gsub("%p", "%%%0"), replace)
end
]]--
-- 文字列aに含まれるすべてのbをcに置換する。
local function replaceAll(a, b, c)
local result = string.gsub(a, b, c)
return result
end
---- リザルトデータ変換系 ----
-- 引数に3勢力の%を受け取り、targetの勝敗を返す。targetが空文字ならNONEを、targetがa以上かつb以上ならWINを、どちらでもないならLOSEを返す。
local function winOrLoseOrNone(target, a, b)
if isEmpty(target) == true then
return RESULTS.NONE
end
local t = toNum(target)
if t >= toNum(a) and t >= toNum(b) then
return RESULTS.WIN
end
return RESULTS.LOSE
end
-- 引数に3勢力の%を受け取り、それぞれの勝敗を返す。{red:RESULTS, blue: RESULTS, green: RESULTS}
local function percentagesIntoTeamsResult(red, blue, green)
return {
red = winOrLoseOrNone(red, blue, green),
blue = winOrLoseOrNone(blue, red, green),
green = winOrLoseOrNone(green, red, blue)
}
end
-- 勢力の勝敗結果をもとにセル背景色rgbaを作成
local function teamsResultIntoRgba(redBlueGreen)
local list = {
{"red", [[rgba(255, 0, 0, %s)]], redBlueGreen.red},
{"blue", [[rgba(0, 0, 255, %s)]], redBlueGreen.blue},
{"green", [[rgba(0, 191, 0, %s)]], redBlueGreen.green}
}
local temp = {}
for key, val in pairs(list) do
if val[3] == RESULTS.WIN then
temp[val[1]] = string.format(val[2], 0.5)
elseif val[3] == RESULTS.LOSE then
temp[val[1]] = string.format(val[2], 0.125)
else
temp[val[1]] = ""
end
end
return temp
end
-- 引数で受け取ったファイター名を対応するクラス名に変換して返す。
local function fighterNameIntoClassName(fname)
if isEmpty(fname) == true then
return ""
end
for idx, val in pairs(FIGHTER_CLASSNAME) do
if val[1] == fname then
return val[2]
end
end
error("不正なファイター名: " .. fname)
end
-- エリア名を表すオブジェクトのキー名をwikiでの表示名に変換
local function areaNameKeyIntoViewText(key)
if key == [[asia]] then
return [[アジア]]
end
if key == [[americas]] then
return [[北米・南米]]
end
if key == [[europe]] then
return [[欧・オ]]
end
if key == [[japan]] then
return [[日本]]
end
--使わないかも
if key == [[world]] then
return [[世界]]
end
error("不正なエリア名キー: " .. key)
end
---- その他 ----
local function makeTeamDataTemplate()
local teamDataTempalceC = {
percentage = nil,
bgColor = nil,
}
local teamDataTemplate = {
name = nil,
members = {},
results = {
["3ds"] = {
world = teamDataTempalceC,
asia = teamDataTempalceC,
americas = teamDataTempalceC,
europe = teamDataTempalceC
},
wiiU = {
world = teamDataTempalceC,
japan = teamDataTempalceC,
americas = teamDataTempalceC,
europe = teamDataTempalceC
}
}
}
return teamDataTemplate
end
-- テーブルのrowspan指定部分を生成。WiiU発売前なら3(3DSとWiiU行を連結しない)、WiiU発売後なら6(連結する)
local function makeRowSpan(noWiiUEra)
return string.format(
[[rowspan=%s]],
ifElse(
noWiiUEra,
function() return 3 end,
function() return 6 end
)
)
end
TeamData = {}
-- 勢力データ クラスもどき --
TeamData.new = function(data, frame)
local obj = {}
obj.data = data
obj.frame = frame
-- 勢力メンバーを対応クラス名に変換して1つの文字列にして返す。
function obj:fighterNamesIntoClassNames()
local temp = {}
for idx, val in pairs(self.data.members) do
table.insert(
temp,
fighterNameIntoClassName(val)
)
end
return table.concat(temp, " ")
end
-- ファイター名配列の各要素で頭アイコンテンプレートを生成して1つの文字列にして返す。
function obj:makeHeadIcons()
local temp = {}
for idx, val in pairs(self.data.members) do
if isEmpty(val) == false then
table.insert(
temp,
self.frame:expandTemplate{ title = '頭アイコン', args = { c=val, g='for', s='32px' } }
)
end
end
return table.concat(temp, "")
end
-- 3DSとWiiU両方がある勢力の、所属ファイター一覧セルの背景色スタイル。セルの上半分が3DSの結果色、下半分がWiiUの結果色となるように、2色グラデーションで表現している。
function obj:makeStyleTwoBgColor()
local str = [[
background: linear-gradient(
transparent 1%%,
★3ds★ 1%%,
★3ds★ 50%%,
★WiiU★ 50%%,
★WiiU★
);
background: -webkit-linear-gradient(
transparent 1%%,
★3ds★ 1%%,
★3ds★ 50%%,
★WiiU★ 50%%,
★WiiU★
);
]]
--error(mw.dumpObject({a=self.data.results["3ds"].world.bgColor, b=self.data.results.wiiU.world.bgColor}))
--[[
local a, b = xpcall(replaceAll, "★3ds★", self.data.results["3ds"].world.bgColor)
if a == false then
error(mw.dumpObject({a=a, b=b, c= self.data.results["3ds"].world.bgColor, d=type(self.data.results["3ds"].world.bgColor)}))
end
xpcall(replaceAll, "★WiiU★", self.data.results.wiiU.world.bgColor)
if type(self.data.results["3ds"].world.bgColor) ~= "string" then
error(mw.dumpObject({a=type(self.data.results["3ds"].world.bgColor), b=self.data}))
end
]]--
str = replaceAll(str, "★3ds★", self.data.results["3ds"].world.bgColor)
str = replaceAll(str, "★WiiU★", self.data.results.wiiU.world.bgColor)
return str
end
-- 勢力紹介(勢力名と所属ファイター表記)セルを生成。
-- rowspan:WiiU発売前は3、発売後は6(3DS行とWiiU行を結合)
-- 背景色:勢力がある場合のみつける。WiiU発売前は単一色。色は世界の勝敗色。
-- 顔アイコンとタイトル:勢力があれば記載し、なければ横線。
-- 中央に点線:WiiU発売後のみ描画。
-- WiiU行からは呼び出さない。WiiU発売後は行結合で、発売前はWiiU行には横線を描画するのみ。
function obj:makeCellTeamMembers(noWiiUEra)
local style = [[
★rowspan★
style="
width:200px;
padding:0;
position:relative;
★bgColor★
"
]]
local view = [[
<div
style="
z-index:1;
position:relative;
"
>
★icons★
<p style="margin:0;">
★teamName★
</p>
</div>
★border★
]]
local rowspan = makeRowSpan(noWiiUEra)
local bgColor = ""
local icons = ""
local teamName = ""
local border = ""
if #self.data.members == 0 then
-- 勢力無しの場合
view = DASH
elseif noWiiUEra == true then
-- WiiU発売前
bgColor = [[background-color: ]] .. self.data.results["3ds"].world.bgColor .. [[;]]
icons = self:makeHeadIcons()
teamName = self.data.name
else
-- WiiU発売後
bgColor = self:makeStyleTwoBgColor()
icons = self:makeHeadIcons()
teamName = self.data.name
border = [[
<hr
style="
z-index:0;
margin: auto;
width:100%;
height:0;
position:absolute;
top: 0;
bottom: 0;
background-color: transparent;
border-top: 1px dashed #aaa;
"
>
]]
end
style = replaceAll(style, "★rowspan★", rowspan)
style = replaceAll(style, "★bgColor★", bgColor)
view = replaceAll(view, "★icons★", icons)
view = replaceAll(view, "★teamName★", teamName)
view = replaceAll(view, "★border★", border)
return table.concat({trimWhitespaces(style), trimWhitespaces(view)}, "|")
end
-- エリア名セルと獲得パーセントセルを生成。
function obj:makeCellsAreaNameAndPercentage(console, areaName)
local t = [[
style="
white-space:nowrap;
font-size:75%;
★bgColor★
"
|★areaName★
||style="
font-size:75%;
★bgColor★
"
|★text★
]]
-- local bgColor = path(self.data, "results", console, areaName, "bgColor")
--[[
if self.data.results[console][areaName] == nil then
error(mw.dumpObject({a = console, b = areaName, c = self.data.results}))
end
]]--
local bgColor = self.data.results[console][areaName].bgColor
local viewAreaName = areaNameKeyIntoViewText(areaName)
-- local per = path(self.data, "results", console, areaName, "percentage")
local per = self.data.results[console][areaName].percentage
t = replaceAll(t, "★bgColor★", ifElse(
isEmpty(bgColor),
function() return "" end,
function() return [[background-color: ]] .. bgColor .. ";" end
))
t = replaceAll(t, "★areaName★", viewAreaName)
t = replaceAll(t, "★text★", ifElse(
isEmpty(per),
function() return DASH end,
function() return per .. [[%%]] end
))
return trimWhitespaces(t)
end
-- 世界の%セルを生成。
function obj:makeCellWorldPercentage(console)
-- local bgColor = path(self.data, "results", console, "world", "bgColor")
local bgColor = self.data.results[console].world.bgColor
local per = self.data.results[console].world.percentage
local bgStyle = string.format(
[[style="background: %s";]],
ifElse(
isEmpty(bgColor),
function() return "" end,
function() return bgColor end
)
)
-- 参加してるなら↑のstyleを、不参加勢力ならスタイル無し
local style = string.format(
[[rowspan=3 %s]],
ifElse(
isEmpty(per),
function() return "" end,
function() return bgStyle end
)
)
local view = ifElse(
isEmpty(per),
function() return DASH end,
function() return per .. [[%]] end
)
return table.concat({trimWhitespaces(style), trimWhitespaces(view)}, "|")
end
return obj
end
--[[
params:
dateStart
dateEnd
title
red
name
members
[...]
results
3ds
world
percentage
bgColor
asia
americas
europe
results
wiiU
world
japan
americas
europe
]]--
local function buildWikiTable(params, frame)
local noWiiUEra = isEmptyAll({params.red.results.wiiU.world.percentage, params.blue.results.wiiU.world.percentage, params.green.results.wiiU.world.percentage})
local red = TeamData.new(params.red, frame)
local blue = TeamData.new(params.blue, frame)
local green = TeamData.new(params.green, frame)
local noWiiUCell = [[|rowspan=3|]] .. DASH
-- メモ:
-- ・rowspan=nのあとに続く | は同じ行に書かなければならない。
-- ・文字列の記述を""" と[[]]で混在させてしまった。
local markdowns = {
-- 行 抽出スクリプト用のクラス指定
string.format(
[[|- class="conc %s"]],
table.concat({
red:fighterNamesIntoClassNames(),
blue:fighterNamesIntoClassNames(),
green:fighterNamesIntoClassNames()
}, " ")),
-- 1列目の上半分 「3」(3DS)
[[|rowspan=3 style="color:#d01312;" |'''''3''''']],
-- 2列目 開始日と終了日のセル
string.format([[|rowspan=6 | %s ~ <br />%s]], params.dateStart, params.dateEnd),
-- 題のセル。WiiUがあればrowspanが6に(1行に)、なければ3に(2行に)
string.format([[|%s|%s]], makeRowSpan(noWiiUEra), [[''']] .. params.title .. [[''']]),
-- 赤勢力紹介セル。
[[|]] .. red:makeCellTeamMembers(noWiiUEra),
-- 3DS赤勢力のアジアセル。
[[|]] .. red:makeCellsAreaNameAndPercentage("3ds", "asia"),
-- 3DS赤勢力の世界セル。
[[|]] .. red:makeCellWorldPercentage("3ds"),
-- 青勢力紹介セル。
[[|]] .. blue:makeCellTeamMembers(noWiiUEra),
-- 3DS青勢力のアジアセル。
[[|]] .. blue:makeCellsAreaNameAndPercentage("3ds", "asia"),
-- 3DS青勢力の世界セル。
[[|]] .. blue:makeCellWorldPercentage("3ds"),
-- 緑勢力紹介セル。
[[|]] .. green:makeCellTeamMembers(noWiiUEra),
-- 3DS緑勢力のアジアセル。
[[|]] .. green:makeCellsAreaNameAndPercentage("3ds", "asia"),
-- 3DS緑勢力の世界セル。
[[|]] .. green:makeCellWorldPercentage("3ds"),
[[|-]],
-- 3DS赤勢力の北米・南米セル。
[[|]] .. red:makeCellsAreaNameAndPercentage("3ds", "americas"),
-- 3DS青勢力の北米・南米セル。
[[|]] .. blue:makeCellsAreaNameAndPercentage("3ds", "americas"),
-- 3DS緑勢力の北米・南米セル。
[[|]] .. green:makeCellsAreaNameAndPercentage("3ds", "americas"),
[[|-]],
-- 3DS赤勢力の欧州・オセアニアセル。
[[|]] .. red:makeCellsAreaNameAndPercentage("3ds", "europe"),
-- 3DS青勢力の欧州・オセアニアセル。
[[|]] .. blue:makeCellsAreaNameAndPercentage("3ds", "europe"),
-- 3DS緑勢力の欧州・オセアニアセル。
[[|]] .. green:makeCellsAreaNameAndPercentage("3ds", "europe"),
[[|-]],
-- 1列目の下半分 「U」(Wii U)
[[|rowspan=3 style="color:#0095CA;" |'''''U''''']],
-- 題のセル。WiiU発売前は横線を、発売後は何も記述しないことで3DSのセルと結合する。
ifElse(
noWiiUEra,
function() return noWiiUCell end,
function() return "" end
),
-- WiiU赤勢力紹介セル。WiiU発売前は横線を、発売後は何も記述しないことで3DSのセルと結合する。
ifElse(
noWiiUEra,
function() return noWiiUCell end,
function() return "" end
),
-- WiiU赤勢力の日本セル。
[[|]] .. red:makeCellsAreaNameAndPercentage("wiiU", "japan"),
-- WiiU赤勢力の世界セル。
[[|]] .. red:makeCellWorldPercentage("wiiU"),
-- WiiU青勢力紹介セル。
ifElse(
noWiiUEra,
function() return noWiiUCell end,
function() return "" end
),
-- WiiU青勢力の日本セル。
[[|]] .. blue:makeCellsAreaNameAndPercentage("wiiU", "japan"),
-- WiiU青勢力の世界セル。
[[|]] .. blue:makeCellWorldPercentage("wiiU"),
-- WiiU緑勢力紹介セル。
ifElse(
noWiiUEra,
function() return noWiiUCell end,
function() return "" end
),
-- WiiU緑勢力の日本セル。
[[|]] .. green:makeCellsAreaNameAndPercentage("wiiU", "japan"),
-- WiiU緑勢力の世界セル。
[[|]] .. green:makeCellWorldPercentage("wiiU"),
[[|-]],
-- WiiU赤勢力の北米・南米セル。
[[|]] .. red:makeCellsAreaNameAndPercentage("wiiU", "americas"),
-- WiiU青勢力の北米・南米セル。
[[|]] .. blue:makeCellsAreaNameAndPercentage("wiiU", "americas"),
-- WiiU緑勢力の北米・南米セル。
[[|]] .. green:makeCellsAreaNameAndPercentage("wiiU", "americas"),
[[|-]],
-- WiiU赤勢力の欧州・オセアニアセル。
[[|]] .. red:makeCellsAreaNameAndPercentage("wiiU", "europe"),
-- WiiU青勢力の欧州・オセアニアセル。
[[|]] .. blue:makeCellsAreaNameAndPercentage("wiiU", "europe"),
-- WiiU緑勢力の欧州・オセアニアセル。
[[|]] .. green:makeCellsAreaNameAndPercentage("wiiU", "europe"),
}
return table.concat(removeEmpties(markdowns), "\n")
end
function p.main(frame)
local a = frame.args
local red = makeTeamDataTemplate()
local blue = makeTeamDataTemplate()
local green = makeTeamDataTemplate()
local bgColor3ds = {
world = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedWorld3ds, a.BlueWorld3ds, a.GreenWorld3ds)),
asia = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedAsia3ds, a.BlueAsia3ds, a.GreenAsia3ds)),
americas = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedAmericas3ds, a.BlueAmericas3ds, a.GreenAmericas3ds)),
europe = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedEurope3ds, a.BlueEurope3ds, a.GreenEurope3ds))
}
local bgColorWiiU = {
world = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedWorldWiiU, a.BlueWorldWiiU, a.GreenWorldWiiU)),
japan = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedJapanWiiU, a.BlueJapanWiiU, a.GreenJapanWiiU)),
americas = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedAmericasWiiU, a.BlueAmericasWiiU, a.GreenAmericasWiiU)),
europe = teamsResultIntoRgba(percentagesIntoTeamsResult(a.RedEuropeWiiU, a.BlueEuropeWiiU, a.GreenEuropeWiiU))
}
if isEmpty(a.Red1) == false then
red.name = a.RedTeamName
red.members = removeEmpties({ a.Red1, a.Red2, a.Red3, a.Red4, a.Red5, a.Red6, a.Red7, a.Red8 })
-- 参加している勢力であるならば、3DSは必ずある。
red.results["3ds"] = {
world = {
percentage = a.RedWorld3ds,
bgColor = bgColor3ds.world.red
},
asia = {
percentage = a.RedAsia3ds,
bgColor = bgColor3ds.asia.red
},
americas = {
percentage = a.RedAmericas3ds,
bgColor = bgColor3ds.americas.red
},
europe = {
percentage = a.RedEurope3ds,
bgColor = bgColor3ds.europe.red
},
}
-- WiiU発売前であれば、3DSはあってもWiiUは無い。
if isEmpty(a.RedWorldWiiU) == false then
red.results.wiiU = {
world = {
percentage = a.RedWorldWiiU,
bgColor = bgColorWiiU.world.red
},
japan = {
percentage = a.RedJapanWiiU,
bgColor = bgColorWiiU.japan.red
},
americas = {
percentage = a.RedAmericasWiiU,
bgColor = bgColorWiiU.americas.red
},
europe = {
percentage = a.RedEuropeWiiU,
bgColor = bgColorWiiU.europe.red
},
}
end
end
if isEmpty(a.Blue1) == false then
blue.name = a.BlueTeamName
blue.members = removeEmpties({ a.Blue1, a.Blue2, a.Blue3, a.Blue4, a.Blue5, a.Blue6, a.Blue7, a.Blue8 })
blue.results["3ds"] = {
world = {
percentage = a.BlueWorld3ds,
bgColor = bgColor3ds.world.blue
},
asia = {
percentage = a.BlueAsia3ds,
bgColor = bgColor3ds.asia.blue
},
americas = {
percentage = a.BlueAmericas3ds,
bgColor = bgColor3ds.americas.blue
},
europe = {
percentage = a.BlueEurope3ds,
bgColor = bgColor3ds.europe.blue
},
}
if isEmpty(a.BlueWorldWiiU) == false then
blue.results.wiiU = {
world = {
percentage = a.BlueWorldWiiU,
bgColor = bgColorWiiU.world.blue
},
japan = {
percentage = a.BlueJapanWiiU,
bgColor = bgColorWiiU.japan.blue
},
americas = {
percentage = a.BlueAmericasWiiU,
bgColor = bgColorWiiU.americas.blue
},
europe = {
percentage = a.BlueEuropeWiiU,
bgColor = bgColorWiiU.europe.blue
},
}
end
end
if isEmpty(a.Green1) == false then
green.name = a.GreenTeamName
green.members = removeEmpties({ a.Green1, a.Green2, a.Green3, a.Green4, a.Green5, a.Green6, a.Green7, a.Green8 })
green.results["3ds"] = {
world = {
percentage = a.GreenWorld3ds,
bgColor = bgColor3ds.world.green
},
asia = {
percentage = a.GreenAsia3ds,
bgColor = bgColor3ds.asia.green
},
americas = {
percentage = a.GreenAmericas3ds,
bgColor = bgColor3ds.americas.green
},
europe = {
percentage = a.GreenEurope3ds,
bgColor = bgColor3ds.europe.green
},
}
if isEmpty(a.GreenWorldWiiU) == false then
green.results.wiiU = {
world = {
percentage = a.GreenWorldWiiU,
bgColor = bgColorWiiU.world.green
},
japan = {
percentage = a.GreenJapanWiiU,
bgColor = bgColorWiiU.japan.green
},
americas = {
percentage = a.GreenAmericasWiiU,
bgColor = bgColorWiiU.americas.green
},
europe = {
percentage = a.GreenEuropeWiiU,
bgColor = bgColorWiiU.europe.green
},
}
end
end
local params = {
dateStart = a.DateStart,
dateEnd = a.DateEnd,
title = a.Title,
red = red,
blue = blue,
green = green
}
local r = buildWikiTable(params, frame)
return r
end
return p