• 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
no edit summary
Line 21: Line 21:  
${rules}]],
 
${rules}]],
   −
     battle_node_label = [[<div class="kcRoute" style="vertical-align:middle"><div class="kcRouteNode" style="background:#FF0000;">${label}</div></div>]],
+
     battle_node_label = [[<div class="kcRoute" style="vertical-align:middle"><div class="kcRouteNode" style="background:${color};">${label}</div></div>]],
    
}
 
}
   −
function formatNodeLabel(label)
+
function formatNodeLabel(label, color)
     if label == "Start" then
+
     if label == "0" then
 
         return "'''Start'''"
 
         return "'''Start'''"
 +
    elseif label:match("%d") then
 +
        return format{templates.battle_node_label, label = label, color = "grey"}
 
     else
 
     else
         return format{templates.battle_node_label, label = label}
+
         return format{templates.battle_node_label, label = label, color = color}
 
     end
 
     end
 
end
 
end
    
function formatTable(args)
 
function formatTable(args)
     local branching = {
+
     local branching = { index = {}, }
        index = {},
  −
    }
   
     for route, rules in pairs(args) do
 
     for route, rules in pairs(args) do
 
         local from, to = route:match("(%S+)%s*->%s*(%S+)")
 
         local from, to = route:match("(%S+)%s*->%s*(%S+)")
 +
        local from_color = from:match("%S+/(%S+)")
 +
        local to_color = to:match("%S+/(%S+)")
 +
        from = from_color and from:match("(%S+)/") or from
 +
        to = to_color and to:match("(%S+)/") or to
 
         if not find(branching.index, from) then
 
         if not find(branching.index, from) then
 
             table.insert(branching.index, from)
 
             table.insert(branching.index, from)
 
         end
 
         end
 
         if not branching[from] then
 
         if not branching[from] then
             branching[from] = { index = {} }
+
             branching[from] = { color = from_color, index = {} }
 
         end
 
         end
         branching[from][to] = rules
+
         branching[from][to] = { color = to_color, rules = rules }
 
         if not find(branching[from].index, to) then
 
         if not find(branching[from].index, to) then
 
             table.insert(branching[from].index, to)
 
             table.insert(branching[from].index, to)
 
         end
 
         end
 +
    end
 +
    table.sort(branching.index)
 +
    for _, from in ipairs(branching.index) do
 +
        table.sort(branching[from].index)
 
     end
 
     end
 
     local rows = {}
 
     local rows = {}
Line 55: Line 63:  
             templates.table_row_start,
 
             templates.table_row_start,
 
             rowspan = #branching[from].index,
 
             rowspan = #branching[from].index,
             from = formatNodeLabel(from),
+
             from = formatNodeLabel(from, branching[from].color or "red"),
 
         })
 
         })
 
         local first = true
 
         local first = true
Line 62: Line 70:  
                 templates.table_row,
 
                 templates.table_row,
 
                 separator = first and "" or "|-\n",
 
                 separator = first and "" or "|-\n",
                 to = formatNodeLabel(to),
+
                 to = formatNodeLabel(to, branching[from][to].color or "red"),
                 rules = branching[from][to],
+
                 rules = branching[from][to].rules,
 
             })
 
             })
 
             first = false
 
             first = false
Line 78: Line 86:  
end
 
end
   −
-- MapBranchingTable.t = MapBranchingTable.format(nil, { ["Start -> A"] = "Fixed route", ["A -> B"] = "Random", ["A -> C"] = "Random" })
+
-- MapBranchingTable.t = MapBranchingTable.format(nil, { ["0 -> 1"] = "Fixed route", ["1 -> B/green"] = "Random", ["1 -> C"] = "Random" })
    
return MapBranchingTable
 
return MapBranchingTable
cssedit, gkautomate
7,064

edits

Navigation menu