Changes

no edit summary
Line 265: Line 265:  
end
 
end
    +
-- min(hp_max, hp + [4, 4, 4, 5, 6, 7, 7, 8, 8, 9][Math.floor(hp / 10)])
 
function ShipData:hp_married()
 
function ShipData:hp_married()
 
local bonuses = {
 
local bonuses = {
Line 278: Line 279:  
[9] = 9,
 
[9] = 9,
 
}
 
}
        local exceptions = {
+
    local exceptions = {
 
[131] = true, -- Yamato
 
[131] = true, -- Yamato
 
[143] = true, -- Musashi
 
[143] = true, -- Musashi
Line 297: Line 298:  
}
 
}
 
local hp = self:hp()
 
local hp = self:hp()
if not hp then
+
local hp_max = self:hp_max()
 +
if not hp or not hp_max then
 
return nil
 
return nil
 
end
 
end
local api_id = self:api_id()
+
-- not using exceptions should work as well
if exceptions[api_id] then
+
if exceptions[self:api_id()] then
return self:hp_max()
+
return hp_max
 
else
 
else
local hp_digit = math.floor(hp / 10)
+
local bonus = bonuses[math.floor(hp / 10)]
local bonus = bonuses[hp_digit]
   
if bonus then
 
if bonus then
return hp + bonus
+
return math.min(hp_max, hp + bonus)
 
else
 
else
 
return nil
 
return nil
7,212

edits