• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
Undo revision 1098795 by がか (talk)
Line 11: Line 11:  
local EquipmentByApiId = require('Module:Collection/EquipmentByApiId')
 
local EquipmentByApiId = require('Module:Collection/EquipmentByApiId')
   −
local function getShipCard(ship)
+
local function getShipCard(ship, hp, maxHp)
 +
    local minHp = type(hp) == 'table' and U.imin(hp) or hp
 
     local id = tonumber(ship)
 
     local id = tonumber(ship)
 
     if id then
 
     if id then
 
         ship = ShipsByApiId[id]
 
         ship = ShipsByApiId[id]
 
     end
 
     end
     return ShipBattleCardKai:Asset({ ship, hd = true, size = '160px' })
+
     return ShipBattleCardKai:Asset({
 +
        ship,
 +
        hd = true,
 +
        size = '160px',
 +
        damaged = minHp / maxHp <= 0.5 and 'true' or 'false',
 +
        layers = minHp / maxHp <= 0.5 and 'status_medium_damage' or minHp / maxHp <= 0.75 and 'status_light_damage' or '',
 +
    })
 
end
 
end
   Line 85: Line 92:     
local function formatHp(hps, maxHp)
 
local function formatHp(hps, maxHp)
     return string.format(
+
  local minHp = U.imin(hps)
        '<span class="explain" title="%s">~/%s</span>',
+
  if minHp / maxHp <= 0.5 then
        U.ijoin(hps, ', '),
+
     return string.format('{{color|red|{{tooltip|~/%s|%s}}}}', maxHp, U.ijoin(hps, ', '))
        maxHp
+
  elseif minHp / maxHp <= 0.75 then
     )
+
    return string.format('{{color|coral|{{tooltip|~/%s|%s}}}}', maxHp, U.ijoin(hps, ', '))
 +
  else
 +
     return string.format('{{tooltip|~/%s|%s}}', maxHp, U.ijoin(hps, ', '))
 +
  end
 
end
 
end
   Line 141: Line 151:  
                 table.insert(result, string.format(
 
                 table.insert(result, string.format(
 
                     '|-\n|%s||%s||style="text-align:left;white-space:nowrap"|%s||%s||%s||%s||%s||%s',
 
                     '|-\n|%s||%s||style="text-align:left;white-space:nowrap"|%s||%s||%s||%s||%s||%s',
                     getShipCard(ship.ship),
+
                     getShipCard(ship.ship, ship.hp, ship.maxHp),
 
                     ship.level,
 
                     ship.level,
 
                     U.ijoin(U.imap(ship.equipment, function(eq) return getEquipmentCard(eq, cardSize) end)),
 
                     U.ijoin(U.imap(ship.equipment, function(eq) return getEquipmentCard(eq, cardSize) end)),
cssedit, gkautomate
6,941

edits

Navigation menu