• 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:EquipmentCardKai"

From Kancolle Wiki
Jump to navigation Jump to search
com>Ckwng
com>Ckwng
(Refactor)
Line 1: Line 1:
local Equipment = require('Module:Equipment')
+
local EquipmentAsset = require('Module:EquipmentAsset')
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
  
local EquipmentCardKai = {}
+
local EquipmentCardKai = EquipmentAsset()
  
function EquipmentCardKai:card(equip, args, link)
+
function EquipmentCardKai:get_source(equip)
 +
return equip:card()
 +
end
 +
 
 +
function EquipmentCardKai:get(equip, args, link)
 
if not args then
 
if not args then
 
args = equip
 
args = equip
Line 10: Line 14:
 
link = args.link
 
link = args.link
 
end
 
end
return Formatting:format_image{equip:card(), size = args.size, link = link, caption = args.caption}
+
return Formatting:format_image{self:get_source(equip), size = args.size, link = link, caption = args.caption}
end
 
 
 
function EquipmentCardKai:Card(args)
 
local equip = self:create_equip(args)
 
if args.link then
 
if args.link == "nil" then
 
return self:card(equip, args, nil)
 
elseif args.link == "false" then
 
return self:card(equip, args, false)
 
else
 
return self:card(equip, args, args.link)
 
end
 
else
 
return self:card(equip, args, equip:link())
 
end
 
 
end
 
end
  
function EquipmentCardKai:create_equip(args)
+
EquipmentCardKai.card = EquipmentCardKai.get
return Equipment(args[1])
 
end
 
  
 
return EquipmentCardKai
 
return EquipmentCardKai

Revision as of 23:05, 23 September 2015

Documentation for this module may be created at Module:EquipmentCardKai/doc

local EquipmentAsset = require('Module:EquipmentAsset')
local Formatting = require('Module:Formatting')

local EquipmentCardKai = EquipmentAsset()

function EquipmentCardKai:get_source(equip)
	return equip:card()
end

function EquipmentCardKai:get(equip, args, link)
	if not args then
		args = equip
		equip = args.equipment or args.equip
		link = args.link
	end
	return Formatting:format_image{self:get_source(equip), size = args.size, link = link, caption = args.caption}
end

EquipmentCardKai.card = EquipmentCardKai.get

return EquipmentCardKai