• 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
Add support for adding layers via call, more layers, layers for full cards
Line 2: Line 2:  
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
   −
local format = require("Module:StringInterpolation").format
+
local format = require("Module:StringOperations").format
 +
local split = require("Module:StringOperations").split
    
local ShipCardKai = {
 
local ShipCardKai = {
 
_card_size = "218x300px",
 
_card_size = "218x300px",
 
_battle_card_size = "160x40px",
 
_battle_card_size = "160x40px",
 +
_card_layers = {
 +
status_expedition = {image = "Card Status Expedition.png", top = "229px", left = "133px"},
 +
status_repair = {image = "Card Status Repair.png", top = "229px", left = "133px"},
 +
status_light_damage = {image = "Card Status Light Damage.png", top = "229px", left = "133px"},
 +
status_medium_damage = {image = "Card Status Medium Damage.png", top = "229px", left = "133px"},
 +
status_heavy_damage = {image = "Card Status Heavy Damage.png", top = "229px", left = "133px"},
 +
status_sunk = {image = "Card Status Sunk.png", top = "229px", left = "133px"},
 +
},
 
_battle_card_layers = {
 
_battle_card_layers = {
 
takoyaki = {image = "Hell plane 2.png", top = "5px", left = "50px", size = "30x30px"},
 
takoyaki = {image = "Hell plane 2.png", top = "5px", left = "50px", size = "30x30px"},
Line 16: Line 25:  
hell_offset_r1 = {image = "Hell plane 2.png", top = "9px", left = "109px", size = "30x30px"},
 
hell_offset_r1 = {image = "Hell plane 2.png", top = "9px", left = "109px", size = "30x30px"},
 
flagship = {image = "Flagship battle card icon.png", top = "3px", left = "139px"},
 
flagship = {image = "Flagship battle card icon.png", top = "3px", left = "139px"},
revenge_r2 = {image = "Hell plane 3.png", top = "3px", left = "130px", size = "30x33px"},
   
revenge_kai_l2 = {image = "Abyssal Revenge Torpedo Bomber Kai.png", top = "0px", left = "60px", size = "35x44px"},
 
revenge_kai_l2 = {image = "Abyssal Revenge Torpedo Bomber Kai.png", top = "0px", left = "60px", size = "35x44px"},
revenge_kai_r1 = {image = "Abyssal Revenge Torpedo Bomber Kai.png", top = "0px", left = "104px", size = "35x44px"},
   
revenge_kai_r2 = {image = "Abyssal Revenge Torpedo Bomber Kai.png", top = "0px", left = "125px", size = "35x44px"},
 
revenge_kai_r2 = {image = "Abyssal Revenge Torpedo Bomber Kai.png", top = "0px", left = "125px", size = "35x44px"},
 
revenge_kai_offset_l2 = {image = "Abyssal Revenge Torpedo Bomber Kai.png", top = "0px", left = "60px", size = "35x44px"},
 
revenge_kai_offset_l2 = {image = "Abyssal Revenge Torpedo Bomber Kai.png", top = "0px", left = "60px", size = "35x44px"},
Line 27: Line 34:  
hell_kai_offset_r1 = {image = "Abyssal Hell Dive Bomber Kai.png", top = "5px", left = "104px", size = "35x35px"},
 
hell_kai_offset_r1 = {image = "Abyssal Hell Dive Bomber Kai.png", top = "5px", left = "104px", size = "35x35px"},
 
attack_seaplane_kai_r = {image = "Abyssal Attack Seaplane Kai.png", top = "0px", left = "120px", size = "35x35px"},
 
attack_seaplane_kai_r = {image = "Abyssal Attack Seaplane Kai.png", top = "0px", left = "120px", size = "35x35px"},
 +
status_expedition = {image = "Battle Card Status Expedition.png", top = "0px", left = "0px"},
 +
status_repair = {image = "Battle Card Status Repair.png", top = "0px", left = "0px"},
 +
status_light_damage = {image = "Battle Card Status Light Damage.png", top = "0px", left = "0px"},
 +
status_medium_damage = {image = "Battle Card Status Medium Damage.png", top = "0px", left = "0px"},
 +
status_heavy_damage = {image = "Battle Card Status Heavy Damage.png", top = "0px", left = "0px"},
 +
status_light_damage_installation = {image = "Battle Card Status Light Damage Installation.png", top = "0px", left = "0px"},
 +
status_medium_damage_installation = {image = "Battle Card Status Medium Damage Installation.png", top = "0px", left = "0px"},
 +
status_heavy_damage_installation = {image = "Battle Card Status Heavy Damage Installation.png", top = "0px", left = "0px"},
 +
status_sunk_installation = {image = "Battle Card Status Sunk Installation.png", top = "0px", left = "0px"},
 +
smudge_light = {image = "Battle Card Smudge Light.png", top = "0px", left = "0px"},
 +
smudge_medium = {image = "Battle Card Smudge Medium.png", top = "0px", left = "0px"},
 +
smudge_heavy = {image = "Battle Card Smudge Heavy.png", top = "0px", left = "0px"},
 
},
 
},
_battle_card_wrapper = [[<span style="display: inline-block; position: relative;">${layers}</span>]],
+
_image_wrapper = [[<span class="image-stack" style="display: inline-block; position: relative;">${layers}</span>]],
_image_layer = [[<span style="position: absolute; top: ${top}; left: ${left}; line-height: 0px;">${image}</span>]],
+
_image_layer = [[<span class="image-layer" style="position: absolute; top: ${top}; left: ${left}; line-height: 0px;">${image}</span>]],
 
}
 
}
   Line 37: Line 56:  
ship = args.ship
 
ship = args.ship
 
end
 
end
return Formatting:format_image{args.damaged and ship:card_damaged() or ship:card(), size = args.size or self._card_size, link = args.link, caption = args.caption}
+
local image = Formatting:format_image{args.damaged and ship:card_damaged() or ship:card(), size = args.size or self._card_size, link = args.link, caption = args.caption}
 +
if args.layers then
 +
local layers = {image}
 +
for _, layer in ipairs(split(args.layers)) do
 +
if self._card_layers[layer] then
 +
self:_add_layer(layers, self._card_layers[layer])
 +
end
 +
end
 +
image = format{self._image_wrapper, layers = table.concat(layers)}
 +
end
 +
return image
 
end
 
end
   Line 52: Line 81:  
local image = Formatting:format_image{args.damaged and ship:battle_card_damaged() or ship:battle_card(), size = args.size or self._battle_card_size, link = args.link, caption = args.caption}
 
local image = Formatting:format_image{args.damaged and ship:battle_card_damaged() or ship:battle_card(), size = args.size or self._battle_card_size, link = args.link, caption = args.caption}
 
local ship_layers = ship:battle_card_layers()
 
local ship_layers = ship:battle_card_layers()
if ship_layers or args.flagship then
+
if ship_layers or args.flagship or args.layers then
 
local layers = {image}
 
local layers = {image}
 
if ship_layers then
 
if ship_layers then
Line 62: Line 91:  
self:_add_layer(layers, self._battle_card_layers.flagship)
 
self:_add_layer(layers, self._battle_card_layers.flagship)
 
end
 
end
image = format{self._battle_card_wrapper, layers = table.concat(layers)}
+
if args.layers then
 +
for _, layer in ipairs(split(args.layers)) do
 +
if self._battle_card_layers[layer] then
 +
self:_add_layer(layers, self._battle_card_layers[layer])
 +
end
 +
end
 +
end
 +
image = format{self._image_wrapper, layers = table.concat(layers)}
 
end
 
end
 
return image
 
return image
Anonymous user

Navigation menu