| Line 23: |
Line 23: |
| | 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}]],
| + | 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}]], |
| | }, | | }, |
| − | _column_cell_templates_basexp = {
| + | _column_cell_templates_basexp = { |
| | 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}]], |
| − | basexp = [[| style="text-align: center; background-color: ${bg_color}; color: ${color};" |${values.basexp}]], | + | basexp = [[| style="text-align: center; background-color: ${bg_color}; color: ${color};" |${values.basexp}]], |
| − | fleet = [[| style="width: 490px; background-color: ${bg_color};" |${values.fleet}]],
| + | 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 48: |
Line 48: |
| | "as", | | "as", |
| | }, | | }, |
| − | _columns_basexp = {
| + | _columns_basexp = { |
| | "node", | | "node", |
| | "formation", | | "formation", |
| − | "basexp",
| + | "basexp", |
| | "fleet", | | "fleet", |
| | "as", | | "as", |
| Line 110: |
Line 110: |
| | color = self._boss_battle_color | | color = self._boss_battle_color |
| | end | | end |
| − | return { values = { basexp = row.basexp }, color = color }
| + | return { values = { basexp = row.basexp }, color = color } |
| | end | | end |
| | | | |
| Line 183: |
Line 183: |
| | --4 = Amount of resources | | --4 = Amount of resources |
| | --5 = Formation | | --5 = Formation |
| − | --6 = Base node exp
| + | --6 = Base node exp |
| | --7 = Fleet building | | --7 = Fleet building |
| | local mode = 1 | | local mode = 1 |
| Line 193: |
Line 193: |
| | local tags = {} | | local tags = {} |
| | local resource | | local resource |
| − | self._is_basexp = false
| |
| | | | |
| | 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 == 7 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, basexp, 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 = {}
| + | mode = 1 |
| − | mode = 1
| |
| | else | | else |
| − | if mode == 1 then
| + | if mode == 1 then |
| − | --First item should always be the node
| + | --First item should always be the node |
| − | node = item_key
| + | node = item_key |
| − | mode = 2
| + | mode = 2 |
| − | elseif mode == 2 then
| + | elseif mode == 2 then |
| − | -- underscores should be exclusive to modifier specification during mode 2
| + | self._node_type = string.lower(string.match(item_key, "(.-)/") or item_key) |
| − | if mw.ustring.find(item_key, '_') then
| + | if mw.ustring.find(string.lower(item_key), "resource") or string.lower(item_key) == "storm" then |
| − | -- capture modifiers here, then trim them off the node type
| + | local split = mw.ustring.find(item_key, '/') |
| − | if mw.ustring.find(item_key, 'BaseEXP') then
| + | if split then |
| − | self._is_basexp = true
| + | tags[string.lower(mw.ustring.sub(item_key, 1, split - 1))] = true |
| − | end
| + | item_key = mw.ustring.sub(item_key, split + 1) |
| − | local nodetypesolo = mw.ustring.sub(item_key, 1, mw.ustring.find(item_key, '_') - 1)
| + | end |
| − | self._node_type = string.lower(string.match(nodetypesolo, "(.-)/") or nodetypesolo)
| + | tags[string.lower(item_key)] = true |
| − | item_key = nodetypesolo;
| + | mode = 3 |
| − | else
| + | elseif string.lower(item_key) == "empty" then |
| − | self._node_type = string.lower(string.match(item_key, "(.-)/") or item_key)
| + | table.insert(self._items, node .. "/empty") |
| − | end
| + | mode = 1 |
| − | if mw.ustring.find(string.lower(item_key), "resource") or string.lower(item_key) == "storm" then
| + | elseif string.lower(item_key) == "select" then |
| − | local split = mw.ustring.find(item_key, '/')
| + | table.insert(self._items, node .. "/select") |
| − | if split then
| + | mode = 1 |
| − | tags[string.lower(mw.ustring.sub(item_key, 1, split - 1))] = true
| + | else |
| − | item_key = mw.ustring.sub(item_key, split + 1)
| + | while mw.ustring.find(item_key, '/') do |
| − | end
| + | local split = mw.ustring.find(item_key, '/') |
| − | tags[string.lower(item_key)] = true
| + | tags[string.lower(mw.ustring.sub(item_key, 1, split - 1))] = true |
| − | mode = 3
| + | item_key = mw.ustring.sub(item_key, split + 1) |
| − | elseif string.lower(item_key) == "empty" then
| + | end |
| − | table.insert(self._items, node .. "/empty")
| + | tags[string.lower(item_key)] = true |
| − | mode = 1
| + | if tags.basexp then |
| − | elseif string.lower(item_key) == "select" then
| + | -- used to communicate the need to account for node xp while building rows\ |
| − | table.insert(self._items, node .. "/select")
| + | self.is_basexp = true |
| − | mode = 1
| + | end |
| − | else
| + | mode = 5 |
| − | while mw.ustring.find(item_key, '/') do
| + | end |
| − | 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
| |
| | elseif mode == 3 then | | elseif mode == 3 then |
| | resource = self:upcase(item_key) | | resource = self:upcase(item_key) |
| Line 263: |
Line 254: |
| | mode = 6 | | mode = 6 |
| | else | | else |
| − | if mode == 6 and self._is_basexp then
| + | -- Only add basexp to the list of values if included as a tag |
| − | basexp = item_key
| + | if mode == 6 and tags.basexp then |
| − | mode = 7
| + | basexp = item_key |
| − | else
| + | mode = 7 |
| − | --Fleets are of variable size, so we append onto a string until we hit the next node declaration
| + | else |
| − | local split = mw.ustring.find(item_key, '/')
| + | --Fleets are of variable size, so we append onto a string until we hit the next node declaration |
| − | local ship_name, ship_suffix
| + | local split = mw.ustring.find(item_key, '/') |
| − | if split then
| + | local ship_name, ship_suffix |
| − | ship_name = mw.ustring.sub(item_key, 1, split - 1)
| + | if split then |
| − | ship_suffix = mw.ustring.sub(item_key, split + 1)
| + | ship_name = mw.ustring.sub(item_key, 1, split - 1) |
| − | else
| + | ship_suffix = mw.ustring.sub(item_key, split + 1) |
| − | ship_name = item_key
| + | else |
| − | ship_suffix = ""
| + | ship_name = item_key |
| − | end
| + | ship_suffix = "" |
| − |
| + | end |
| − | local ship = EnemyShip(ship_name, ship_suffix)
| + | |
| − | local ship_air_power = ship:air_power(tags.raid)
| + | local ship = EnemyShip(ship_name, ship_suffix) |
| − |
| + | local ship_air_power = ship:air_power(tags.raid) |
| − | local ship_caption =
| + | |
| − | (ship:name() or "?")
| + | local ship_caption = |
| − | .. " (" .. Formatting:format_enemy_stat(ship:api_id()) .. "): "
| + | (ship:name() or "?") |
| − | .. (ship:armor() or "?") .. " Armor, " .. (ship:hp() or "?") .. " HP"
| + | .. " (" .. Formatting:format_enemy_stat(ship:api_id()) .. "): " |
| − | .. (ship_air_power ~= 0 and ", " .. (ship_air_power or "?") .. " AP" or "")
| + | .. (ship:armor() or "?") .. " Armor, " .. (ship:hp() or "?") .. " HP" |
| − |
| + | .. (ship_air_power ~= 0 and ", " .. (ship_air_power or "?") .. " AP" or "") |
| − | table.insert(fleet, ShipBattleCardKai:get{
| + | |
| − | ship = ship,
| + | table.insert(fleet, ShipBattleCardKai:get{ |
| − | caption = ship_caption,
| + | ship = ship, |
| − | link = ship:link(),
| + | caption = ship_caption, |
| − | flagship = #fleet == 0
| + | link = ship:link(), |
| − | })
| + | flagship = #fleet == 0 |
| − |
| + | }) |
| − | if ship_air_power then
| + | |
| − | as_rating = as_rating + ship_air_power
| + | if ship_air_power then |
| − | else
| + | as_rating = as_rating + ship_air_power |
| − | as_complete = false
| + | else |
| − | end
| + | as_complete = false |
| − | if mode == 6 then
| + | end |
| − | mode = 7
| + | if mode == 6 then |
| − | end
| + | mode = 7 |
| − | end
| + | end |
| − | end
| + | end |
| | + | end |
| | end | | end |
| | end | | end |
| Line 315: |
Line 307: |
| | local row_values | | local row_values |
| | if type(item) == "string" then | | if type(item) == "string" then |
| − | row_values = item
| + | row_values = item |
| | else | | else |
| − | local columnuse = nil
| + | local columnuse = nil |
| − | if self._is_basexp then
| + | if item.tags.basexp then |
| − | columnuse = self._columns_basexp
| + | columnuse = self._columns_basexp |
| − | else
| + | else |
| − | columnuse = self._columns
| + | columnuse = self._columns |
| − | end
| + | end |
| − |
| + | |
| − | row_values = {}
| + | row_values = {} |
| − | for _, column in ipairs(columnuse) do
| + | for _, column in ipairs(columnuse) do |
| − | row_values[column] = self[column](self, item)
| + | row_values[column] = self[column](self, item) |
| − | end
| + | end |
| − | if index > 1 then
| + | if index > 1 then |
| − | for _, column in ipairs(columnuse) do
| + | for _, column in ipairs(columnuse) do |
| − | for i = index - 1, 1, -1 do
| + | for i = index - 1, 1, -1 do |
| − | if column == "node" then
| + | if column == "node" then |
| − | 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 then
| + | if row_values[column].values.node == previous_cell.values.node then |
| | previous_cell.rowspan = previous_cell.rowspan and previous_cell.rowspan + 1 or 2 | | previous_cell.rowspan = previous_cell.rowspan and previous_cell.rowspan + 1 or 2 |
| − | row_values[column] = nil
| + | row_values[column] = nil |
| − | else
| + | else |
| − | row_values[column].rowspan = 1
| + | row_values[column].rowspan = 1 |
| − | row_values[column].colspan = 1
| + | row_values[column].colspan = 1 |
| − | end
| + | end |
| − | break
| + | break |
| − | end
| + | end |
| | end | | end |
| | end | | end |
| | end | | end |
| | else | | else |
| − | for _, column in ipairs(columnuse) do
| + | for _, column in ipairs(columnuse) do |
| − | row_values[column].rowspan = 1
| + | row_values[column].rowspan = 1 |
| − | row_values[column].colspan = 1
| + | row_values[column].colspan = 1 |
| − | end
| + | end |
| − | end
| + | end |
| | end | | end |
| | table.insert(self._data_rows, row_values) | | table.insert(self._data_rows, row_values) |
| Line 376: |
Line 368: |
| | 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
| |
| − |
| |
| − | function NodeInfo:is_basexp()
| |
| − | return self._is_basexp
| |
| | end | | end |
| | | | |
| Line 386: |
Line 374: |
| | if self:is_simple_node_type() then | | if self:is_simple_node_type() then |
| | header_string = format{ | | header_string = format{ |
| − | self._header_template_simple,
| + | self._header_template_simple, |
| − | node_type = self:format_node_type()
| + | node_type = self:format_node_type() |
| | } | | } |
| − | elseif self:is_basexp() then | + | elseif self._is_basexp then |
| | header_string = format{ | | header_string = format{ |
| − | self._header_template_basexp,
| + | self._header_template_basexp, |
| − | node_type = self:format_node_type()
| + | node_type = self:format_node_type() |
| | } | | } |
| | else | | else |
| | header_string = format{ | | header_string = format{ |
| − | self._header_template,
| + | self._header_template, |
| − | node_type = self:format_node_type()
| + | node_type = self:format_node_type() |
| | } | | } |
| | end | | end |
| Line 438: |
Line 426: |
| | 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 |
| − | for index, row_values in ipairs(self._data_rows) do
| + | for index, row_values in ipairs(self._data_rows) do |
| − | if row_values ~= "break" then
| + | if row_values ~= "break" then |
| − | table.insert(self._rows, self._row_starter)
| + | table.insert(self._rows, self._row_starter) |
| − | if row_values == "header" then
| + | if row_values == "header" then |
| − | table.insert(self._rows, self._header)
| + | table.insert(self._rows, self._header) |
| | elseif type(row_values) == "table" then | | elseif type(row_values) == "table" then |
| | if row_values["node"] then | | if row_values["node"] then |
| Line 452: |
Line 440: |
| | bg_color = "initial" | | bg_color = "initial" |
| | end | | end |
| − | if self._is_basexp then
| + | if self._is_basexp then |
| − | for _, column in ipairs(self._columns_basexp) do
| + | for _, column in ipairs(self._columns_basexp) do |
| − | if row_values[column] then
| + | if row_values[column] then |
| − | row_values[column].bg_color = bg_color
| + | row_values[column].bg_color = bg_color |
| − | end
| + | end |
| − | if row_values[column] then
| + | if row_values[column] then |
| − | table.insert(self._rows, format(self._column_cell_templates_basexp[column] or self._cell, row_values[column]))
| + | table.insert(self._rows, format(self._column_cell_templates_basexp[column] or self._cell, row_values[column])) |
| − | end
| + | end |
| − | end
| + | end |
| − | else
| + | else |
| − | for _, column in ipairs(self._columns) do
| + | for _, column in ipairs(self._columns) do |
| − | if row_values[column] then
| + | if row_values[column] then |
| − | row_values[column].bg_color = bg_color
| + | row_values[column].bg_color = bg_color |
| − | end
| + | end |
| − | if row_values[column] then
| + | if row_values[column] then |
| − | table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
| + | table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column])) |
| − | end
| + | end |
| − | end
| + | end |
| − | end
| + | end |
| − | elseif mw.ustring.find(row_values, '/') then
| + | elseif mw.ustring.find(row_values, '/') then |
| | --node/resource/amount/boss | | --node/resource/amount/boss |
| | local values = {} | | local values = {} |
| Line 500: |
Line 488: |
| | }}) | | }}) |
| | end | | end |
| − | end
| + | end |
| − | end
| + | end |
| | end | | end |
| | end | | end |
| Line 510: |
Line 498: |
| | table.insert(self._rows, self._table_end) | | table.insert(self._rows, self._table_end) |
| | if self._args["toggle_id"] then | | if self._args["toggle_id"] then |
| − | table.insert(self._rows, self._collapser_end)
| + | table.insert(self._rows, self._collapser_end) |
| | end | | end |
| | end | | end |