• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
Attempt to add base node exp to enemy comps
Line 5: Line 5:  
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
 
local ShipBattleCardKai = require("Module:ShipBattleCardKai")
 
local ShipBattleCardKai = require("Module:ShipBattleCardKai")
 
+
 
local NodeInfo = BaseTable({
 
local NodeInfo = BaseTable({
 
     _item_class = EnemyShip,
 
     _item_class = EnemyShip,
Line 11: Line 11:  
     _header_template = [[!#
 
     _header_template = [[!#
 
     !Formation
 
     !Formation
 +
!Base EXP
 
     !${node_type}
 
     !${node_type}
 
     !AD/AP<br>AS/AS+]],
 
     !AD/AP<br>AS/AS+]],
Line 18: Line 19:  
         node = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: center; color: ${color}; background-color: ${bg_color};" |${values.node}]],
 
         node = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: center; color: ${color}; background-color: ${bg_color};" |${values.node}]],
 
         formation = [[| style="text-align: center; background-color: ${bg_color}; color: ${color};" |${values.formation}]],
 
         formation = [[| style="text-align: center; background-color: ${bg_color}; color: ${color};" |${values.formation}]],
         fleet = [[| style="width: 490px; background-color: ${bg_color};" |${values.fleet}]],
+
         basexp = [[| style="text-align: center; background-color: ${bg_color}; color: ${color};" |${values.basexp}]],
 +
fleet = [[| style="width: 490px; background-color: ${bg_color};" |${values.fleet}]],
 
         as = [[| style="text-align: center; background-color: ${bg_color}; color: ${color};" |${values.as}]],
 
         as = [[| style="text-align: center; background-color: ${bg_color}; color: ${color};" |${values.as}]],
 
     },
 
     },
Line 33: Line 35:  
         "node",
 
         "node",
 
         "formation",
 
         "formation",
 +
"basexp",
 
         "fleet",
 
         "fleet",
 
         "as",
 
         "as",
Line 48: Line 51:  
     _maelstrom_node_bg_color = "initial",
 
     _maelstrom_node_bg_color = "initial",
 
})
 
})
 
+
 
function NodeInfo:node(row)
 
function NodeInfo:node(row)
 
     local color, bg_color = "initial", "initial"
 
     local color, bg_color = "initial", "initial"
Line 74: Line 77:  
     return { values = { node = Formatting:japanese_text(row.node) }, color = color, bg_color = bg_color }
 
     return { values = { node = Formatting:japanese_text(row.node) }, color = color, bg_color = bg_color }
 
end
 
end
 
+
 
function NodeInfo:formation(row)
 
function NodeInfo:formation(row)
 
     if row.tags.final then
 
     if row.tags.final then
Line 86: Line 89:  
end
 
end
    +
function NodeInfo:basexp(row)
 +
return { values = { basexp = row.basexp } }
 +
end
 +
 
function NodeInfo:fleet(row)
 
function NodeInfo:fleet(row)
 
     return { values = { fleet = row.fleet } }
 
     return { values = { fleet = row.fleet } }
 
end
 
end
 
+
 
function NodeInfo:as(row)
 
function NodeInfo:as(row)
 
     color = "initial"
 
     color = "initial"
Line 97: Line 104:  
     return { values = { as = row.as }, color = color }
 
     return { values = { as = row.as }, color = color }
 
end
 
end
 
+
 
function NodeInfo:upcase(str)
 
function NodeInfo:upcase(str)
 
     str = str:gsub("(%s)(%l)", function(a, b) return a .. string.upper(b) end)
 
     str = str:gsub("(%s)(%l)", function(a, b) return a .. string.upper(b) end)
Line 103: Line 110:  
     return str
 
     return str
 
end
 
end
 
+
function NodeInfo:insert_item(node, formation, fleet, as, tags, as_complete)
+
function NodeInfo:insert_item(node, formation, basexp, fleet, as, tags, as_complete)
 
--[=[
 
--[=[
 
     -- Can give weird results when major contributors to air power are unknown
 
     -- Can give weird results when major contributors to air power are unknown
Line 132: Line 139:  
         node = node,
 
         node = node,
 
         formation = formation,
 
         formation = formation,
 +
basexp = basexp,
 
         fleet = fleet,
 
         fleet = fleet,
 
         as = air_string,
 
         as = air_string,
Line 137: Line 145:  
     })
 
     })
 
end
 
end
 
+
 
function NodeInfo:create_items()  
 
function NodeInfo:create_items()  
 
     --Modes are as follows:
 
     --Modes are as follows:
Line 145: Line 153:  
     --4 = Amount of resources
 
     --4 = Amount of resources
 
     --5 = Formation
 
     --5 = Formation
     --6 = Fleet building
+
--6 = Base node exp
 +
     --7 = Fleet building
 
     local mode = 1
 
     local mode = 1
   
+
     local node, formation = nil, nil
+
     local node, formation, basexp = nil, nil, 0
 
     local fleet = {}
 
     local fleet = {}
 
     local as_rating, as_complete = 0, true
 
     local as_rating, as_complete = 0, true
   
+
 
     local tags = {}
 
     local tags = {}
 
     local resource
 
     local resource
 
for index, item_key in ipairs(self._args) do
 
for index, item_key in ipairs(self._args) do
 
if item_key == "-" then
 
if item_key == "-" then
    if mode == 6 then --We're at a break and have built a full row; time to insert it
+
    if mode == 7 then --We're at a break and have built a full row; time to insert it
        self:insert_item(node, formation, table.concat(fleet, " "), as_rating, tags, as_complete)
+
        self:insert_item(node, formation, basexp, table.concat(fleet, " "), as_rating, tags, as_complete)
 
    end
 
    end
   
+
 
table.insert(self._items, "break")
 
table.insert(self._items, "break")
+
 
fleet, as_rating, as_complete = {}, 0, true
 
fleet, as_rating, as_complete = {}, 0, true
 
tags = {}
 
tags = {}
Line 211: Line 220:  
        mode = 6
 
        mode = 6
 
    else
 
    else
        --Fleets are of variable size, so we append onto a string until we hit the next node declaration
+
if mode == 6 and tonumber(item_key) then
        local split = mw.ustring.find(item_key, '/')
+
basexp = item_key
        local ship_name, ship_suffix
+
else
        if split then
+
--Fleets are of variable size, so we append onto a string until we hit the next node declaration
            ship_name = mw.ustring.sub(item_key, 1, split - 1)
+
local split = mw.ustring.find(item_key, '/')
            ship_suffix = mw.ustring.sub(item_key, split + 1)
+
local ship_name, ship_suffix
        else
+
if split then
            ship_name = item_key
+
ship_name = mw.ustring.sub(item_key, 1, split - 1)
            ship_suffix = ""
+
ship_suffix = mw.ustring.sub(item_key, split + 1)
        end
+
else
 +
ship_name = item_key
 +
ship_suffix = ""
 +
end
   −
        local ship = EnemyShip(ship_name, ship_suffix)
+
local ship = EnemyShip(ship_name, ship_suffix)
        local ship_air_power = ship:air_power(tags.raid)
+
local ship_air_power = ship:air_power(tags.raid)
   −
        local ship_caption =
+
local ship_caption =
            (ship:name() or "?")
+
(ship:name() or "?")
            .. " (" .. Formatting:format_enemy_stat(ship:api_id()) .. "): "
+
.. " (" .. Formatting:format_enemy_stat(ship:api_id()) .. "): "
            .. (ship:armor() or "?") .. " Armor, " .. (ship:hp() or "?") .. " HP"
+
.. (ship:armor() or "?") .. " Armor, " .. (ship:hp() or "?") .. " HP"
            .. (ship_air_power ~= 0 and ", " .. (ship_air_power or "?") .. " AP" or "")
+
.. (ship_air_power ~= 0 and ", " .. (ship_air_power or "?") .. " AP" or "")
   −
        table.insert(fleet, ShipBattleCardKai:get{
+
table.insert(fleet, ShipBattleCardKai:get{
            ship = ship,
+
ship = ship,
            caption = ship_caption,
+
caption = ship_caption,
            link = ship:link(),
+
link = ship:link(),
            flagship = #fleet == 0
+
flagship = #fleet == 0
                })
+
})
   −
        if ship_air_power then
+
if ship_air_power then
            as_rating = as_rating + ship_air_power
+
as_rating = as_rating + ship_air_power
        else
+
else
            as_complete = false
+
as_complete = false
        end
+
end
 +
if mode == 6 then
 +
-- only check for the base node experience once
 +
mode = 7
 +
end
 +
end
 
             end
 
             end
 
end
 
end
 
     end
 
     end
     if mode == 6 then
+
     if mode == 7 then
         self:insert_item(node, formation, table.concat(fleet, " "), as_rating, tags, as_complete)
+
         self:insert_item(node, formation, basexp, table.concat(fleet, " "), as_rating, tags, as_complete)
 
     end
 
     end
 
end
 
end
 
+
 
function NodeInfo:create_data_rows()
 
function NodeInfo:create_data_rows()
 
     for index, item in ipairs(self._items) do
 
     for index, item in ipairs(self._items) do
Line 289: Line 306:  
end
 
end
 
end
 
end
 
+
 
function NodeInfo:format_node_type()
 
function NodeInfo:format_node_type()
 
     local node_types = {
 
     local node_types = {
Line 306: Line 323:  
     return self._args["comment"] or node_types[self._node_type] or "Fleet"
 
     return self._args["comment"] or node_types[self._node_type] or "Fleet"
 
end
 
end
 
+
 
function NodeInfo:is_simple_node_type()
 
function NodeInfo:is_simple_node_type()
 
     return self._node_type == 'resource' or self._node_type == 'storm' or self._node_type == 'empty' or self._node_type == 'select'
 
     return self._node_type == 'resource' or self._node_type == 'storm' or self._node_type == 'empty' or self._node_type == 'select'
 
end
 
end
 
+
 
function NodeInfo:create_header()
 
function NodeInfo:create_header()
 
     local header_string = format{
 
     local header_string = format{
Line 319: Line 336:  
     self._header_bottom = header_string
 
     self._header_bottom = header_string
 
end
 
end
 
+
 
function NodeInfo:start_rows()
 
function NodeInfo:start_rows()
 
     self._rows = {}
 
     self._rows = {}
   
+
 
     if self._args["toggle_id"] then
 
     if self._args["toggle_id"] then
 
         table.insert(self._rows, format{self._collapser_template,
 
         table.insert(self._rows, format{self._collapser_template,
Line 329: Line 346:  
         })
 
         })
 
     end
 
     end
   
+
 
     table.insert(self._rows, self._table_start)
 
     table.insert(self._rows, self._table_start)
 
     table.insert(self._rows, self._header)
 
     table.insert(self._rows, self._header)
 
end
 
end
 
+
 
function NodeInfo:process_resource_node(resource, amount)
 
function NodeInfo:process_resource_node(resource, amount)
 
     --Amount may or may not be just numbers
 
     --Amount may or may not be just numbers
 
     local action, units, node_type, bg_color = "Gained", "", "Resource", self._resource_node_bg_color
 
     local action, units, node_type, bg_color = "Gained", "", "Resource", self._resource_node_bg_color
   
+
 
     if mw.ustring.sub(amount, 1, 1) == "-" then
 
     if mw.ustring.sub(amount, 1, 1) == "-" then
 
         action = "Lost"
 
         action = "Lost"
Line 344: Line 361:  
         bg_color = self._maelstrom_node_bg_color
 
         bg_color = self._maelstrom_node_bg_color
 
     end
 
     end
   
+
 
     if mw.ustring.find(amount, " ") then
 
     if mw.ustring.find(amount, " ") then
 
         local split = mw.ustring.find(amount, " ")
 
         local split = mw.ustring.find(amount, " ")
Line 350: Line 367:  
         amount = mw.ustring.sub(amount, 1, split - 1)
 
         amount = mw.ustring.sub(amount, 1, split - 1)
 
     end
 
     end
   
+
 
     local text = action .. " " .. amount .. " " .. resource .. " " .. units
 
     local text = action .. " " .. amount .. " " .. resource .. " " .. units
 
     return text, node_type, bg_color
 
     return text, node_type, bg_color
 
end
 
end
 
+
 
function NodeInfo:build_rows()
 
function NodeInfo:build_rows()
 
     local bg_color
 
     local bg_color
Line 409: Line 426:  
     end
 
     end
 
end
 
end
 
+
 
function NodeInfo:finish_rows()
 
function NodeInfo:finish_rows()
 
     table.insert(self._rows, self._row_starter)
 
     table.insert(self._rows, self._row_starter)
Line 418: Line 435:  
     end
 
     end
 
end
 
end
 
+
 
U.registerTableTests(NodeInfo, {
 
U.registerTableTests(NodeInfo, {
 
     { "A", "Boss", "Line Ahead", "Northern Princess" }
 
     { "A", "Boss", "Line Ahead", "Northern Princess" }
 
})
 
})
 
-- p.run_table_tests()
 
-- p.run_table_tests()
 
+
 
return NodeInfo
 
return NodeInfo

Navigation menu