Line 1: |
Line 1: |
− | local U = require("Module:Utils") | + | local U = require("Module:Core") |
− | local format = require('Module:Utils').format | + | local format = require('Module:Core').format |
| local BaseTable = require("Module:BaseTable") | | local BaseTable = require("Module:BaseTable") |
| local EnemyShip = require("Module:EnemyShip") | | local EnemyShip = require("Module:EnemyShip") |
Line 11: |
Line 11: |
| local NodeInfo = BaseTable({ | | local NodeInfo = BaseTable({ |
| _item_class = EnemyShip, | | _item_class = EnemyShip, |
− | _table_start = [[{|class="wikitable" style="width:690px"]], | + | _table_start = [[{|class="wikitable"]], |
| + | _table_start_style = [[{|class="wikitable" style="margin-bottom:%spx !important"]], |
| _header_template = [[!# | | _header_template = [[!# |
| !Formation | | !Formation |
Line 24: |
Line 25: |
| !AD/AP<br>AS/AS+]], | | !AD/AP<br>AS/AS+]], |
| _column_cell_templates = { | | _column_cell_templates = { |
− | node = [[|colspan="${colspan}" rowspan="${rowspan}" style="text-align:center;color:${color};background-color:${bg_color}"|${values.node}]], | + | node = [[|rowspan="${rowspan}" style="text-align:center;color:${color};background-color:${bg_color}"|${values.node}]], |
| formation = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.formation}]], | | formation = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.formation}]], |
− | fleet = [[|style="width:485px;padding-left:8px;background-color:${bg_color};"|<div style="display:table-row;font-size:0px">${values.fleet}</div>]], | + | fleet = [[|style="background-color:${bg_color};font-size:0px"|${values.fleet}]], |
− | as = [[|style="text-align:center;background-color:${bg_color};color:${color};"|${values.as}]], | + | as = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.as}]], |
| }, | | }, |
| _column_cell_templates_basexp = { | | _column_cell_templates_basexp = { |
− | node = [[|colspan="${colspan}" rowspan="${rowspan}" style="text-align:center;color:${color};background-color:${bg_color}"|${values.node}]], | + | node = [[|rowspan="${rowspan}" style="text-align:center;color:${color};background-color:${bg_color}"|${values.node}]], |
| formation = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.formation}]], | | formation = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.formation}]], |
− | basexp = [[|style="text-align:center;background-color:${bg_color};color: ${color}"|${values.basexp}]], | + | basexp = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.basexp}]], |
− | fleet = [[|style="width:485px;padding-left:8px;background-color:${bg_color}"|<div style="display:table-row;font-size:0px">${values.fleet}</div>]], | + | fleet = [[|style="background-color:${bg_color};font-size:0px"|${values.fleet}]], |
− | as = [[|style="text-align:center;background-color:${bg_color};color: ${color}" |${values.as}]], | + | as = [[|style="text-align:center;background-color:${bg_color};color:${color}"|${values.as}]], |
| }, | | }, |
| | | |
| _simple_node_template = [[|style="text-align:center"|${node} | | _simple_node_template = [[|style="text-align:center"|${node} |
− | |colspan="3" style="text-align:center"|<span lang="ja">${ja}</span><br>${en}]], | + | |style="text-align:center"|<span lang="ja">${ja}</span><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 45: |
Line 46: |
| _select_node_en = 'You can decide the fleet\'s course. Admiral, which heading should we take?', | | _select_node_en = 'You can decide the fleet\'s course. Admiral, which heading should we take?', |
| _select_node_ja = '艦隊の針路を選択できます。提督、どちらの針路をとられますか?', | | _select_node_ja = '艦隊の針路を選択できます。提督、どちらの針路をとられますか?', |
| + | |
| + | _landing_node_en = 'The landing point of the convoy has been reached. The transport operation here has already been completed successfully.', |
| + | _landing_node_ja = '輸送物資の揚陸地点に到達しました。本海域の輸送作戦は無事完了しています。', |
| | | |
| _resource_node_template = [[|style="text-align:center;background-color:${values.bg_color};color:${values.color}"|${values.node} | | _resource_node_template = [[|style="text-align:center;background-color:${values.bg_color};color:${values.color}"|${values.node} |
− | |colspan="3" style="text-align:center;background-color:${values.bg_color};color:${values.color}"|${values.text}]], | + | |style="text-align:center;background-color:${values.bg_color};color:${values.color}"|${values.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 72: |
Line 76: |
| _defense_battle_bg_color = "#81C784", | | _defense_battle_bg_color = "#81C784", |
| _raid_battle_bg_color = "#81C784", | | _raid_battle_bg_color = "#81C784", |
− | _ha_raid_battle_bg_color = "#43A047", | + | -- _ha_raid_battle_bg_color = "#43A047", |
| _boss_battle_color = "red", | | _boss_battle_color = "red", |
| _clear_battle_color = "blue", | | _clear_battle_color = "blue", |
Line 93: |
Line 97: |
| end | | end |
| if row.tags.raid then | | if row.tags.raid then |
− | bg_color = row.tags.has_lbas_ha_bomber and self._ha_raid_battle_bg_color or self._raid_battle_bg_color | + | bg_color = self._raid_battle_bg_color |
| end | | end |
| if row.tags.night then | | if row.tags.night then |
Line 104: |
Line 108: |
| bg_color = self._ambush_battle_bg_color | | bg_color = self._ambush_battle_bg_color |
| end | | end |
− | return { values = { node = Formatting:japanese_text(row.node) }, color = color, bg_color = bg_color } | + | return { values = { node = row.node }, color = color, bg_color = bg_color } |
| end | | end |
| | | |
| function NodeInfo:formation(row) | | function NodeInfo:formation(row) |
| if row.tags.final then | | if row.tags.final then |
− | row.formation = row.formation .. "<br /><div style='font-weight:bold; color:red;'>(Final)</div>" | + | row.formation = row.formation .. "<br /><div style='font-weight:bold;color:red'>(Final)</div>" |
| end | | end |
| if row.tags.clear then | | if row.tags.clear then |
− | row.formation = row.formation .. "<br /><div style='font-weight:bold; color:blue;'>(Clear)</div>" | + | row.formation = row.formation .. "<br /><div style='font-weight:bold;color:blue'>(Clear)</div>" |
| end | | end |
| if row.tags.has_lbas_ha_bomber then | | if row.tags.has_lbas_ha_bomber then |
| row.formation = row.formation .. '<br /><span class="explain" title="High Altitude Air Raid, 2-3 Rocket Interceptors are recommended">(HA)</span>' | | row.formation = row.formation .. '<br /><span class="explain" title="High Altitude Air Raid, 2-3 Rocket Interceptors are recommended">(HA)</span>' |
| end | | end |
− | local color = "initial" | + | return { |
− | if row.tags.boss then
| + | values = { formation = row.formation }, |
− | color = self._boss_battle_color
| + | color = row.tags.boss and self._boss_battle_color or 'initial', |
− | end
| + | -- bg_color = row.tags.has_lbas_ha_bomber and self._ha_raid_battle_bg_color or 'initial', |
− | return { values = { formation = row.formation }, color = color }
| + | } |
| end | | end |
| | | |
| function NodeInfo:basexp(row) | | function NodeInfo:basexp(row) |
− | color = "initial" | + | return { |
− | if row.tags.boss then
| + | values = { basexp = row.basexp }, |
− | color = self._boss_battle_color | + | color = row.tags.boss and self._boss_battle_color or 'initial', |
− | end
| + | } |
− | return { values = { basexp = row.basexp }, color = color }
| |
| end | | end |
| | | |
| function NodeInfo:fleet(row) | | function NodeInfo:fleet(row) |
− | return { values = { fleet = row.fleet } } | + | return { |
| + | values = { fleet = row.fleet }, |
| + | -- bg_color = row.tags.has_lbas_ha_bomber and self._ha_raid_battle_bg_color or 'initial', |
| + | } |
| end | | end |
| | | |
Line 159: |
Line 165: |
| | | |
| function NodeInfo:as(row) | | function NodeInfo:as(row) |
− | color = "initial" | + | return { |
− | if row.tags.boss then
| + | values = { as = row.as }, |
− | color = self._boss_battle_color
| + | color = row.tags.boss and self._boss_battle_color or 'initial', |
− | end
| + | -- bg_color = row.tags.has_lbas_ha_bomber and self._ha_raid_battle_bg_color or 'initial', |
− | return { values = { as = row.as }, color = color }
| + | } |
| end | | end |
− |
| + | |
| function NodeInfo:upcase(str) | | function NodeInfo:upcase(str) |
| str = str:gsub("(%s)(%l)", function(a, b) return a .. string.upper(b) end) | | str = str:gsub("(%s)(%l)", function(a, b) return a .. string.upper(b) end) |
Line 179: |
Line 185: |
| air_string = "<span class='explain' title='LBAS: " .. aslb_string .. "'>" .. as_string .. "</span>" | | air_string = "<span class='explain' title='LBAS: " .. aslb_string .. "'>" .. as_string .. "</span>" |
| end | | end |
| + | self._number_of_formations = self._number_of_formations + 1 |
| table.insert(self._items, { | | table.insert(self._items, { |
| node = node, | | node = node, |
Line 187: |
Line 194: |
| tags = tags, | | tags = tags, |
| }) | | }) |
| + | end |
| + | |
| + | function NodeInfo:create_table_prep() |
| + | self._number_of_formations = 0 |
| end | | end |
| | | |
− | function NodeInfo:create_items() | + | function NodeInfo:create_items() |
| --Modes are as follows: | | --Modes are as follows: |
| --1 = Node | | --1 = Node |
Line 241: |
Line 252: |
| elseif string.lower(item_key) == "select" then | | elseif string.lower(item_key) == "select" then |
| table.insert(self._items, node .. "/select") | | table.insert(self._items, node .. "/select") |
| + | mode = 1 |
| + | elseif string.lower(item_key) == "landing" then |
| + | table.insert(self._items, node .. "/landing") |
| mode = 1 | | mode = 1 |
| else | | else |
Line 411: |
Line 425: |
| raid = 'Air Raids', | | raid = 'Air Raids', |
| ambush = 'Ambush Battle Node', | | ambush = 'Ambush Battle Node', |
| + | supported = 'Supported Battle Node', |
| + | |
| + | -- older node type names (required to make older event pages work) |
| + | medium = 'Normal Battle Node', |
| + | dogfight = 'Air Defense Node', |
| } | | } |
− | return self._args["comment"] or node_types[self._node_type] or "Fleet" | + | local prefix = self._args.ha and string.format( |
| + | "[[%s/High Altitude Raids|High Altitude]] ", |
| + | U.split(self._params.fullpagename, '/')[1] |
| + | ) or "" |
| + | return self._args["comment"] or (prefix .. (node_types[self._node_type] or "Unknown")) or "Fleet" |
| end | | end |
| | | |
Line 451: |
Line 474: |
| end | | end |
| | | |
− | table.insert(self._rows, self._table_start)
| + | if self._args.margin then |
| + | local bottom_margin = 500 - (50 * 2 + 50 * self._number_of_formations + 15 * 2 + 30) |
| + | table.insert(self._rows, string.format(self._table_start_style, bottom_margin)) |
| + | else |
| + | table.insert(self._rows, self._table_start) |
| + | end |
| + | |
| table.insert(self._rows, self._header) | | table.insert(self._rows, self._header) |
| end | | end |
Line 545: |
Line 574: |
| en = enText or self._select_node_en, | | en = enText or self._select_node_en, |
| ja = jaText or self._select_node_ja, | | ja = jaText or self._select_node_ja, |
| + | }) |
| + | elseif values[2] == "landing" then |
| + | table.insert(self._rows, format{ |
| + | self._simple_node_template, |
| + | node = node, |
| + | en = enText or self._landing_node_en, |
| + | ja = jaText or self._landing_node_ja, |
| }) | | }) |
| else | | else |
Line 573: |
Line 609: |
| end | | end |
| end | | end |
− |
| + | |
| U.registerTableTests(NodeInfo, { | | U.registerTableTests(NodeInfo, { |
| { "A", "Normal/Clear", "Line Ahead", "Northern Princess" } | | { "A", "Normal/Clear", "Line Ahead", "Northern Princess" } |
| }) | | }) |
| -- p.run_table_tests() | | -- p.run_table_tests() |
− |
| + | |
| return NodeInfo | | return NodeInfo |