Line 5: |
Line 5: |
| 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 EventComp = { | | local EventComp = { |
Line 53: |
Line 53: |
| end | | end |
| | | |
− | function EventComp:process_equipment(equip) | + | function EventComp:process_equipment(equip, planes) |
| --Fighter power | | --Fighter power |
| --Only fighter planes, dive bombers, torpedo bombers and seaplane bombers with an AA stat are counted | | --Only fighter planes, dive bombers, torpedo bombers and seaplane bombers with an AA stat are counted |
| 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()) | + | self._fighter_power = self._fighter_power + math.floor(math.sqrt(planes or 0) * equip:aa()) |
| end | | end |
| | | |
Line 75: |
Line 75: |
| } | | } |
| for index, item_key in ipairs(self._args) do | | for index, item_key in ipairs(self._args) do |
− | if item_key == "-" then | + | if index == #self._args then |
| + | table.insert(entry.equips, self._equip_class(item_key)) |
| + | table.insert(self._items, entry) |
| + | elseif item_key == "-" then |
| table.insert(self._items, entry) | | table.insert(self._items, entry) |
| | | |
Line 84: |
Line 87: |
| } | | } |
| elseif entry.ship and entry.level then | | elseif entry.ship and entry.level then |
− | table.insert(entry.equips, self._equip_class(item_key)) | + | local equip = self._equip_class(item_key) |
| + | table.insert(entry.equips, equip) |
| + | self:process_equipment(equip, select(2, entry.ship:slot(#entry.equips))) |
| elseif entry.ship then | | elseif entry.ship then |
| entry.level = tonumber(item_key) | | entry.level = tonumber(item_key) |
Line 97: |
Line 102: |
| end | | end |
| end | | end |
− | table.insert(entry.equips, self._equip_class(item_key))
| |
− | table.insert(self._items, entry)
| |
| end | | end |
| | | |
Line 116: |
Line 119: |
| if column == "equipment" then | | if column == "equipment" then |
| for index, equip in ipairs(row_values[column]) do | | for index, equip in ipairs(row_values[column]) do |
− | self:process_equipment(equip)
| |
| local values = { equip_name = Formatting:format_link(equip:link()), style = "" } | | local values = { equip_name = Formatting:format_link(equip:link()), style = "" } |
| if index == #row_values[column] then values.style = "border-bottom: 1px solid grey;" end | | if index == #row_values[column] then values.style = "border-bottom: 1px solid grey;" end |
− | table.insert(self._rows, "| style=\"" .. values.style .. "\" |" .. Formatting:format_image{Formatting:format_equipment_icon(equip:icon())}) | + | table.insert(self._rows, "| style=\"" .. values.style .. "\" |" .. Formatting:format_image{Formatting:format_equipment_icon(equip:icon()), size = '20px'}) |
| table.insert(self._rows, format(self._column_cell_templates[column], values)) | | table.insert(self._rows, format(self._column_cell_templates[column], values)) |
| table.insert(self._rows, "|-") | | table.insert(self._rows, "|-") |