Changes

Replace artillery spotting percentages with actual numbers
Line 1: Line 1:  
local BaseData = require("Module:BaseData")
 
local BaseData = require("Module:BaseData")
 +
local Formatting = require('Module:Formatting')
    
local format = require('Module:StringInterpolation').format
 
local format = require('Module:StringInterpolation').format
Line 65: Line 66:  
[3] = "Bombing, displayed as Shelling",
 
[3] = "Bombing, displayed as Shelling",
 
},
 
},
_artillery_spotting_modes = {
+
_artillery_spotting_actions = {
[1] = "Double Attack (120% x2)",
+
[1] = "Double Attack",
[2] = "Double Attack (120% x2) / Cut-in: Secondary Gun (110%)",
+
[2] = "Cut-in: Secondary Gun",
[3] = "Double Attack (120% x2) / Cut-in: AP (150%)",
+
[3] = "Cut-in: Radar",
[4] = "Cut-in: Secondary Gun (110%)",
+
[4] = "Cut-in: AP", --130%
[5] = "Cut-in: Secondary Gun (110%) / Cut-in: Radar (120%)",
+
[5] = "Cut-in: AP", --150%
[6] = "Cut-in: Secondary Gun (110%) / Cut-in: AP (130%)",
+
},
 +
_artillery_spotting_attack_counts = {
 +
[1] = "x2",
 
},
 
},
 
_night_battle_modes = {
 
_night_battle_modes = {
Line 375: Line 378:     
-- Detect possible day time special attack modifiers.
 
-- Detect possible day time special attack modifiers.
function ShipCapabilities:artillery_spotting()
+
function ShipCapabilities:artillery_spotting(post_cap_attack_power)
 
local total_space = self._ship:total_space()
 
local total_space = self._ship:total_space()
 
if not total_space or total_space <= 0 then
 
if not total_space or total_space <= 0 then
Line 398: Line 401:  
end
 
end
 
if seaplanes >= 1 then
 
if seaplanes >= 1 then
 +
local attack_power
 +
if post_cap_attack_power then
 +
attack_power = post_cap_attack_power
 +
if attack_power == 0 then
 +
return false
 +
end
 +
else
 +
local attack_mode
 +
--assume no pre-cap modifiers
 +
attack_mode, attack_power = self:day_battle()
 +
if not attack_mode then
 +
return false
 +
end
 +
attack_power = math.min(attack_power, 150)
 +
end
 
if main_guns >= 2 then
 
if main_guns >= 2 then
 
if ap_shells >= 1 then
 
if ap_shells >= 1 then
return 3
+
return {{1, attack_power * 1.2}, {5, attack_power * 1.5}}
 
elseif secondary_guns >= 1 then
 
elseif secondary_guns >= 1 then
return 2
+
return {{1, attack_power * 1.2}, {2, attack_power * 1.1}}
 
end
 
end
return 1
+
return {{1, attack_power * 1.2}}
 
elseif main_guns == 1 and secondary_guns >= 1 then
 
elseif main_guns == 1 and secondary_guns >= 1 then
 
if radars >= 1 then
 
if radars >= 1 then
return 5
+
return {{2, attack_power * 1.1}, {3, attack_power * 1.2}}
 
elseif ap_shells >= 1 then
 
elseif ap_shells >= 1 then
return 6
+
return {{2, attack_power * 1.1}, {4, attack_power * 1.3}}
 
end
 
end
return 4
+
return {{2, attack_power * 1.1}}
 
end
 
end
 
end
 
end
Line 417: Line 435:  
end
 
end
   −
function ShipCapabilities:format_artillery_spotting(mode)
+
function ShipCapabilities:format_artillery_spotting(modes)
if mode then
+
if modes then
return self._artillery_spotting_modes[mode]
+
local result = {}
 +
for _, mode in ipairs(modes) do
 +
local attack_power = tostring(math.floor(mode[2]))
 +
local attack_mode = mode[1]
 +
local attack_count = self._artillery_spotting_attack_counts[attack_mode]
 +
if attack_count then
 +
attack_power = attack_power .. " " .. attack_count
 +
end
 +
table.insert(result, format{self._attack_template, mode = self._artillery_spotting_actions[attack_mode], attack_power = attack_power})
 +
end
 +
return Formatting:tooltip(table.concat(result, " / "), "Assuming Parallel Engagement, Line Ahead, and no damage penalty.")
 
end
 
end
 
return "No"
 
return "No"
Anonymous user