• 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:NodeInfoInvoke"

From Kancolle Wiki
Jump to navigation Jump to search
m
m
Line 56: Line 56:
 
     local map_number = string.match(map, "%d") or "?"
 
     local map_number = string.match(map, "%d") or "?"
 
      
 
      
     if not diffs then
+
     if event_number <= 6 then
 
         title_template_simple = [[<div id="${map} ${node}" style="width:700px;text-align:center;">${map} ${node}: ${name}</div>
 
         title_template_simple = [[<div id="${map} ${node}" style="width:700px;text-align:center;">${map} ${node}: ${name}</div>
 
]]
 
]]

Revision as of 11:03, 7 April 2018

Documentation for this module may be created at Module:NodeInfoInvoke/doc

local Utils = require('Module:Utils')
local format = require('Module:StringInterpolation').format
local NodeInfo = require('Module:NodeInfo')

local title_template_simple = [[<div id="${map} ${node} ${diff}" style="width:700px;text-align:center;">${map} ${node}: ${name}</div>
]]

local title_template = [[<div id="${map} ${node} ${diff}" style="width:700px;text-align:center;">${map} ${node}: ${name} ([http://db.kcwiki.moe/drop/map/${event_number}${map_number}${diff_number}/${node}-SAB.html PoiDB])</div>
]]

local event_numbers = {
    ["World 1: 鎮守府海域"] = 1,
    ["World 2: 南西諸島海域"] = 2,
    ["World 3: 北方海域"] = 3,
    ["World 4: 西方海域"] = 4,
    ["World 5: 南方海域"] = 5,
    ["World 6: 中部海域"] = 6,
    ["Winter 2016 Event"] = 33,
    ["Spring 2016 Event"] = 34,
    ["Summer 2016 Event"] = 35,
    ["Fall 2016 Event"] = 36,
    ["Winter 2017 Event"] = 37,
    ["Spring 2017 Event"] = 38,
    ["Summer 2017 Event"] = 39,
    ["Fall 2017 Event"] = 40,
    ["Winter 2018 Event"] = 41,
}

local diff_numbers = {
    ["Easy"] = 1,
    ["Normal"] = 2,
    ["Medium"] = 2,
    ["Hard"] = 3,
}

local diff_numbers2 = {
    ["Casual"] = 1,
    ["Easy"] = 2,
    ["Medium"] = 3,
    ["Hard"] = 4,
}

function formatTitle(pagename, args)

    local event, map = string.match(pagename, "([^/]+)/([^/]+)")
    event = event or "?"
    map = map or "E-?"

    local event_number = event_numbers[event] or "?"

    local node = args[1] or "?"
    
    local name = args.name or "?"

    
    local map_number = string.match(map, "%d") or "?"
    
    if event_number <= 6 then
        title_template_simple = [[<div id="${map} ${node}" style="width:700px;text-align:center;">${map} ${node}: ${name}</div>
]]
        title_template = [[<div id="${map} ${node}" style="width:700px;text-align:center;">${map} ${node}: ${name} ([http://db.kcwiki.moe/drop/map/${event_number}${map_number}/${node}-SAB.html PoiDB])</div>
]]
        return format{
            node == "AB" and title_template_simple or title_template,
            map = map,
            node = node,
            name = name,
            event_number = event_number,
            map_number = map_number,
        }
    else 
        local diffs = (event_number == "?" or event_number >= 41) and diff_numbers2 or diff_numbers
        local diff_number = diffs[diff] or "?"
        local diff = diffs[args.diff] and args.diff or "?"
        return format{
            node == "AB" and title_template_simple or title_template,
            map = map,
            node = node,
            diff = diff,
            name = name,
            event_number = event_number,
            map_number = map_number,
            diff_number = diff_number,
        }
        end
end

local NodeInfoInvoke = {}

function NodeInfoInvoke.Table(frame)
    local args = Utils.getTemplateArgs(frame)
    local table_string = NodeInfo:Table(args.explicit)
    if args.explicit.diff then
        return formatTitle(args.implicit.pagename, args.explicit) .. table_string
    else
        return table_string
    end
end

return NodeInfoInvoke