Line 173: |
Line 173: |
| local StatIcons = require('Module:StatIcons') | | local StatIcons = require('Module:StatIcons') |
| | | |
− | local table_templates = { | + | local templates = { |
| | | |
− | dd = [[{| class="wikitable sortable typography-xl-optout" style="width:100%;" | + | main = [[{| class="wikitable sortable typography-xl-optout" style="width:100%;" |
| ! colspan="2" | | | ! colspan="2" | |
| ! colspan="4" |Day Battle | | ! colspan="4" |Day Battle |
Line 184: |
Line 184: |
| !${fp} | | !${fp} |
| !${torp} | | !${torp} |
− | !<span title="Normal attack damage: without equipment, with maxed equipment; all modifiers = 1, see notes">Attack</span> | + | !<span title="Damage: normal attack without equipment, ${db_attack_note} with maxed equipment (all other modifiers = 1, see notes)">Hit</span> |
− | !<span title="Normal torpedo salvo damage, all modifiers = 1, see notes">Torpedo</span> | + | !<span title="Normal torpedo salvo damage, all modifiers = 1, see notes">Salvo</span> |
| !${fp_plus_torp} | | !${fp_plus_torp} |
− | !<span title="Maximal damage from double attack (combined)">Double Attack</span> | + | !<span title="Maximal damage from double attack (combined)">DA</span> |
− | !<span title="Maximal damage from cut-in">Cut-In</span> | + | !<span title="Maximal damage from cut-in">CI</span> |
| !${luck_minus_cap} | | !${luck_minus_cap} |
− | !<span title="Torpedo/mixed cut-in rate, gun cut-in rate (only luck dependent part, no bonuses)">Cut-In Rates</span> | + | !<span title="Torpedo/mixed cut-in rate, gun cut-in rate (only luck dependent part, no bonuses)">CI%</span> |
| ${rows}|}]], | | ${rows}|}]], |
| | | |
− | dd_row = [===[|-
| + | carrier = [[{| class="wikitable sortable typography-xl-optout" style="width:100%;" |
| + | !Rank |
| + | !Name |
| + | !${fp} |
| + | !<span title=""></span> |
| + | !<span title=""></span> |
| + | ${rows}|}]], |
| + | |
| + | main_row = [[|- |
| |${rank} | | |${rank} |
| |${name} | | |${name} |
Line 205: |
Line 213: |
| |${luck_minus_cap} | | |${luck_minus_cap} |
| |${nb_ci_rate} | | |${nb_ci_rate} |
− | ]===] | + | ]], |
| + | |
| + | carrier_row = [[|- |
| + | |${rank} |
| + | |${name} |
| + | |${fp} |
| + | | |
| + | | |
| + | ]], |
| | | |
| } | | } |
| | | |
− | local map_types = { dd = "dd", cl = "dd", clt = "dd", ca = "dd", bb = "dd" } | + | local map_types = { |
| + | dd = "main", cl = "main", clt = "main", ca = "main", bb = "main", |
| + | cvl = "carrier", cv = "carrier", |
| + | } |
| | | |
| function Combat.table(frame) | | function Combat.table(frame) |
− | local typ = map_types[frame.args["type"]] or "dd" | + | local type = frame.args["type"] |
| + | local db_attack_notes = { |
| + | dd = "normal attack", |
| + | cl = "double attack", |
| + | clt = "normal attack", |
| + | ca = "double attack", |
| + | } |
| return format{ | | return format{ |
− | table_templates[typ], | + | templates[map_types[type]], |
| rows = frame.args[1] or "", | | rows = frame.args[1] or "", |
| + | db_attack_note = db_attack_notes[type] or "?", |
| fp = Formatting:format_image{StatIcons.firepower, caption = Formatting:format_stat_name("firepower")}, | | fp = Formatting:format_image{StatIcons.firepower, caption = Formatting:format_stat_name("firepower")}, |
| torp = Formatting:format_image{StatIcons.torpedo, caption = Formatting:format_stat_name("torpedo")}, | | torp = Formatting:format_image{StatIcons.torpedo, caption = Formatting:format_stat_name("torpedo")}, |
Line 227: |
Line 253: |
| } | | } |
| end | | end |
− |
| |
− | local modifiers = default_modifiers(false)
| |
| | | |
| function get_db_attack_string(fp, t) | | function get_db_attack_string(fp, t) |
| + | local modifiers = default_modifiers(false) |
| local equip_fp = { | | local equip_fp = { |
| dd = 2 * 3 + math.floor(2 * math.sqrt(10)), | | dd = 2 * 3 + math.floor(2 * math.sqrt(10)), |
| cl = 2 * 10 + math.floor(2 * math.sqrt(10)), | | cl = 2 * 10 + math.floor(2 * math.sqrt(10)), |
| clt = 2 * 8 + math.floor(2 * math.sqrt(10)), | | clt = 2 * 8 + math.floor(2 * math.sqrt(10)), |
| + | ca = 2 * 10 + math.floor(2 * math.sqrt(10)) + 3, |
| } | | } |
− | return | + | local normal = damage(shelling_attack_power(fp, 0, modifiers), modifiers) |
− | damage(shelling_attack_power(fp, 0, modifiers), modifiers)
| + | if t == "cl" or t == "ca" then |
− | .. ", " ..
| + | modifiers.spotting = spotting_modifiers.double |
− | damage(shelling_attack_power(fp, equip_fp[t] or 0, modifiers), modifiers)
| + | end |
| + | local special = damage(shelling_attack_power(fp, equip_fp[t] or 0, modifiers), modifiers) |
| + | return normal .. ", " .. special |
| end | | end |
| | | |
Line 246: |
Line 274: |
| local rank = frame.args[1] | | local rank = frame.args[1] |
| local ship_key = frame.args[2] | | local ship_key = frame.args[2] |
− | local typ = map_types[frame.args["type"]] or "dd" | + | local typ = frame.args["type"] |
| local note = frame.args["note"] | | local note = frame.args["note"] |
| | | |
Line 252: |
Line 280: |
| local ship_table = Ship:get_table(name, suffix) | | local ship_table = Ship:get_table(name, suffix) |
| | | |
− | if rank and name and ship_table and ship_table._type then | + | if rank and typ and name and ship_table and ship_table._type then |
| + | local fp = ship_table._firepower_max |
| local torp = ship_table._torpedo_max or 0 | | local torp = ship_table._torpedo_max or 0 |
− | local luck_diff = 60 - ship_table._luck | + | local luck = ship_table._luck |
| + | local luck_diff = 60 - luck |
| return format{ | | return format{ |
− | table_templates[typ .. "_row"], | + | templates[map_types[typ] .. "_row"], |
| rank = rank, | | rank = rank, |
| name = | | name = |
| note and format{'[[${name}|<span title="${note}">${name}</span>]]<sup>?</sup>', name = name, note = note} or | | note and format{'[[${name}|<span title="${note}">${name}</span>]]<sup>?</sup>', name = name, note = note} or |
| string.format("[[%s]]", name), | | string.format("[[%s]]", name), |
− | fp = ship_table._firepower_max, | + | fp = fp, |
| torp = torp, | | torp = torp, |
− | fp_plus_torp = ship_table._firepower_max + torp, | + | fp_plus_torp = fp + torp, |
− | db_attack = get_db_attack_string(ship_table._firepower_max, typ), | + | db_attack = get_db_attack_string(fp, typ), |
| db_torp = "", | | db_torp = "", |
| nb_da = "", | | nb_da = "", |
Line 270: |
Line 300: |
| luck_minus_cap = luck_diff < 0 and "−" .. -luck_diff or luck_diff, | | luck_minus_cap = luck_diff < 0 and "−" .. -luck_diff or luck_diff, |
| nb_ci_rate = | | nb_ci_rate = |
− | cut_in_rate(ship_table._luck, cut_in_types.torpedo) .. "%, " .. | + | cut_in_rate(luck, cut_in_types.torpedo) .. "%, " .. |
− | cut_in_rate(ship_table._luck, cut_in_types.main) .. "%", | + | cut_in_rate(luck, cut_in_types.main) .. "%", |
| } | | } |
| else | | else |
Line 278: |
Line 308: |
| | | |
| end | | end |
− |
| |
− | function Combat.table_cl(frame) return Combat.table_dd(frame) end
| |
− | function Combat.table_cl_row(frame) return Combat.table_dd_row(frame) end
| |
− | function Combat.table_ca(frame) return Combat.table_dd(frame) end
| |
− | function Combat.table_ca_row(frame) return Combat.table_dd_row(frame) end
| |
− | function Combat.table_cav(frame) return Combat.table_dd(frame) end
| |
− | function Combat.table_cav_row(frame) return Combat.table_dd_row(frame) end
| |
− | function Combat.table_bb(frame) return Combat.table_dd(frame) end
| |
− | function Combat.table_bb_row(frame) return Combat.table_dd_row(frame) end
| |
− | function Combat.table_bbv(frame) return Combat.table_dd(frame) end
| |
− | function Combat.table_bbv_row(frame) return Combat.table_dd_row(frame) end
| |
− |
| |
| | | |
| return Combat | | return Combat |