• 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
(db.kcwiki.moe moved to db.kcwiki.cn. Note DB does not have old events (< Fall 2021 at this writing), so older links are broken.)
 
(58 intermediate revisions by 3 users not shown)
Line 1: Line 1:
local Utils = require('Module:Utils')
+
local U = require('Module:Core')
local format = require('Module:StringInterpolation').format
 
 
local NodeInfo = require('Module:NodeInfo')
 
local NodeInfo = require('Module:NodeInfo')
  
local title_template_simple_event = [[<div id="${map} ${node} ${diff}" style="width:700px;text-align:center;">${map} ${node}: ${name}</div>
+
local templates = {
]]
+
    title = '<div id="${map} ${node}">${map} ${node}${nameSuffix} ([https://db.kcwiki.cn/drop/map/${world_number}${map_number}/${node}-SAB.html PoiDB])</div>\n',
 
+
    title_simple = '<div id="${map} ${node}">${map} ${node}${nameSuffix}</div>\n',
local title_template_event = [[<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>
+
    event_title = '<div id="${map} ${node} ${diff}">${map} ${diff} ${node}${nameSuffix} ([https://db.kcwiki.cn/drop/map/${world_number}${map_number}/${diff_number}/${node}-SAB.html PoiDB])</div>\n',
]]
+
    event_title_simple = '<div id="${map} ${node} ${diff}">${map} ${diff} ${node}${nameSuffix}</div>\n',
 
+
}
local title_template_simple = [[<div id="${map} ${node}" style="width:700px;text-align:center;">${map} ${node}: ${name}</div>
 
]]
 
 
 
local title_template = [[<div id="${map} ${node}" style="width:700px;text-align:center;">${map} ${node}: ${name} ([http://db.kcwiki.moe/drop/map/${world_number}${map_number}/${node}-SAB.html PoiDB])</div>
 
]]
 
  
local event_numbers = {
+
local world_numbers = {
 
     ["World 1"] = 1,
 
     ["World 1"] = 1,
 
     ["World 2"] = 2,
 
     ["World 2"] = 2,
Line 22: Line 16:
 
     ["World 5"] = 5,
 
     ["World 5"] = 5,
 
     ["World 6"] = 6,
 
     ["World 6"] = 6,
 +
    ["World 7"] = 7,
 
     ["Winter 2016 Event"] = 33,
 
     ["Winter 2016 Event"] = 33,
 
     ["Spring 2016 Event"] = 34,
 
     ["Spring 2016 Event"] = 34,
Line 31: Line 26:
 
     ["Fall 2017 Event"] = 40,
 
     ["Fall 2017 Event"] = 40,
 
     ["Winter 2018 Event"] = 41,
 
     ["Winter 2018 Event"] = 41,
 +
    ["Early Fall 2018 Event"] = 42,
 +
    ["Winter 2019 Event"] = 43,
 +
    ["Spring 2019 Event"] = 44,
 +
    ["Summer 2019 Event"] = 45,
 +
    ["Fall 2019 Event"] = 46,
 +
    ["Hinamatsuri 2020 Mini-Event"] = 47,
 +
    ["Rainy-Summer 2020 Event"] = 48,
 +
    ["Fall 2020 Event"] = 49,
 +
    ["Spring 2021 Event"] = 50,
 +
    ["Summer 2021 Event"] = 51,
 +
    ["Fall 2021 Event"] = 52,
 +
    ["Winter 2022 Event"] = 53,
 +
    ["Spring 2022 Event"] = 54,
 +
    ["Summer 2022 Event"] = 55,
 +
    ["Early Spring 2023 Event"] = 56,
 +
    ["Summer 2023 Event"] = 57,
 +
    ["Early Spring 2024 Event"] = 58,
 +
    ["Summer 2024 Event"] = 59,
 
}
 
}
  
local diff_numbers = {
+
local diff_numbers_legacy = {
 +
    ["Regular"] = 0,
 
     ["Easy"] = 1,
 
     ["Easy"] = 1,
 
     ["Normal"] = 2,
 
     ["Normal"] = 2,
Line 40: Line 54:
 
}
 
}
  
local diff_numbers2 = {
+
local diff_numbers = {
 +
    ["Regular"] = 0,
 
     ["Casual"] = 1,
 
     ["Casual"] = 1,
 
     ["Easy"] = 2,
 
     ["Easy"] = 2,
Line 46: Line 61:
 
     ["Hard"] = 4,
 
     ["Hard"] = 4,
 
}
 
}
 +
 +
local simple_node_types = { "Resource", "Storm", "Empty", "Select", "Raid", "Landing", "Repair" }
  
 
function formatTitle(pagename, args)
 
function formatTitle(pagename, args)
  
     local event, map = string.match(pagename, "([^/]+)/([^/]+)")
+
     local world, map = string.match(pagename, "([^/]+)/([^/]+)")
     event = event or "?"
+
     world = args.world or world or '??'
     map = map or "E-?"
+
    map = args.map or map or '??'
 +
 
 +
    local world_number = world_numbers[world] or "??"
 +
     local map_number = string.match(map:sub(3, 4), "%d") or "??"
  
     local event_number = event_numbers[event] or "?"
+
     local node = args[1] or "??"
      
+
     local node_type = args[2] or "??"
     local diffs = (event_number == "?" or event_number >= 41) and diff_numbers2 or diff_numbers
+
     local is_simple_node_type = node_type == "??" or U.ifind(simple_node_types, node_type)
  
     local node = args[1] or "?"
+
     local diffs = (world_number == "??" or world_number >= 41) and diff_numbers or diff_numbers_legacy
 
     local diff = diffs[args.diff] and args.diff
 
     local diff = diffs[args.diff] and args.diff
     local name = args.name or "?"
+
     local diff_number = diffs[diff] or "??"
 +
    local is_event_diff = diff and diff ~= 'Regular'
  
   
+
     local nameSuffix = args.name and ": " .. args.name or ""
     local map_number = string.match(map, "%d") or "?"
 
    local diff_number = diffs[diff]
 
  
     return diff and format{
+
     return U.format{
         node == "AB" and title_template_simple_event or title_template_event,
+
         (is_simple_node_type and
 +
            (is_event_diff and templates.event_title_simple or templates.title_simple) or
 +
            (is_event_diff and templates.event_title or templates.title)),
 
         map = map,
 
         map = map,
 
         node = node,
 
         node = node,
 
         diff = diff,
 
         diff = diff,
         name = name,
+
         nameSuffix = nameSuffix,
         event_number = event_number,
+
         world_number = world_number,
 
         map_number = map_number,
 
         map_number = map_number,
 
         diff_number = diff_number,
 
         diff_number = diff_number,
    } or format{
 
        node == "AB" and title_template_simple or title_template,
 
        map = map,
 
        node = node,
 
        name = name,
 
        world_number = event_number,
 
        map_number = map_number,
 
 
     }
 
     }
 
 
end
 
end
  
local NodeInfoInvoke = {}
+
return {
 
+
    Table = function(frame)
function NodeInfoInvoke.Table(frame)
+
        local args = U.getTemplateArgs(frame)
    local args = Utils.getTemplateArgs(frame)
+
        local world, map = string.match(args.implicit.pagename, "([^/]+)/([^/]+)")
    local table_string = NodeInfo:Table(args.explicit)
+
        args.implicit.world = args.explicit.world or world or '??'
    if args.explicit.diff or args.implicit.pagename and args.implicit.pagename:sub(1, 5) == "World" then
+
        args.implicit.map = args.explicit.map or map or '??'
        return formatTitle(args.implicit.pagename, args.explicit) .. table_string
+
        local table_string = NodeInfo:Table(args.explicit, args.implicit)
    else
+
        if args.explicit.diff or args.implicit.pagename and args.implicit.pagename:sub(1, 5) == "World" then
        return table_string
+
            return formatTitle(args.implicit.pagename, args.explicit) .. table_string
 +
        else
 +
            return table_string
 +
        end
 
     end
 
     end
end
+
}
 
 
return NodeInfoInvoke
 

Latest revision as of 20:41, 12 August 2024

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

local U = require('Module:Core')
local NodeInfo = require('Module:NodeInfo')

local templates = {
    title = '<div id="${map} ${node}">${map} ${node}${nameSuffix} ([https://db.kcwiki.cn/drop/map/${world_number}${map_number}/${node}-SAB.html PoiDB])</div>\n',
    title_simple = '<div id="${map} ${node}">${map} ${node}${nameSuffix}</div>\n',
    event_title = '<div id="${map} ${node} ${diff}">${map} ${diff} ${node}${nameSuffix} ([https://db.kcwiki.cn/drop/map/${world_number}${map_number}/${diff_number}/${node}-SAB.html PoiDB])</div>\n',
    event_title_simple = '<div id="${map} ${node} ${diff}">${map} ${diff} ${node}${nameSuffix}</div>\n',
}

local world_numbers = {
    ["World 1"] = 1,
    ["World 2"] = 2,
    ["World 3"] = 3,
    ["World 4"] = 4,
    ["World 5"] = 5,
    ["World 6"] = 6,
    ["World 7"] = 7,
    ["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,
    ["Early Fall 2018 Event"] = 42,
    ["Winter 2019 Event"] = 43,
    ["Spring 2019 Event"] = 44,
    ["Summer 2019 Event"] = 45,
    ["Fall 2019 Event"] = 46,
    ["Hinamatsuri 2020 Mini-Event"] = 47,
    ["Rainy-Summer 2020 Event"] = 48,
    ["Fall 2020 Event"] = 49,
    ["Spring 2021 Event"] = 50,
    ["Summer 2021 Event"] = 51,
    ["Fall 2021 Event"] = 52,
    ["Winter 2022 Event"] = 53,
    ["Spring 2022 Event"] = 54,
    ["Summer 2022 Event"] = 55,
    ["Early Spring 2023 Event"] = 56,
    ["Summer 2023 Event"] = 57,
    ["Early Spring 2024 Event"] = 58,
    ["Summer 2024 Event"] = 59,
}

local diff_numbers_legacy = {
    ["Regular"] = 0,
    ["Easy"] = 1,
    ["Normal"] = 2,
    ["Medium"] = 2,
    ["Hard"] = 3,
}

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

local simple_node_types = { "Resource", "Storm", "Empty", "Select", "Raid", "Landing", "Repair" }

function formatTitle(pagename, args)

    local world, map = string.match(pagename, "([^/]+)/([^/]+)")
    world = args.world or world or '??'
    map = args.map or map or '??'

    local world_number = world_numbers[world] or "??"
    local map_number = string.match(map:sub(3, 4), "%d") or "??"

    local node = args[1] or "??"
    local node_type = args[2] or "??"
    local is_simple_node_type = node_type == "??" or U.ifind(simple_node_types, node_type)

    local diffs = (world_number == "??" or world_number >= 41) and diff_numbers or diff_numbers_legacy
    local diff = diffs[args.diff] and args.diff
    local diff_number = diffs[diff] or "??"
    local is_event_diff = diff and diff ~= 'Regular'

    local nameSuffix = args.name and ": " .. args.name or ""

    return U.format{
        (is_simple_node_type and
            (is_event_diff and templates.event_title_simple or templates.title_simple) or
            (is_event_diff and templates.event_title or templates.title)),
        map = map,
        node = node,
        diff = diff,
        nameSuffix = nameSuffix,
        world_number = world_number,
        map_number = map_number,
        diff_number = diff_number,
    }
end

return {
    Table = function(frame)
        local args = U.getTemplateArgs(frame)
        local world, map = string.match(args.implicit.pagename, "([^/]+)/([^/]+)")
        args.implicit.world = args.explicit.world or world or '??'
        args.implicit.map = args.explicit.map or map or '??'
        local table_string = NodeInfo:Table(args.explicit, args.implicit)
        if args.explicit.diff or args.implicit.pagename and args.implicit.pagename:sub(1, 5) == "World" then
            return formatTitle(args.implicit.pagename, args.explicit) .. table_string
        else
            return table_string
        end
    end
}