• 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
m
no edit summary
Line 39: Line 39:     
function NodeInfo:node(row)
 
function NodeInfo:node(row)
     local color, time_color, bg_color = "initial", self._day_battle_color, "initial"
+
     local color, bg_color = "initial", self._day_battle_color, "initial"
     if row.boss then
+
     if row.tags.boss then
 
         color = self._boss_battle_color
 
         color = self._boss_battle_color
 
     end
 
     end
     if row.time == "Night" then
+
     if row.tags.night then
        time_color = self._night_battle_color
   
         bg_color = self._night_battle_bg_color
 
         bg_color = self._night_battle_bg_color
 
     end
 
     end
     return { values = { node = row.node, time = row.time }, color = color, time_color = time_color, bg_color = bg_color }
+
     return { values = { node = row.node }, color = color, bg_color = bg_color }
 
end
 
end
    
function NodeInfo:formation(row)
 
function NodeInfo:formation(row)
     if row.final then
+
     if row.tags.final then
 
         row.formation = row.formation .. " (Final)"
 
         row.formation = row.formation .. " (Final)"
 
     end
 
     end
 
     local color = "initial"
 
     local color = "initial"
     if row.boss then
+
     if row.tags.boss then
 
         color = self._boss_battle_color
 
         color = self._boss_battle_color
 
     end
 
     end
Line 67: Line 66:  
function NodeInfo:as(row)
 
function NodeInfo:as(row)
 
     color = "initial"
 
     color = "initial"
     if row.boss then
+
     if row.tags.boss then
 
         color = self._boss_battle_color
 
         color = self._boss_battle_color
 
     end
 
     end
Line 73: Line 72:  
end
 
end
   −
function NodeInfo:process_node(item)
+
function NodeInfo:insert_item(node, formation, fleet, as, tags)
    local split = mw.ustring.find(item, '/')
  −
local node, time
  −
if split then
  −
    node = mw.ustring.sub(item, 1, split - 1)
  −
    time = mw.ustring.sub(item, split + 1):gsub("^%l", string.upper)
  −
else
  −
    node = item:upper()
  −
    time = ""
  −
end
  −
return node, time
  −
end
  −
 
  −
function NodeInfo:insert_item(node, time, boss, final, formation, fleet, as, item_key)
   
     local air_parity = string.format("%.1d", as * (2 / 3))
 
     local air_parity = string.format("%.1d", as * (2 / 3))
 
     local air_supremacy = tostring(as * 2)
 
     local air_supremacy = tostring(as * 2)
Line 92: Line 78:  
     table.insert(self._items, {
 
     table.insert(self._items, {
 
         node = node,
 
         node = node,
        time = time,
  −
boss = boss,
  −
final = final,
   
formation = formation,
 
formation = formation,
 
fleet = fleet,
 
fleet = fleet,
 
as = air_string,
 
as = air_string,
 +
tags = tags,
 
})
 
})
 
end
 
end
    
function NodeInfo:create_items()
 
function NodeInfo:create_items()
 +
    --Modes are as follows:
 +
    --1 = Node
 +
    --2 = Tag processing
 +
    --3 = Resource type
 +
    --4 = Amount of resources
 +
    --5 = Formation
 +
    --6 = Fleet building
 
     local mode = 1
 
     local mode = 1
     local node, time, boss, final, formation, fleet, as_rating = nil, nil, false, false, nil, "", 0
+
   
 +
     local node, formation = nil, nil
 +
    local fleet = ""
 +
    local as_rating = 0
 +
   
 +
    local tags = {}
 +
    local resource
 
for index, item_key in ipairs(self._args) do
 
for index, item_key in ipairs(self._args) do
if item_key == "-" or mw.ustring.find(item_key, "#") then
+
if item_key == "-" then
    if mode == 3 then
+
    if mode == 6 then --We're at a break and have built a full row; time to insert it
        self:insert_item(node, time, boss, final, formation, fleet, as_rating, item_key)
+
        self:insert_item(node, formation, fleet, as_rating, tags)
 
    end
 
    end
 +
   
 
table.insert(self._items, "break")
 
table.insert(self._items, "break")
 
 
node, time, boss, final, formation, fleet, as_rating = nil, nil, false, false, nil, "", 0
+
fleet, as_rating = "", 0
 +
tags = {}
 
mode = 1
 
mode = 1
  −
if mw.ustring.find(item_key, "#") then
  −
    item_key = mw.ustring.sub(item_key, 2)
  −
   
  −
    --If it has no /, then it's an empty node; otherwise, it has a resource and number
  −
    if not mw.ustring.find(item_key, '/') then
  −
        table.insert(self._items, item_key .. "/empty")
  −
    else
  −
        table.insert(self._items, item_key)
  −
    end
  −
    table.insert(self._items, "break")
  −
end
   
else
 
else
--Each item will be just a string, so we need to check for one of the _columns, which will be done by mode
   
if mode == 1 then
 
if mode == 1 then
 
    --First item should always be the node
 
    --First item should always be the node
    --Node format: !node/day|night where the second part is day -or- night; ! indicates a boss node
+
    node = item_key
    if mw.ustring.sub(item_key, 1, 1) == "!" then
+
    mode = 2
        boss = true
+
elseif mode == 2 then
        item_key = mw.ustring.sub(item_key, 2)
+
    if string.lower(item_key) == "resource" or string.lower(item_key) == "storm" then
 +
        tags[string.lower(item_key)] = true
 +
        mode = 3
 +
    elseif string.lower(item_key) == "empty" then
 +
        table.insert(self._items, node .. "/empty")
 +
        mode = 1
 +
    else
 +
        while mw.ustring.find(item_key, '/') do
 +
            local split = mw.ustring.find(item_key, '/')
 +
            tags[string.lower(mw.ustring.sub(item_key, 1, split - 1))] = true
 +
            item_key = mw.ustring.sub(item_key, split + 1)
 +
        end
 +
        tags[string.lower(item_key)] = true
 +
        mode = 5
 
    end
 
    end
   
+
    elseif mode == 3 then
    --If there's a *, then it's a final form.
+
        resource = item_key
    if mw.ustring.sub(item_key, 1, 1) == "*" then
+
        mode = 4
        final = true
+
    elseif mode == 4 then
        item_key = mw.ustring.sub(item_key, 2)
+
        local amount = item_key
    end
+
        if tags["storm"] and mw.ustring.sub(amount, 1, 1) ~= "-" then
   
+
            amount = "-" .. amount
    node, time = self:process_node(item_key)
+
        end
    mode = 2
+
        local string = node .. "/" .. resource .. "/" .. amount
    elseif mode == 2 then
+
        table.insert(self._items, string)
 +
    elseif mode == 5 then
 
        formation = item_key
 
        formation = item_key
        mode = 3
+
        mode = 6
 
    else
 
    else
 
        --Fleets are of variable size, so we append onto a string until we hit the next node declaration
 
        --Fleets are of variable size, so we append onto a string until we hit the next node declaration
Line 170: Line 170:  
end
 
end
 
     end
 
     end
     if mode == 3 then
+
     if mode == 6 then
         self:insert_item(node, time, boss, final, formation, fleet, as_rating, item_key)
+
        for k, v in pairs(tags) do mw.log(k, v) end
 +
         self:insert_item(node, formation, fleet, as_rating, tags)
 
     end
 
     end
 
end
 
end
Line 191: Line 192:  
    local previous_cell = self._data_rows[i][column]
 
    local previous_cell = self._data_rows[i][column]
 
     if previous_cell then
 
     if previous_cell then
        if row_values[column].values.node == previous_cell.values.node and row_values[column].values.time == previous_cell.values.time then
+
        if row_values[column].values.node == previous_cell.values.node then
 
        previous_cell.rowspan = previous_cell.rowspan + 1
 
        previous_cell.rowspan = previous_cell.rowspan + 1
 
        row_values[column] = nil
 
        row_values[column] = nil
48

edits

Navigation menu