Changes

m
no edit summary
Line 38: Line 38:  
     local types_allowed = { [6] = true, [7] = true, [8] = true, [11] = true }
 
     local types_allowed = { [6] = true, [7] = true, [8] = true, [11] = true }
 
     if types_allowed[equip:type()] and equip:aa() then
 
     if types_allowed[equip:type()] and equip:aa() then
         self._fighter_power = self._fighter_power + math.floor(math.sqrt(planes) * equip:aa())
+
         NanaminCombinedFleet._fighter_power = NanaminCombinedFleet._fighter_power + math.floor(math.sqrt(planes) * equip:aa())
 
     end
 
     end
 
end
 
end
Line 50: Line 50:  
     local multiplier = { [7] = 1.04, [8] = 1.04, [9] = 1.66, [10] = 2.00, [11] = 1.78, [12] = 1.00, [13] = 0.99, [29] = 0.91 }
 
     local multiplier = { [7] = 1.04, [8] = 1.04, [9] = 1.66, [10] = 2.00, [11] = 1.78, [12] = 1.00, [13] = 0.99, [29] = 0.91 }
 
     if multiplier[equip:type()] ~= nil and equip:los() then
 
     if multiplier[equip:type()] ~= nil and equip:los() then
         self._elos = self._elos + (equip:los() * multiplier[equip:type()])
+
         NanaminCombinedFleet._elos = NanaminCombinedFleet._elos + (equip:los() * multiplier[equip:type()])
 
     end
 
     end
 
end
 
end
Line 74: Line 74:  
     else
 
     else
 
         local equipment = Equipment(item)
 
         local equipment = Equipment(item)
         self:add_to_fighter_power(equipment, plane_count)
+
         NanaminCombinedFleet:add_to_fighter_power(equipment, plane_count)
         self:add_to_elos(equipment)
+
         NanaminCombinedFleet:add_to_elos(equipment)
 
         return equipment, plane_count
 
         return equipment, plane_count
 
     end
 
     end
Line 82: Line 82:  
function NanaminCombinedFleet:organize_args()
 
function NanaminCombinedFleet:organize_args()
 
     local ship_index, ship, los = 0
 
     local ship_index, ship, los = 0
     for index, item in ipairs(self._args) do
+
     for index, item in ipairs(NanaminCombinedFleet._args) do
 
         --Arguments that begin in ! will end up outside of this as args["!something"] - no need to check for it
 
         --Arguments that begin in ! will end up outside of this as args["!something"] - no need to check for it
 
         if mw.ustring.sub(item, 1, 1) ~= "#" then
 
         if mw.ustring.sub(item, 1, 1) ~= "#" then
Line 88: Line 88:  
             if mw.ustring.find(item, '/') then
 
             if mw.ustring.find(item, '/') then
 
                 ship_index = ship_index + 1
 
                 ship_index = ship_index + 1
                 ship, los = self:process_ship(item)
+
                 ship, los = NanaminCombinedFleet:process_ship(item)
                 self._ship_list[ship_index] = { ship = ship, equips = {} }
+
                 NanaminCombinedFleet._ship_list[ship_index] = { ship = ship, equips = {} }
                 self._elos = self._elos + math.sqrt(los) * 1.69
+
                 NanaminCombinedFleet._elos = NanaminCombinedFleet._elos + math.sqrt(los) * 1.69
 
             else
 
             else
                 local slot = #self._ship_list[ship_index].equips + 1
+
                 local slot = #NanaminCombinedFleet._ship_list[ship_index].equips + 1
                 local equipment, planes = self:process_equipment(ship, item, slot)
+
                 local equipment, planes = NanaminCombinedFleet:process_equipment(ship, item, slot)
                 table.insert(self._ship_list[ship_index].equips, { equip = equipment, planes = planes })
+
                 table.insert(NanaminCombinedFleet._ship_list[ship_index].equips, { equip = equipment, planes = planes })
 
             end
 
             end
 
         end
 
         end
Line 101: Line 101:     
function NanaminCombinedFleet:begin_tabber()
 
function NanaminCombinedFleet:begin_tabber()
     table.insert(self._rows, self._tabber_start)
+
     table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._tabber_start)
 
end
 
end
    
function NanaminCombinedFleet:end_tabber()
 
function NanaminCombinedFleet:end_tabber()
     table.insert(self._rows, self._tabber_end)
+
     table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._tabber_end)
 
end
 
end
    
function NanaminCombinedFleet:begin_table()
 
function NanaminCombinedFleet:begin_table()
     table.insert(self._rows, self._table_start)
+
     table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._table_start)
 
end
 
end
    
function NanaminCombinedFleet:end_table()
 
function NanaminCombinedFleet:end_table()
     table.insert(self._rows, self._table_end)
+
     table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._table_end)
 
end
 
end
    
function NanaminCombinedFleet:build_fleet_table(tab_name, i_start, i_end)
 
function NanaminCombinedFleet:build_fleet_table(tab_name, i_start, i_end)
     table.insert(self._rows, tab_name)
+
     table.insert(NanaminCombinedFleet._rows, tab_name)
     self:begin_table()
+
     NanaminCombinedFleet:begin_table()
 
     --Tentative style of 3 cards across the top
 
     --Tentative style of 3 cards across the top
 
     for a = i_start, i_end do
 
     for a = i_start, i_end do
 
         for b = 1, 3 do
 
         for b = 1, 3 do
 
             local ship_num = (a - 1) * 3 + b
 
             local ship_num = (a - 1) * 3 + b
             table.insert(self._rows, format{self._ship_image_template, values = {
+
             table.insert(NanaminCombinedFleet._rows, format{NanaminCombinedFleet._ship_image_template, values = {
                 bg_color = self._ship_image_bg,
+
                 bg_color = NanaminCombinedFleet._ship_image_bg,
                 ship_image = Formatting:format_image{self._ship_list[ship_num].ship:battle_card(), align = self._center_align}
+
                 ship_image = Formatting:format_image{NanaminCombinedFleet._ship_list[ship_num].ship:battle_card(), align = NanaminCombinedFleet._center_align}
 
             }})
 
             }})
 
         end
 
         end
         table.insert(self._rows, self._row_starter)
+
         table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._row_starter)
 
         for b = 1, 4 do
 
         for b = 1, 4 do
 
             row = {}
 
             row = {}
 
             for c = 1, 3 do
 
             for c = 1, 3 do
 
                 local ship_num = (a - 1) * 3 + c
 
                 local ship_num = (a - 1) * 3 + c
                 local equip = self._ship_list[ship_num].equips[b].equip
+
                 local equip = NanaminCombinedFleet._ship_list[ship_num].equips[b].equip
 
                 local equip_icon, equip_link
 
                 local equip_icon, equip_link
 
                 if type(equip) == "string" then
 
                 if type(equip) == "string" then
Line 139: Line 139:  
                     equip_link = equip
 
                     equip_link = equip
 
                 else
 
                 else
                     equip_icon = Formatting:format_image{Formatting:format_equipment_icon(equip:icon()), size = self._equip_icon_size}
+
                     equip_icon = Formatting:format_image{Formatting:format_equipment_icon(equip:icon()), size = NanaminCombinedFleet._equip_icon_size}
 
                     equip_link = Formatting:format_link(equip:link())
 
                     equip_link = Formatting:format_link(equip:link())
 
                 end
 
                 end
                 table.insert(self._rows, format{self._equip_icon_template, values = {
+
                 table.insert(NanaminCombinedFleet._rows, format{NanaminCombinedFleet._equip_icon_template, values = {
                   bg_color = self._equip_icon_bg,
+
                   bg_color = NanaminCombinedFleet._equip_icon_bg,
 
                   equip_icon = equip_icon
 
                   equip_icon = equip_icon
 
                 }})
 
                 }})
                 table.insert(self._rows, format{self._equip_link_template, values = {
+
                 table.insert(NanaminCombinedFleet._rows, format{NanaminCombinedFleet._equip_link_template, values = {
                     bg_color = self._equip_link_bg,
+
                     bg_color = NanaminCombinedFleet._equip_link_bg,
 
                     equip_link = equip_link
 
                     equip_link = equip_link
 
                 }})
 
                 }})
 
             end
 
             end
             table.insert(self._rows, self._row_starter)
+
             table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._row_starter)
 
         end
 
         end
 
     end
 
     end
     self:end_table()
+
     NanaminCombinedFleet:end_table()
 
end
 
end
    
function NanaminCombinedFleet:add_info(label, text)
 
function NanaminCombinedFleet:add_info(label, text)
     table.insert(self._rows, format{self._info_template, values = {
+
     table.insert(NanaminCombinedFleet._rows, format{NanaminCombinedFleet._info_template, values = {
 
         label = label,
 
         label = label,
 
         text = text
 
         text = text
Line 166: Line 166:  
function NanaminCombinedFleet:build_info_tab()
 
function NanaminCombinedFleet:build_info_tab()
 
     --Finish eLoS calculation
 
     --Finish eLoS calculation
     self._hq_level = tonumber(self._args["!hq"]) - (tonumber(self._args["!hq"]) % 5)
+
     NanaminCombinedFleet._hq_level = tonumber(NanaminCombinedFleet._args["!hq"]) - (tonumber(NanaminCombinedFleet._args["!hq"]) % 5)
     if tonumber(self._args["!hq"]) % 5 ~= 0 then
+
     if tonumber(NanaminCombinedFleet._args["!hq"]) % 5 ~= 0 then
         self._hq_level = self._hq_level + 5
+
         NanaminCombinedFleet._hq_level = NanaminCombinedFleet._hq_level + 5
 
     end
 
     end
     self._elos = self._elos - (self._hq_level * 0.61)
+
     NanaminCombinedFleet._elos = NanaminCombinedFleet._elos - (NanaminCombinedFleet._hq_level * 0.61)
 
      
 
      
     table.insert(self._rows, "|-|Information=")
+
     table.insert(NanaminCombinedFleet._rows, "|-|Information=")
     table.insert(self._rows, self._info_container_start)
+
     table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._info_container_start)
     self:add_info("Route Taken", self._args["!route"] or "Unavailable")
+
     NanaminCombinedFleet:add_info("Route Taken", NanaminCombinedFleet._args["!route"] or "Unavailable")
     self:add_info("Fighter Power", self._fighter_power or 0)
+
     NanaminCombinedFleet:add_info("Fighter Power", NanaminCombinedFleet._fighter_power or 0)
     self:add_info("Effective Line of Sight", string.format("%.2f", self._elos) or 0)
+
     NanaminCombinedFleet:add_info("Effective Line of Sight", string.format("%.2f", NanaminCombinedFleet._elos) or 0)
     self:add_info("HQ Level", self._args["!hq"] or "Unavailable")
+
     NanaminCombinedFleet:add_info("HQ Level", NanaminCombinedFleet._args["!hq"] or "Unavailable")
     table.insert(self._rows, self._info_container_end)
+
     table.insert(NanaminCombinedFleet._rows, NanaminCombinedFleet._info_container_end)
 
end
 
end
    
function NanaminCombinedFleet:join_rows()
 
function NanaminCombinedFleet:join_rows()
     return table.concat(self._rows, "\n")
+
     return table.concat(NanaminCombinedFleet._rows, "\n")
 
end
 
end
    
function NanaminCombinedFleet:Fleetbox(args)
 
function NanaminCombinedFleet:Fleetbox(args)
     self._args = args
+
     NanaminCombinedFleet._args = args
 
      
 
      
     self:organize_args()
+
     NanaminCombinedFleet:organize_args()
 
      
 
      
     self:begin_tabber()
+
     NanaminCombinedFleet:begin_tabber()
     self:build_fleet_table("Main Fleet=", 1, 2)
+
     NanaminCombinedFleet:build_fleet_table("Main Fleet=", 1, 2)
     self:build_fleet_table("|-|Escort Fleet=", 3, 4)
+
     NanaminCombinedFleet:build_fleet_table("|-|Escort Fleet=", 3, 4)
     self:build_info_tab()
+
     NanaminCombinedFleet:build_info_tab()
     self:end_tabber()
+
     NanaminCombinedFleet:end_tabber()
 
      
 
      
     return self:join_rows()
+
     return NanaminCombinedFleet:join_rows()
 
end
 
end
  
48

edits