Changes

m
46 revisions imported
Line 5: Line 5:  
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
   −
local format = require('Module:StringOperations').format
+
local U = require('Module:Core')
 +
local format = U.format
    
local ShipMetaKai = BaseData{
 
local ShipMetaKai = BaseData{
 
_template = [[{|class="${table_class}"  
 
_template = [[{|class="${table_class}"  
 
|-
 
|-
!class="infobox-kai-header-major" colspan=2|${name}
+
!class="infobox-kai-header-major" colspan=2|${name}<div style="float:right;margin-right:5px">${edit_link}</div>
 
|-
 
|-
 
!Class
 
!Class
Line 24: Line 25:  
|${availability}
 
|${availability}
 
|-
 
|-
!Implemented on
+
!Implementation
 
|${implementation_date}
 
|${implementation_date}
 
|}]],
 
|}]],
 
     _flat_template = [[{|class="${table_class}"  
 
     _flat_template = [[{|class="${table_class}"  
 
|-
 
|-
!class="infobox-kai-header-major" colspan=4|${name}
+
!class="infobox-kai-header-major" colspan=4|${name}<div style="float:right;margin-right:5px">${edit_link}</div>
 
|-
 
|-
 
!${voice_actor_header}
 
!${voice_actor_header}
Line 38: Line 39:  
!${artist_header}
 
!${artist_header}
 
|${artist}
 
|${artist}
!Implemented on
+
!Implementation
 
|${implementation_date}
 
|${implementation_date}
 
|}]],
 
|}]],
 +
    _ship_data_documentation = "Template:ShipDataDocumentation/EditIntro",
 +
    _edit_link_text = "Edit",
 
_voice_actor_header = "[[Glossary#List of Vessels by Japanese Voice Actresses|Seiyuu]]",
 
_voice_actor_header = "[[Glossary#List of Vessels by Japanese Voice Actresses|Seiyuu]]",
 
_artist_header = "[[Glossary#List of Vessels by Artist|Artist]]",
 
_artist_header = "[[Glossary#List of Vessels by Artist|Artist]]",
Line 46: Line 49:  
_name_template = "${name} ${japanese_name}",
 
_name_template = "${name} ${japanese_name}",
 
_person_template = "${name} (${japanese_name})",
 
_person_template = "${name} (${japanese_name})",
_normal_construction_label = "Normal",
+
_normal_construction_label = "[[Construction#Building_recipes|Normal]]",
_large_ship_construction_label = "LSC",
+
_large_ship_construction_label = "[[Construction#Large_Ship_Construction_Recipe|LSC]]",
 
_buildable_label = "Construction",
 
_buildable_label = "Construction",
 
_drop_label = "Drop",
 
_drop_label = "Drop",
 
_details_template = " (${details})",
 
_details_template = " (${details})",
_event_reward_label = "Event Reward",
+
_event_reward_label = "[[Template:Event_Drop|Event Reward]]",
_event_drop_label = "Event Drop",
+
_event_drop_label = "[[Template:Event_Drop|Event Drop]]",
_node_name_template = "${world}-${map}-${node}",
+
_node_name_template = "${world}-${map} ${node}",
 
_node_formation_template = "-${formation}",
 
_node_formation_template = "-${formation}",
_event_node_name_template = "${year} ${quarter} E-${map}-${node}",
+
_event_node_name_template = "${year} ${quarter} E-${map} ${node}",
 
_event_map_name_template = "${year} ${quarter} E-${map}",
 
_event_map_name_template = "${year} ${quarter} E-${map}",
_date_template = "${year}-${month}-${day}",
+
_date_template = "${year}/${month:2}/${day:2}",
 
_all_nodes_symbol = "*",
 
_all_nodes_symbol = "*",
 
_max_drops_before_collapsible = 6,
 
_max_drops_before_collapsible = 6,
Line 74: Line 77:  
},
 
},
 
_fields = {
 
_fields = {
 +
    "edit_link",
 
"name",
 
"name",
 
"class",
 
"class",
Line 87: Line 91:  
_args = args,
 
_args = args,
 
}:create_infobox()
 
}:create_infobox()
 +
end
 +
 +
function ShipMetaKai:edit_link()
 +
self._vars.edit_link = Formatting:format_edit_link(self._ship_data_module, self._edit_link_text, self._ship_data_documentation)
 
end
 
end
   Line 123: Line 131:  
return format{self._person_template, name = Formatting:format_external_link(person:link()), japanese_name = japanese_name}
 
return format{self._person_template, name = Formatting:format_external_link(person:link()), japanese_name = japanese_name}
 
end
 
end
 +
 +
local custom_quest_links = {
 +
    ["5A05"] = "Partials/Updates/2018_April_23rd#5A05"
 +
}
    
function ShipMetaKai:availability()
 
function ShipMetaKai:availability()
Line 137: Line 149:  
if buildable then
 
if buildable then
 
table.insert(result, self._buildable_label .. format{self._details_template, details = table.concat(buildable, ", ")})
 
table.insert(result, self._buildable_label .. format{self._details_template, details = table.concat(buildable, ", ")})
 +
end
 +
if availability and availability.quest then
 +
        table.insert(result, "Quest: " .. U.ijoin(U.imap(availability.quest, function(label)
 +
            return string.format("[[%s|%s]]", custom_quest_links[label] or string.format("Quests#%s", label), label)
 +
        end), ", "))
 
end
 
end
 
for _, method in ipairs(availability or {}) do
 
for _, method in ipairs(availability or {}) do
Line 161: Line 178:  
end
 
end
 
    local details_len = #details
 
    local details_len = #details
if details_len > 0 and self._detailed_availability then
+
if details_len > 0 then
 
details = format{self._details_template, details = table.concat(details, ", ")}
 
details = format{self._details_template, details = table.concat(details, ", ")}
 
if details_len > self._max_drops_before_collapsible then
 
if details_len > self._max_drops_before_collapsible then
Line 237: Line 254:     
function ShipMetaKai:implementation_date()
 
function ShipMetaKai:implementation_date()
local implementation_date = self._ship:implementation_date()
+
local form = self._ship
if implementation_date then
+
local next_form = form._remodel_to
self._vars.implementation_date = format{self._date_template, year = implementation_date[1], month = implementation_date[2], day = implementation_date[3]}
+
local i = 1
else
+
local data = {}
self._vars.implementation_date = "??"
+
local forms = {}
 +
if form._implementation_date then
 +
    data[format{
 +
    self._date_template,
 +
    year = form._implementation_date[1],
 +
    month = form._implementation_date[2],
 +
    day = form._implementation_date[3]
 +
}] = { "Base" }
 +
end
 +
while next_form and not forms[next_form] and i < 10 do
 +
    forms[next_form] = true
 +
    form = Ship(next_form)
 +
    if form._implementation_date then
 +
        local d = format{
 +
        self._date_template,
 +
        year = form._implementation_date[1],
 +
        month = form._implementation_date[2],
 +
        day = form._implementation_date[3]
 +
    }
 +
    local name = form:suffix() and form:suffix() ~= "" and form:suffix() or form:name()
 +
    data[d] = data[d] or {}
 +
        table.insert(data[d], name)
 +
    end
 +
    next_form = form._remodel_to
 +
        i = i + 1
 
end
 
end
 +
    local dates = U.isort(U.keys(data))
 +
self._vars.implementation_date = #dates == 0 and "??" or #dates == 1 and dates[1] or U.ijoin(U.imap(dates, function (d)
 +
return string.format("%s (%s)", d, U.ijoin(data[d], ", "))
 +
end), "<br>")
 
end
 
end
   Line 293: Line 338:  
return self:format_template()
 
return self:format_template()
 
end
 
end
 +
 +
function ShipMetaKai.test()
 +
    mw.log(ShipMetaKai:Infobox({ "Ayanami" }))
 +
    mw.log(ShipMetaKai:Infobox({ "U-511" }))
 +
    mw.log(ShipMetaKai:Infobox({ "Zuikaku" }))
 +
end
 +
-- p.test()
    
return ShipMetaKai
 
return ShipMetaKai
Bots, gkautomate
12,557

edits