- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:ShipSeasonalQuotes"
Jump to navigation
Jump to search
(Created page with "local Utils = require("Module:Utils") local format = require("Module:StringInterpolation").format local templates = { header = [[{| class="wikitable typography-xl-optout"...") |
m (10 revisions imported) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | local Utils = require("Module: | + | local Utils = require("Module:Core") |
− | local format = require("Module: | + | local format = require("Module:Core").format |
local templates = { | local templates = { | ||
− | header = [[{| class="wikitable | + | header = [[{| class="wikitable toggle-target-ship-quotes" style="width:100%" |
!style="width:10%;"|Event | !style="width:10%;"|Event | ||
!Japanese | !Japanese | ||
Line 17: | Line 17: | ||
} | } | ||
− | local seasons = | + | local seasons = require("Module:Collection/Seasons") |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
local ShipSeasonalQuotes = {} | local ShipSeasonalQuotes = {} | ||
Line 49: | Line 37: | ||
end | end | ||
+ | -- Template:ShipSeasonalQuotes | ||
function ShipSeasonalQuotes.format(frame, args) | function ShipSeasonalQuotes.format(frame, args) | ||
args = args or Utils.getTemplateArgs(frame) | args = args or Utils.getTemplateArgs(frame) | ||
− | local ship = args. | + | local ship = args.explicit["1"] or args.implicit.pagename |
− | local ship2 = args.explicit | + | local ship2 = args.explicit["2"] |
local result = {} | local result = {} | ||
table.insert(result, templates.header) | table.insert(result, templates.header) | ||
for _, season in ipairs(seasons) do | for _, season in ipairs(seasons) do | ||
− | local seasonData = require(string.format("Module: | + | local seasonData = require(string.format("Module:Data/Season/%s", season)) |
if ship2 then | if ship2 then | ||
addRow(result, seasonData, season, ship, format{templates.as_ship, ship = ship}) | addRow(result, seasonData, season, ship, format{templates.as_ship, ship = ship}) | ||
addRow(result, seasonData, season, ship2, format{templates.as_ship, ship = ship2}) | addRow(result, seasonData, season, ship2, format{templates.as_ship, ship = ship2}) | ||
else | else | ||
− | addRow(result, seasonData, ship) | + | addRow(result, seasonData, season, ship) |
end | end | ||
end | end | ||
Line 67: | Line 56: | ||
return table.concat(result, "\n") | return table.concat(result, "\n") | ||
end | end | ||
− | |||
− | |||
return ShipSeasonalQuotes | return ShipSeasonalQuotes |
Latest revision as of 12:44, 12 May 2021
Documentation for this module may be created at Module:ShipSeasonalQuotes/doc
local Utils = require("Module:Core")
local format = require("Module:Core").format
local templates = {
header = [[{| class="wikitable toggle-target-ship-quotes" style="width:100%"
!style="width:10%;"|Event
!Japanese
!English
!Note]],
footer = "|}",
row = [=[|-
|nowrap="nowrap"|[[Seasonal/${season}|${season}]]<br><span class="audio-button click-parent">[[Media:${ship} ${season}.ogg|Play]]</span>
|lang="ja"|${ja}
|${en}
|${note}]=],
as_ship = [[''As ${ship}'']]
}
local seasons = require("Module:Collection/Seasons")
local ShipSeasonalQuotes = {}
function addRow(result, seasonData, season, ship, note_prefix)
local shipData = seasonData.ships[ship]
if shipData then
for _, lineData in ipairs(shipData) do
table.insert(result, format{
templates.row,
ship = ship,
season = season,
ja = lineData.ja,
en = lineData.en,
note = (note_prefix or "") .. (note_prefix and lineData.note and "<br>" or "") .. (lineData.note or ""),
})
end
end
end
-- Template:ShipSeasonalQuotes
function ShipSeasonalQuotes.format(frame, args)
args = args or Utils.getTemplateArgs(frame)
local ship = args.explicit["1"] or args.implicit.pagename
local ship2 = args.explicit["2"]
local result = {}
table.insert(result, templates.header)
for _, season in ipairs(seasons) do
local seasonData = require(string.format("Module:Data/Season/%s", season))
if ship2 then
addRow(result, seasonData, season, ship, format{templates.as_ship, ship = ship})
addRow(result, seasonData, season, ship2, format{templates.as_ship, ship = ship2})
else
addRow(result, seasonData, season, ship)
end
end
table.insert(result, templates.footer)
return table.concat(result, "\n")
end
return ShipSeasonalQuotes