- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:Sandbox/CombatTable"
Jump to navigation
Jump to search
Line 59: | Line 59: | ||
{ torpedo = 12, rank = 10, k = 1 }, | { torpedo = 12, rank = 10, k = 1 }, | ||
}, | }, | ||
− | + | }, | |
+ | FBB = { | ||
+ | main = { | ||
+ | { firepower = 17, rank = 10, k = 1.5 }, | ||
+ | { firepower = 17, rank = 10, k = 1.5 }, | ||
+ | { firepower = 8, rank = 10, k = 1 }, | ||
+ | }, | ||
+ | torpedo = { | ||
+ | { torpedo = 12, rank = 10, k = 1 }, | ||
+ | { torpedo = 12, rank = 10, k = 1 }, | ||
+ | { torpedo = 12, rank = 10, k = 1 }, | ||
+ | { torpedo = 12, rank = 10, k = 1 }, | ||
+ | }, | ||
+ | main_ci = { | ||
+ | { firepower = 17, rank = 10, k = 1.5 }, | ||
+ | { firepower = 17, rank = 10, k = 1.5 }, | ||
+ | { firepower = 17, rank = 10, k = 1.5 }, | ||
+ | { firepower = 8, rank = 10, k = 1 }, | ||
+ | }, | ||
+ | }, | ||
+ | BB = { | ||
+ | main = { | ||
+ | { firepower = 22, rank = 10, k = 1.5 }, | ||
+ | { firepower = 22, rank = 10, k = 1.5 }, | ||
+ | { firepower = 8, rank = 10, k = 1 }, | ||
+ | }, | ||
+ | main_ci = { | ||
+ | { firepower = 22, rank = 10, k = 1.5 }, | ||
+ | { firepower = 22, rank = 10, k = 1.5 }, | ||
+ | { firepower = 22, rank = 10, k = 1.5 }, | ||
+ | { firepower = 8, rank = 10, k = 1 }, | ||
}, | }, | ||
}, | }, | ||
Line 70: | Line 100: | ||
CA = "CA", | CA = "CA", | ||
CAV = "CA", | CAV = "CA", | ||
− | FBB = " | + | FBB = "FBB", |
BB = "BB", | BB = "BB", | ||
BBV = "BB", | BBV = "BB", | ||
Line 85: | Line 115: | ||
FBB = "main", | FBB = "main", | ||
BB = "main", | BB = "main", | ||
− | CAV = " | + | CAV = "main", |
− | BBV = " | + | BBV = "main", |
CVL = "carrier", | CVL = "carrier", | ||
CV = "carrier", | CV = "carrier", | ||
Line 194: | Line 224: | ||
spotting = Combat.modifier.spotting.double, | spotting = Combat.modifier.spotting.double, | ||
note = "double attack", | note = "double attack", | ||
+ | }, | ||
+ | Bismarck = { | ||
+ | spotting = Combat.modifier.spotting.double, | ||
+ | note = "double attack", | ||
+ | nb_ci = Combat.modifier.night_attack.cut_in.torpedo, | ||
+ | nb_ci_equip = "torpedo", | ||
+ | }, | ||
+ | FBB = { | ||
+ | spotting = Combat.modifier.spotting.double, | ||
+ | note = "double attack", | ||
+ | nb_ci = Combat.modifier.night_attack.cut_in.main, | ||
+ | nb_ci_equip = "main_ci", | ||
+ | }, | ||
+ | BB = { | ||
+ | spotting = Combat.modifier.spotting.double, | ||
+ | note = "double attack", | ||
+ | nb_ci = Combat.modifier.night_attack.cut_in.main, | ||
+ | nb_ci_equip = "main_ci", | ||
}, | }, | ||
} | } | ||
Line 237: | Line 285: | ||
local template = templates[type_code_to_template[type_code_] .. "_row"] | local template = templates[type_code_to_template[type_code_] .. "_row"] | ||
local luck_diff = 60 - ship._luck | local luck_diff = 60 - ship._luck | ||
− | + | local attack = name == "Bismarrck" and attacks["Bismarrck"] or attacks[type_code] | |
+ | |||
return format{ | return format{ | ||
template, | template, | ||
Line 246: | Line 295: | ||
torp = ship._torpedo_max, | torp = ship._torpedo_max, | ||
fp_plus_torp = ship._firepower_max + (ship._torpedo_max or 0), | fp_plus_torp = ship._firepower_max + (ship._torpedo_max or 0), | ||
− | db_attack = format_damage(ship, type_code, Combat.shelling, "main", nil, | + | db_attack = format_damage(ship, type_code, Combat.shelling, "main", nil, attack.spotting), |
db_torp = format_damage(ship, type_code, Combat.torpedo, "torpedo"), | db_torp = format_damage(ship, type_code, Combat.torpedo, "torpedo"), | ||
nb_da = format_damage(ship, type_code, Combat.night_battle, "main", Combat.modifier.night_attack.double), | nb_da = format_damage(ship, type_code, Combat.night_battle, "main", Combat.modifier.night_attack.double), | ||
− | nb_ci = format_damage(ship, type_code, Combat.night_battle, "torpedo", Combat.modifier.night_attack.cut_in.torpedo), | + | nb_ci = format_damage(ship, type_code, Combat.night_battle, attack.nb_ci_equip or "torpedo", attack.nb_ci or Combat.modifier.night_attack.cut_in.torpedo), |
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 = format{ | nb_ci_rate = format{ |
Revision as of 12:23, 24 October 2015
Documentation for this module may be created at Module:Sandbox/CombatTable/doc
local format = require('Module:StringInterpolation').format
local Formatting = require('Module:Formatting')
local StatIcons = require('Module:StatIcons')
local Ship = require('Module:Ship')
local Combat = require('Module:Combat')
local equipment = {
DD = {
main = {
{ firepower = 3, rank = 10, k = 1 },
{ firepower = 3, rank = 10, k = 1 },
},
torpedo = {
-- Quint/53
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
},
},
CL = {
-- 20.3 #3
main = {
{ firepower = 10, rank = 10, k = 1 },
{ firepower = 10, rank = 10, k = 1 },
},
torpedo = {
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
},
},
CLT = {
main = {
-- OTO
{ firepower = 8, rank = 10, k = 1 },
{ firepower = 8, rank = 10, k = 1 },
-- Hyouteki
{ torpedo = 12 },
},
torpedo = {
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12 },
},
},
CA = {
main = {
-- 20.3 #3
{ firepower = 10, rank = 10, k = 1 },
{ firepower = 10, rank = 10, k = 1 },
-- FuMO
{ firepower = 3 },
},
torpedo = {
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
},
},
FBB = {
main = {
{ firepower = 17, rank = 10, k = 1.5 },
{ firepower = 17, rank = 10, k = 1.5 },
{ firepower = 8, rank = 10, k = 1 },
},
torpedo = {
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
{ torpedo = 12, rank = 10, k = 1 },
},
main_ci = {
{ firepower = 17, rank = 10, k = 1.5 },
{ firepower = 17, rank = 10, k = 1.5 },
{ firepower = 17, rank = 10, k = 1.5 },
{ firepower = 8, rank = 10, k = 1 },
},
},
BB = {
main = {
{ firepower = 22, rank = 10, k = 1.5 },
{ firepower = 22, rank = 10, k = 1.5 },
{ firepower = 8, rank = 10, k = 1 },
},
main_ci = {
{ firepower = 22, rank = 10, k = 1.5 },
{ firepower = 22, rank = 10, k = 1.5 },
{ firepower = 22, rank = 10, k = 1.5 },
{ firepower = 8, rank = 10, k = 1 },
},
},
}
local normalized_type_code = {
DD = "DD",
CL = "CL",
CLT = "CLT",
CA = "CA",
CAV = "CA",
FBB = "FBB",
BB = "BB",
BBV = "BB",
CVL = "CV",
CV = "CV",
CVB = "CV",
}
local type_code_to_template = {
DD = "main",
CL = "main",
CLT = "main",
CA = "main",
FBB = "main",
BB = "main",
CAV = "main",
BBV = "main",
CVL = "carrier",
CV = "carrier",
CVB = "carrier",
-- SS = "submarine",
-- SSV = "submarine_aviation",
-- AV = "...",
-- AO = "...",
}
function format_damage(ship_, type_code, damage_type_fn, equip_setup, night_attack, spotting)
local combat = Combat:new(night_attack)
local normal_damage = combat:damage(damage_type_fn(combat, Combat.ship(ship_, {}, night_attack)))
local normal_damage_string =
normal_damage >= combat.cap
and string.format('<span style="color:red;">%s</span>', normal_damage)
or normal_damage
local equip = equipment[type_code][equip_setup]
spotting = spotting or 1
local equip_damage_pre = combat:damage(damage_type_fn(combat, Combat.ship(ship_, equip, night_attack)))
local equip_damage = combat:damage(damage_type_fn(combat, Combat.ship(ship_, equip, night_attack, spotting)))
local equip_damage_string =
equip_damage_pre >= combat.cap
and string.format('<span style="color:red;">%s</span>', equip_damage)
or equip_damage
return
night_attack
and string.format("%s", equip_damage_string)
or string.format("%s, %s", normal_damage_string, equip_damage_string)
end
local templates = {
main = [[{| class="wikitable sortable typography-xl-optout" style="width:100%;"
! colspan="2" |
! colspan="4" |Day Battle
! colspan="5" |Night Battle
! colspan="3" |Defence
|-
!style="width:60px;"|Rank
!style="width:80px;"|Name
!${fp}
!${torp}
!<span title="Hit damage: without equipment, ${db_attack_note} with maxed equipment (all other modifiers = 1, see notes)">Hit</span>
!<span title="Torpedo salvo damage: without torpedo equipment, with maxed torpedo equipment (all other modifiers = 1, see notes)">Salvo</span>
!${fp_plus_torp}
!<span title="Maximal damage from double attack (each, multiple by 1.5 for critical hit)">DA</span>
!<span title="Maximal damage from cut-in (multiple by 2, multiple by 1.5 for critical hit)">CI</span>
!${luck_minus_cap}
!<span title="Torpedo/mixed cut-in rate, gun cut-in rate (only luck dependent part, no bonuses)">CI%</span>
!${hp}
!${armor}
!${evasion}
${rows}|}]],
carrier = [[{| class="wikitable sortable typography-xl-optout" style="width:100%;"
!style="width:60px;"|Rank
!style="width:80px;"|Name
!${fp}
!<span title="Air Power with full >> Reppuu">Air Power</span>
!<span title="">Aerial Hit</span>
!<span title="">Shelling</span>
${rows}|}]],
main_row = [[|-
|${rank}
|${name}
|${fp}
|${torp}
|${db_attack}
|${db_torp}
|${fp_plus_torp}
|${nb_da}
|${nb_ci}
|${luck_minus_cap}
|${nb_ci_rate}
|${hp}
|${armor}
|${evasion_rate}
]],
carrier_row = [[|-
|${rank}
|${name}
|${fp}
|
|
|
]],
}
local attacks = {
DD = {
spotting = 1,
note = "normal attack",
},
CL = {
spotting = Combat.modifier.spotting.double,
note = "double attack",
},
CLT = {
spotting = 1,
note = "normal attack",
},
CA = {
spotting = Combat.modifier.spotting.double,
note = "double attack",
},
Bismarck = {
spotting = Combat.modifier.spotting.double,
note = "double attack",
nb_ci = Combat.modifier.night_attack.cut_in.torpedo,
nb_ci_equip = "torpedo",
},
FBB = {
spotting = Combat.modifier.spotting.double,
note = "double attack",
nb_ci = Combat.modifier.night_attack.cut_in.main,
nb_ci_equip = "main_ci",
},
BB = {
spotting = Combat.modifier.spotting.double,
note = "double attack",
nb_ci = Combat.modifier.night_attack.cut_in.main,
nb_ci_equip = "main_ci",
},
}
local Table = {}
function Table.header(frame)
local type_code_ = frame.args["type"]
local type_code = normalized_type_code[type_code_]
local template = templates[type_code_to_template[type_code_]]
return format{
template,
rows = frame.args[1] or "",
db_attack_note = attacks[type_code].note or "?",
fp = Formatting:format_image{StatIcons.firepower, caption = Formatting:format_stat_name("firepower")},
torp = Formatting:format_image{StatIcons.torpedo, caption = Formatting:format_stat_name("torpedo")},
fp_plus_torp =
Formatting:format_image{StatIcons.firepower, caption = Formatting:format_stat_name("firepower")}
.. "+" ..
Formatting:format_image{StatIcons.torpedo, caption = Formatting:format_stat_name("torpedo")},
luck_minus_cap =
'<span title="Luck cap">60</span>−' ..
Formatting:format_image{StatIcons.luck, caption = Formatting:format_stat_name("luck")},
hp = Formatting:format_image{StatIcons.hp, caption = Formatting:format_stat_name("HP")},
armor = Formatting:format_image{StatIcons.armor, caption = Formatting:format_stat_name("Armor")},
evasion = Formatting:format_image{StatIcons.evasion, caption = Formatting:format_stat_name("Evasion rate")},
}
end
function Table.row(frame)
local rank = frame.args[1]
local ship_key = frame.args[2]
local note = frame.args["note"]
local name, suffix = Ship:process_ship_key(ship_key)
local ship = Ship:get_table(name, suffix)
if rank and name and ship and ship._type then
local type_code_ = Formatting:format_ship_code(ship._type)
local type_code = normalized_type_code[type_code_]
local template = templates[type_code_to_template[type_code_] .. "_row"]
local luck_diff = 60 - ship._luck
local attack = name == "Bismarrck" and attacks["Bismarrck"] or attacks[type_code]
return format{
template,
rank = rank,
name = note and format{'[[${name}|<span title="${note}">${name}</span>]]<sup>?</sup>', name = name, note = note} or
string.format("[[%s]]", name),
fp = ship._firepower_max,
torp = ship._torpedo_max,
fp_plus_torp = ship._firepower_max + (ship._torpedo_max or 0),
db_attack = format_damage(ship, type_code, Combat.shelling, "main", nil, attack.spotting),
db_torp = format_damage(ship, type_code, Combat.torpedo, "torpedo"),
nb_da = format_damage(ship, type_code, Combat.night_battle, "main", Combat.modifier.night_attack.double),
nb_ci = format_damage(ship, type_code, Combat.night_battle, attack.nb_ci_equip or "torpedo", attack.nb_ci or Combat.modifier.night_attack.cut_in.torpedo),
luck_minus_cap = luck_diff < 0 and "−" .. -luck_diff or luck_diff,
nb_ci_rate = format{
[[${torpedo}%, ${main}%]],
torpedo = Combat.nb_cut_in_rate(ship, Combat.nb_cut_in_types.torpedo),
main = Combat.nb_cut_in_rate(ship, Combat.nb_cut_in_types.main)},
hp = ship._hp,
armor = ship._armor_max,
evasion_rate = Combat.evasion_rate(ship) .. "%",
}
else
return ""
end
end
return Table