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({
 
     _item_class = Ship,
 
     _item_class = Ship,
 
     _equip_class = Equipment,
 
     _equip_class = Equipment,
     _equip_bg = "whitesmoke",
+
    _equip_icon_bg = "#8DCDEE",
 +
     _equip_bg = "#E4F3FB",
 +
    _equip_locked_bg = "#CDDBE2",
 +
    _extra_cells_bg = "#98D2F0",
 +
    _table_start = [[{|]],
 
     _header_template = nil,
 
     _header_template = nil,
     _calculated_cell_template = [[| colspan="6" style="background: #FFE6E6; 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: #FFE6E6; 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}]],
         equips = [[| style="background: #FFE6E6; width: 15px;" |${values.equip_icon}
+
         equips = [[| style="background: ${values.icon_bg_color}; width: 15px;" |${values.equip_icon}
         | style="background: #F5FFFF; width: 175px;text-align: center;" |${values.equip_link}]],
+
         | style="background: ${values.equip_bg_color}; width: 175px;text-align: center;" |${values.equip_link}]],
 
         ship2 = [[| rowspan="4" style="background: white;" |${values.ship_card}]],
 
         ship2 = [[| rowspan="4" style="background: white;" |${values.ship_card}]],
         equips2 = [[| style="background: #FFE6E6; width: 15px;" |${values.equip_icon}
+
         equips2 = [[| style="background: ${values.icon_bg_color}; width: 15px;" |${values.equip_icon}
         | style="background: #F5FFFF; width: 175px; text-align: center;" |${values.equip_link}]]
+
         | style="background: ${values.equip_bg_color}; width: 175px; text-align: center;" |${values.equip_link}]]
 
     },
 
     },
 
     _columns = {
 
     _columns = {
Line 37: Line 42:  
function NanaminFleet:create_table_prep()
 
function NanaminFleet:create_table_prep()
 
     self._size = self._args.image_size or self._default_size
 
     self._size = self._args.image_size or self._default_size
 +
 +
    self._hq_lvl = tonumber(self._args["!hq"])
 +
   
 +
    --Get bracket of 5
 +
    self._hq_lvl = self._hq_lvl - (self._hq_lvl % 5) + 5
 +
    if self._hq_lvl % 5 == 0 then
 +
        self._hq_lvl = self._hq_lvl + 5
 +
    end
 +
   
 +
    self._route = self._args["!route"]
 
end
 
end
   Line 46: 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 57: Line 72:     
function NanaminFleet:equips(row)
 
function NanaminFleet:equips(row)
     local value, icon
+
     local value, icon, equip_bg_color
 
     if row[2] == false then
 
     if row[2] == false then
 
         value = "- Unequipped -"
 
         value = "- Unequipped -"
 
         icon = ""
 
         icon = ""
 +
        equip_bg_color = self._equip_bg
 
     elseif row[2] == "locked" then
 
     elseif row[2] == "locked" then
 
         value = "- Locked -"
 
         value = "- Locked -"
 
         icon = ""
 
         icon = ""
 +
        equip_bg_color = self._equip_locked_bg
 
     else
 
     else
 
         value = Formatting:format_link(row[2]:link())
 
         value = Formatting:format_link(row[2]:link())
 
         icon = Formatting:format_image{Formatting:format_equipment_icon(row[2]:icon()), size = "22x22px"}
 
         icon = Formatting:format_image{Formatting:format_equipment_icon(row[2]:icon()), size = "22x22px"}
 +
        equip_bg_color = self._equip_bg
 
     end
 
     end
     return {values = {equip_link = value, equip_icon = icon}, bg_color = self._equip_bg, text_align = self._center_align}
+
     return {values = {equip_link = value, equip_icon = icon, icon_bg_color = self._equip_icon_bg, equip_bg_color = equip_bg_color}, bg_color = self._equip_bg, text_align = self._center_align}
 
end
 
end
   Line 94: Line 112:  
     local row1, row2, row3, row4 = {}, {}, {}, {}
 
     local row1, row2, row3, row4 = {}, {}, {}, {}
 
     local ship_item1, ship_item2
 
     local ship_item1, ship_item2
 +
 
     for index, item_key in ipairs(self._args) do
 
     for index, item_key in ipairs(self._args) do
 
         local item
 
         local item
Line 101: Line 120:  
         elseif item_key == "!-" then
 
         elseif item_key == "!-" then
 
             item = "locked"
 
             item = "locked"
        elseif mw.ustring.find(item_key, '!hq') then
  −
            item = false
  −
           
  −
            local split = mw.ustring.find(item_key, '=')
  −
            self._hq_lvl = tonumber(mw.ustring.sub(item_key, split + 1))
  −
           
  −
            --Get bracket of 5
  −
            self._hq_lvl = self._hq_lvl - (self._hq_lvl % 5) + 5
  −
            if self._hq_lvl % 5 == 0 then
  −
                self._hq_lvl = self._hq_lvl + 5
  −
            end
  −
        elseif mw.ustring.find(item_key, '!route') then
  −
            local split = mw.ustring.find(item_key, '=')
  −
            self._route = mw.ustring.sub(item_key, split + 1)
  −
            self._route = item_key
   
         else
 
         else
 
             if mw.ustring.find(item_key, '/') then
 
             if mw.ustring.find(item_key, '/') then
Line 160: Line 164:  
                 end
 
                 end
 
                 if item:type() == 6 or item:type() == 7 or item:type() == 8 or item:type() == 11 then
 
                 if item:type() == 6 or item:type() == 7 or item:type() == 8 or item:type() == 11 then
                     if item:aa() then
+
                     if ship:slot(slot_number) and item:aa() then
 +
                        mw.log("Adding " .. tostring(item:aa()) .. " from " .. ship:name() .. ", slot " .. tostring(slot_number))
 
                         self._fighter_power = self._fighter_power + math.floor(math.sqrt(select(2, ship:slot(slot_number))) * item:aa())
 
                         self._fighter_power = self._fighter_power + math.floor(math.sqrt(select(2, ship:slot(slot_number))) * item:aa())
 
                     end
 
                     end
Line 187: Line 192:  
             table.insert(self._items, row4)
 
             table.insert(self._items, row4)
 
             row1, row2, row3, row4 = {}, {}, {}, {}
 
             row1, row2, row3, row4 = {}, {}, {}, {}
 +
            ship_item1 = nil
 
         end
 
         end
 
     end
 
     end
    table.insert(self._items, "extra")
   
end
 
end
   Line 203: 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 214: 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 224: 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
  −
            })
  −
            table.insert(self._rows, self._row_starter)
  −
            table.insert(self._rows, format{self._route_cell_template,
  −
                random_thing = "",
  −
                route = self._route
  −
            })
   
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