Changes

m
158 revisions imported
Line 1: Line 1:  
local BaseTable = require('Module:BaseTable')
 
local BaseTable = require('Module:BaseTable')
 
local Ship = require('Module:Ship')
 
local Ship = require('Module:Ship')
 +
local ShipBattleCardKai = require('Module:ShipBattleCardKai')
 
local ShipCardKai = require('Module:ShipCardKai')
 
local ShipCardKai = require('Module:ShipCardKai')
 
local Equipment = require('Module:Equipment')
 
local Equipment = require('Module:Equipment')
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
local format = require('Module:StringInterpolation').format
+
local format = require('Module:Core').format
    
local NanaminFleet = BaseTable({
 
local NanaminFleet = BaseTable({
Line 16: Line 17:  
     _header_template = nil,
 
     _header_template = nil,
 
     _calculated_cell_template = [[| colspan="6" style="background: ${bg_color}; text-align: center; font-weight: bold;" |Effective Line of Sight: ${elos} // Fighter Power: ${fighter_power}]],
 
     _calculated_cell_template = [[| colspan="6" style="background: ${bg_color}; text-align: center; font-weight: bold;" |Effective Line of Sight: ${elos} // Fighter Power: ${fighter_power}]],
     _route_cell_template = [[| colspan="6" style="background: ${bg_color}; text-align: center; font-weight: bold;" |Route Taken: ${route}]],
+
     _added_cell_template = [[| colspan="6" style="background: ${bg_color}; text-align: center; font-weight: bold;" |${content}]],
 
     _column_cell_templates = {
 
     _column_cell_templates = {
 
         ship = [[| rowspan="4" style="background: white;" |${values.ship_card}]],
 
         ship = [[| rowspan="4" style="background: white;" |${values.ship_card}]],
Line 60: Line 61:  
         value = Formatting:format_image{self._blank, size = self._size}
 
         value = Formatting:format_image{self._blank, size = self._size}
 
     else
 
     else
         value = ShipCardKai:card{ship = row[1], size = self._size, link = row[1]:link(), caption = row[1]:name()}
+
         value = ShipCardKai:get{ship = row[1], size = self._size, link = row[1]:link(), caption = row[1]:name()}
 
     end
 
     end
 
     return {values = {ship_card = value}, bg_color = self._transparent, text_align = self._center_align}
 
     return {values = {ship_card = value}, bg_color = self._transparent, text_align = self._center_align}
Line 194: Line 195:  
         end
 
         end
 
     end
 
     end
    table.insert(self._items, "extra")
   
end
 
end
   Line 208: Line 208:  
                 if value then
 
                 if value then
 
                     row_values[column] = value
 
                     row_values[column] = value
                    row_values[column].rowspan = item.class ~= nil and 4 or 1
  −
                    row_values[column].colspan = 1
   
                 end
 
                 end
 
             end
 
             end
Line 219: Line 217:  
function NanaminFleet:build_rows()
 
function NanaminFleet:build_rows()
 
for index, row_values in ipairs(self._data_rows) do
 
for index, row_values in ipairs(self._data_rows) do
if row_values ~= "break" and row_values ~= "extra" 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
Line 229: Line 227:  
end
 
end
 
end
 
end
else
  −
table.insert(self._rows,
  −
format{self._cell,
  −
colspan = #self._columns, rowspan = 1,
  −
text_align = self._args[self._custom_row_prefix .. row_values .. self._text_align_suffix] or self._start_align,
  −
bg_color = self._args[self._custom_row_prefix .. row_values .. self._bg_color_suffix] or self._transparent,
  −
values = {
  −
value = self._args[self._custom_row_prefix .. row_values .. self._content_suffix] or "",
  −
},
  −
}
  −
)
   
    end
 
    end
        elseif row_values == "extra" then
  −
            table.insert(self._rows, self._row_starter)
  −
            table.insert(self._rows, format{self._calculated_cell_template,
  −
                elos = string.format("%.2f", self._elos - (self._hq_lvl * 0.61)),
  −
                fighter_power = self._fighter_power,
  −
                bg_color = self._extra_cells_bg
  −
            })
  −
            table.insert(self._rows, self._row_starter)
  −
            table.insert(self._rows, format{self._route_cell_template,
  −
                route = self._route,
  −
                bg_color = self._extra_cells_bg
  −
            })
   
end
 
end
end
+
    end
 +
    --Anything that's added after the table ends
 +
    table.insert(self._rows, self._row_starter)
 +
    table.insert(self._rows, format{self._calculated_cell_template,
 +
        elos = string.format("%.2f", self._elos - (self._hq_lvl * 0.61)),
 +
        fighter_power = self._fighter_power,
 +
        bg_color = self._extra_cells_bg,
 +
    })
 +
    table.insert(self._rows, self._row_starter)
 +
    table.insert(self._rows, format{self._added_cell_template,
 +
        content = "Route Taken: " .. self._route,
 +
        bg_color = self._extra_cells_bg,
 +
    })
 +
    if self._args["!difficulty"] then
 +
        table.insert(self._rows, self._row_starter)
 +
        table.insert(self._rows, format{self._added_cell_template,
 +
            content = "Difficulty Chosen: " .. self._args["!difficulty"],
 +
            bg_color = self._extra_cells_bg,
 +
        })
 +
    end
 +
    if self._args["!drops"] then
 +
        table.insert(self._rows, self._row_starter)
 +
        --Drops will be a bunch of ship names separated by /
 +
        local drops_str = self._args["!drops"]
 +
        local drops = {}
 +
        while mw.ustring.find(drops_str, '/') do
 +
            local split = mw.ustring.find(drops_str, '/')
 +
            local ship = Ship(mw.ustring.sub(drops_str, 1, split - 1), "")
 +
            local battle_card = ShipBattleCardKai:get{ship = ship, link = ship:link(), caption = ship:name()}
 +
            table.insert(drops, battle_card)
 +
            drops_str = mw.ustring.sub(drops_str, split + 1)
 +
        end
 +
        local ship = Ship(drops_str, "")
 +
        local battle_card = ShipBattleCardKai:get{ship = ship, link = ship:link(), caption = ship:name()}
 +
        table.insert(drops, battle_card)
 +
       
 +
        local content = "Notable Drops<br />"
 +
        for i = 1, #drops do
 +
            content = content .. drops[i] .. " "
 +
            if i % 4 == 0 then
 +
                content = mw.ustring.sub(content, 1, -2)
 +
                content = content .. "<br />"
 +
            end
 +
        end
 +
        table.insert(self._rows, format{self._added_cell_template,
 +
            content = content,
 +
            bg_color = self._extra_cells_bg,
 +
        })
 +
    end
 
end
 
end
    
return NanaminFleet
 
return NanaminFleet
Bots, gkautomate
12,557

edits