Line 11: |
Line 11: |
| _equip_bg = "whitesmoke", | | _equip_bg = "whitesmoke", |
| _header_template = nil, | | _header_template = nil, |
| + | _calculated_cell_template = [[| colspan="4" style="background: whitesmoke;" |Effective Line of Sight: ${elos} / Fighter Power: ${fighter_power}]], |
| _column_cell_templates = { | | _column_cell_templates = { |
| ship = [[| rowspan="4" style="background: transparent;" |${values.ship_card}]], | | ship = [[| rowspan="4" style="background: transparent;" |${values.ship_card}]], |
Line 26: |
Line 27: |
| }, | | }, |
| _blank = "Empty_ship_slot.png", | | _blank = "Empty_ship_slot.png", |
− | _default_size = "120x165px" | + | _default_size = "120x165px", |
| + | _elos = 0, |
| + | _fighter_power = 0 |
| }) | | }) |
| | | |
Line 83: |
Line 86: |
| function NanaminFleet:create_items() | | function NanaminFleet:create_items() |
| local row1, row2, row3, row4 = {}, {}, {}, {} | | local row1, row2, row3, row4 = {}, {}, {}, {} |
| + | local los, fighter_power = 0, 0 |
| for index, item_key in ipairs(self._args) do | | for index, item_key in ipairs(self._args) do |
| local item | | local item |
Line 93: |
Line 97: |
| else | | else |
| item = self._equip_class(self:process_item_key(item_key)) | | item = self._equip_class(self:process_item_key(item_key)) |
| + | |
| + | --Calculate the effective LoS and fighter power |
| + | --[[Effective LoS = Dive Bomber LoS x (1.04) + Torpedo Bomber LoS x (1.37) |
| + | + Carrier-based Recon Plane LoS x (1.66) + Recon Seaplane LoS x (2.00) |
| + | + Seaplane Bomber LoS x (1.78) + Small Radar LoS x (1.00) + Large Radar LoS x (0.99) |
| + | + Searchlight LoS x (0.91) + √(base LoS of each ship) x (1.69) |
| + | + (HQ Lv. rounded up to the next multiple of 5) x (-0.61)--]] |
| + | local slot_number = (index - 1) % 5 |
| + | 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[item:type()] ~= nil then |
| + | los = los + (item:los() * multiplier[item:type()]) |
| + | end |
| + | fighter_power = fighter_power + math.floor(math.sqrt(select(2, item:slot(slot_number)))) |
| end | | end |
| end | | end |
Line 118: |
Line 144: |
| end | | end |
| end | | end |
| + | table.insert(self._items, "extra") |
| + | self._elos = los |
| + | self._fighter_power = fighter_power |
| end | | end |
| | | |
Line 134: |
Line 163: |
| table.insert(self._data_rows, row_values) | | table.insert(self._data_rows, row_values) |
| end | | end |
| + | end |
| + | |
| + | function NanaminFleet:build_rows() |
| + | for index, row_values in ipairs(self._data_rows) do |
| + | if row_values ~= "break" and row_values ~= "extra" then |
| + | table.insert(self._rows, self._row_starter) |
| + | if row_values == "header" then |
| + | table.insert(self._rows, self._header) |
| + | elseif type(row_values) == "table" then |
| + | for _, column in ipairs(self._columns) do |
| + | if row_values[column] then |
| + | table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column])) |
| + | 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 |
| + | elseif row_values == "extra" then |
| + | table.insert(self._rows, format{self._calculated_cell_template, |
| + | elos = self._elos, |
| + | fighter_power = self._fighter_power |
| + | }) |
| + | end |
| + | end |
| end | | end |
| | | |
| return NanaminFleet | | return NanaminFleet |