Module:Vocabulary
Documentation for this module may be created at Module:Vocabulary/doc
local p = {}
local nations = {
japan = { bi = "Japan", bv = "of Japan", bp = "Japanese", mp = "japanese" },
usa = { bi = "U.S.A.", bv = "of U.S.A.", bp = "American", mp = "american" },
ussr = { bi = "U.S.S.R.", bv = "of U.S.S.R.", bp = "Soviet", mp = "soviet" },
uk = { bi = "U.K.", bv = "of U.K.", bp = "British", mp = "british" },
germany = { bi = "Germany", bv = "of Germany", bp = "German", mp = "german" },
europe = { bi = "Europe", bv = "of Europe", bp = "European", mp = "european" },
pan_asia = { bi = "Pan-Asia", bv = "of Pan-Asia", bp = "Pan-Asian", mp = "pan-asian" },
france = { bi = "France", bv = "of France", bp = "French", mp = "french" },
commonwealth = { bi = "Commonwealth",bv = "of Commonwealth",bp = "Commonwealth",mp = "commonwealth" },
italy = { bi = "Italy", bv = "of Italy", bp = "Italian", mp = "italian" },
pan_america = { bi = "Pan-America", bv = "of Pan-America", bp = "Pan-American",mp = "pan-american" },
netherlands = { bi = "Netherlands", bv = "of Netherlands", bp = "Dutch", mp = "dutch" },
spain = { bi = "Spain", bv = "of Spain", bp = "Spanish", mp = "spanish" }
}
local classes = {
aircarrier = { bm = "Aircraft Carriers", ss = "aircraft carrier", bs = "Aircraft Carrier" },
battleship = { bm = "Battleships", ss = "battleship", bs = "Battleship" },
cruiser = { bm = "Cruisers", ss = "cruiser", bs = "Cruiser" },
destroyer = { bm = "Destroyers", ss = "destroyer", bs = "Destroyer" },
submarine = { bm = "Submarines", ss = "submarine", bs = "Submarine" },
undefined = { bm = "Submarines", ss = "submarine", bs = "Submarine" }
}
local tiers = {
['1'] = 'I', ['2'] = 'II', ['3'] = 'III', ['4'] = 'IV', ['5'] = 'V',
['6'] = 'VI', ['7'] = 'VII', ['8'] = 'VIII', ['9'] = 'IX', ['10'] = 'X',
['11'] = '★'
}
local function clean(val)
return val and mw.text.trim(tostring(val)):lower() or ""
end
local function getArgs(frame)
if type(frame) == 'table' and frame.args then
return frame.args
end
return frame
end
function p.nation(frame)
local args = getArgs(frame)
local id = clean(args[1])
local mode = clean(args[2]) or "bv"
if mode == "list" then
local f = (type(frame) == 'table' and frame.preprocess) and frame or mw.getCurrentFrame()
return f:preprocess('{{#shiplist:nations|}}')
end
local res = nations[id]
return res and res[mode] or "N/A"
end
function p.ship_class(frame)
local args = getArgs(frame)
local id = clean(args[1])
local mode = clean(args[2]) or "bm"
if mode == "list" then
return "Destroyer;Cruiser;Battleship;AirCarrier"
end
local res = classes[id]
return res and res[mode] or "N/A"
end
function p.tier(frame)
local args = getArgs(frame)
local id = mw.text.trim(tostring(args[1] or ""))
return tiers[id] or id
end
return p