| Line 8: |
Line 8: |
| | local VitaShipsByApiId = require('Module:Collection/VitaShipsByApiId') | | local VitaShipsByApiId = require('Module:Collection/VitaShipsByApiId') |
| | local mapNodeTranslations = require('Module:Data/Map/Translation') | | local mapNodeTranslations = require('Module:Data/Map/Translation') |
| | + | |
| | + | local function run_template(template, values) |
| | + | if not values.rowspan or values.rowspan == 1 then |
| | + | template = string.gsub(template, 'rowspan="${rowspan}" ', '') |
| | + | end |
| | + | if not values.color or values.color == '' or values.color == 'initial' then |
| | + | template = string.gsub(template, 'color:${color};" ', '') |
| | + | end |
| | + | if not values.bg_color or values.bg_color == '' or values.bg_color == 'initial' then |
| | + | template = string.gsub(template, 'background-color:${bg_color}" ', '') |
| | + | end |
| | + | template = string.gsub(template, 'style=""', '') |
| | + | return format(template, values) |
| | + | end |
| | | | |
| | local NodeInfo = BaseTable({ | | local NodeInfo = BaseTable({ |
| | _item_class = EnemyShip, | | _item_class = EnemyShip, |
| − | _table_start = [[{|class="wikitable"]], | + | _table_start = [[{|class="wikitable" style="text-align:center"]], |
| − | _table_start_style = [[{|class="wikitable" style="margin-bottom:%spx !important"]], | + | _table_start_style = [[{|class="wikitable" style="text-align:center;margin-bottom:%spx !important"]], |
| | _header_template = [[!# | | _header_template = [[!# |
| | !Formation | | !Formation |
| Line 25: |
Line 39: |
| | !AD/AP<br>AS/AS+]], | | !AD/AP<br>AS/AS+]], |
| | _column_cell_templates = { | | _column_cell_templates = { |
| − | node = [[|rowspan="${rowspan}" style="text-align:center;color:${color};background-color:${bg_color}"|${values.node}]], | + | node = [[|rowspan="${rowspan}" style="color:${color};background-color:${bg_color}"|${values.node}]], |
| − | formation = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.formation}]], | + | formation = [[|style="color:${color};background-color:${bg_color}"|${values.formation}]], |
| − | fleet = [[|style="background-color:${bg_color};font-size:0px"|${values.fleet}]], | + | fleet = [[|style="text-align:left;font-size:0px;background-color:${bg_color}"|${values.fleet}]], |
| − | as = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.as}]], | + | as = [[|style="color:${color};background-color:${bg_color}"|${values.as}]], |
| | }, | | }, |
| | _column_cell_templates_basexp = { | | _column_cell_templates_basexp = { |
| − | node = [[|rowspan="${rowspan}" style="text-align:center;color:${color};background-color:${bg_color}"|${values.node}]], | + | node = [[|rowspan="${rowspan}" style="color:${color};background-color:${bg_color}"|${values.node}]], |
| − | formation = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.formation}]], | + | formation = [[|style="color:${color};background-color:${bg_color}"|${values.formation}]], |
| − | basexp = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.basexp}]], | + | basexp = [[|style="color:${color};background-color:${bg_color}"|${values.basexp}]], |
| − | fleet = [[|style="background-color:${bg_color};font-size:0px"|${values.fleet}]], | + | fleet = [[|style="text-align:left;font-size:0px;background-color:${bg_color}"|${values.fleet}]], |
| − | as = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.as}]], | + | as = [[|style="color:${color};background-color:${bg_color}"|${values.as}]], |
| | }, | | }, |
| | | | |
| − | _simple_node_template = [[|style="text-align:center"|${node} | + | _simple_node_template = [[|${node} |
| − | |style="text-align:center"|<span lang="ja">${ja}</span><br>${en}]], | + | |${ja}<br>${en}]], |
| | | | |
| | _empty_node_en = 'Must be my imagination./No enemy spotted./Calm seas./Calm straits./Be alert./Peaceful seas.', | | _empty_node_en = 'Must be my imagination./No enemy spotted./Calm seas./Calm straits./Be alert./Peaceful seas.', |
| Line 50: |
Line 64: |
| | _landing_node_ja = '輸送物資の揚陸地点に到達しました。本海域の輸送作戦は無事完了しています。', | | _landing_node_ja = '輸送物資の揚陸地点に到達しました。本海域の輸送作戦は無事完了しています。', |
| | | | |
| − | _resource_node_template = [[|style="text-align:center;background-color:${values.bg_color};color:${values.color}"|${values.node} | + | _resource_node_template = [[|style="color:${color};background-color:${bg_color}"|${node} |
| − | |style="text-align:center;background-color:${values.bg_color};color:${values.color}"|${values.text}]], | + | |style="color:${color};background-color:${bg_color}"|${text}]], |
| | | | |
| | _collapser_template = [[<div class="mw-customtoggle-${toggle_id} wikia-menu-button">${button_display}</div> | | _collapser_template = [[<div class="mw-customtoggle-${toggle_id} wikia-menu-button">${button_display}</div> |
| Line 524: |
Line 538: |
| | end | | end |
| | if row_values[column] then | | if row_values[column] then |
| − | table.insert(self._rows, format(self._column_cell_templates_basexp[column] or self._cell, row_values[column])) | + | table.insert(self._rows, run_template(self._column_cell_templates_basexp[column] or self._cell, row_values[column])) |
| | end | | end |
| | end | | end |
| Line 533: |
Line 547: |
| | end | | end |
| | if row_values[column] then | | if row_values[column] then |
| − | table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column])) | + | table.insert(self._rows, run_template(self._column_cell_templates[column] or self._cell, row_values[column])) |
| | end | | end |
| | end | | end |
| Line 589: |
Line 603: |
| | color = self._boss_battle_color | | color = self._boss_battle_color |
| | end | | end |
| − | table.insert(self._rows, format{self._resource_node_template, values = { | + | table.insert(self._rows, run_template(self._resource_node_template, { |
| | node = node, | | node = node, |
| | text = text, | | text = text, |
| | color = color, | | color = color, |
| | bg_color = bg_color, | | bg_color = bg_color, |
| − | }}) | + | })) |
| | end | | end |
| | end | | end |