Module:Cite game
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Cite game/doc
local p = {}
local data = mw.loadData('Module:Cite game/data')
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame)
if args[1] == nil or args[2] == nil then
error ("Missing required parameters")
end
local game, tgt = args[1], args[2]
-- {{Cite game|AC1|M01}} -> game = AC1, tgt = M01
-- {{Cite game|ACEINF|COOP-ACD|HARD}} -> game = ACEINF, tgt = COOP-ACD
local tgtLang, tgtType, tgtNum, _, tgtStyle =
string.match(tgt, "([JPEN]*)(%a+)(%d+%+*%a*)(-*)(%a*)")
-- JPM01 -> tgtLang = JP, tgtType = M, tgtNum = 01, tgtStyle = empty string
-- M04A-M -> tgtLang = empty string, tgtType = M, tgtNum = 04A, tgtStyle = M
local citation = "" -- start building the citation output
if tgtType == "M" then -- Missions
citation = "Mission " .. tgtNum
if tgtStyle ~= "" and tgtStyle ~= nil and game == "ACZ" then
citation = citation .. tgtStyle
end
if tgtLang ~= nil and tgtLang ~= "" then
if game == "AC3" then
citation = citation .. ": \""
.. data[game][tgtLang .. tgtType .. tgtNum] .. "\""
else
error ("Languages are only supported with Ace Combat 3")
end
elseif game == "AC3" then
error ("Ace Combat 3 requires a language selection")
else
-- all other games
citation = citation .. ": \"" .. data[game][tgtType .. tgtNum]
.. "\""
end
if tgtStyle ~= "" and tgtStyle ~= nil then
if game == "ACZ" then
if tgtStyle == "M" then
citation = citation .. " (Mercenary)"
elseif tgtStyle == "S" then
citation = citation .. " (Soldier)"
elseif tgtStyle == "K" then
citation = citation .. " (Knight)"
else
error ("Invalid Ace Style")
end
elseif game == "AC6" then
citation = citation .. " (Operation " .. tgtStyle .. ")"
else
error ("Ace Styles and Operations are only supported with Ace Combat Zero and 6")
end
end
elseif tgtType == "Cut" then -- Cutscenes
if game == "AC04" or game == "ACX" or game == "ACJA" then
-- Names are the links themselves, wrap them in quotes
citation = "\"" .. data[game][tgtType .. tgtNum] .. "\""
elseif game == "ACZ" or game == "AC5" then
-- AC5 and ACZ are the only other games that classify them as Scenes
if game == "ACZ" and tgtStyle ~= "" and tgtStyle ~= nil then
-- ACZ changes some scenes depending on Ace Style
-- check if there is a specific scene for this number + style
local spScene = data[game][tgtType .. tgtNum .. "-" .. tgtStyle]
if spScene ~= nil then
citation = "Scene " .. tgtNum .. tgtStyle .. ": \""
.. spScene .. "\""
else
citation = "Scene " .. tgtNum .. tgtStyle .. ": \""
.. data[game][tgtType .. tgtNum]
if tgtStyle == "M" then
citation = citation .. " (Mercenary)"
elseif tgtStyle == "S" then
citation = citation .. " (Soldier)"
elseif tgtStyle == "K" then
citation = citation .. " (Knight)"
else
error ("Invalid Ace Style")
end
end
else
citation = "Scene " .. tgtNum .. ": \""
.. data[game][tgtType .. tgtNum] .. "\""
end
else
-- everything else is just called Cutscene with no special handling
citation = "Cutscene " .. tgtNum .. ": \""
.. data[game][tgtType .. tgtNum] .. "\""
end
elseif tgtType == "AM" then -- Arcade Mode
citation = "Arcade Mode " .. data[game][tgtType .. tgtNum]
elseif tgtType == "VR" then -- VR Mode
citation = data[game][tgtType .. tgtNum]
elseif tgtType == "SP" then -- SP Mission
citation = "SP Mission " .. tgtNum .. ": \""
.. data[game][tgtType .. tgtNum] .. "\""
elseif game == "ACEINF" then
local tgtCoop, _, tgtDiff = string.match(tgt, "(%a+)(-*)(%a*)")
if tgtCoop == "MDP" or tgtCoop == "SR" or tgtCoop == "SI" or tgtCoop == "EO" then -- Special Raid
if tgtDiff == "ALL" then
citation = "[[Special Raid]]s: \""
else
citation = "[[Special Raid]]: \""
end
citation = citation .. data[game][tgtCoop .. "-" .. tgtDiff] .. "\""
else
citation = "[[Online Co-Op Missions]]: \""
if tgtDiff ~= "" and tgtDiff ~= nil then
citation = citation .. data[game][tgtCoop .. "-" .. tgtDiff] .. "\""
else
citation = citation .. data[game][tgtCoop] .. "\""
end
end
else
error ("Invalid citation type")
end
local langOut = "" -- specifying language version for AC3
-- no need to check for AC3 w/o lang or lang w/o AC3, handled in missions
if tgtLang ~= "" and tgtLang ~= nil then
if tgtLang == "JP" then
langOut = " (Japanese)"
elseif tgtLang == "EN" then
langOut = " (export)"
else
error ("Only Japanese and export mission types are supported")
end
end
-- add game to citation
citation = citation .. ", ''" .. data[game]["link"] .. "''"
.. langOut .. "."
-- end the function
return citation
end
return p