Module:ShipGraphicKai

Revision as of 19:43, 23 September 2015 by がか (talk | contribs)

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

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

local ShipGraphicKai = {}

function ShipGraphicKai:create_ship(args)
	if args.name then
		return Ship(args.name, args.model)
	else
		return Ship(args[1])
	end
end

function ShipGraphicKai:graphic(ship, args, link)
	if not args then
		args = ship
		ship = args.ship
	end
	return Formatting:format_image{args.damaged and ship:cg_damaged() or ship:cg(), size = args.size, link = link, caption = args.caption}
end

function ShipGraphicKai:Graphic(args)
	local ship = self:create_ship(args)
	if args.filename == "true" then
		return args.damaged and ship:cg_damaged() or ship:cg()
	elseif args.link then
		if args.link == "nil" then
			return self:graphic(ship, args, nil)
		elseif args.link == "false" then
			return self:graphic(ship, args, false)
		else
			return self:graphic(ship, args, args.link)
		end
	else
		return self:graphic(ship, args, ship:link())
	end
end

return ShipGraphicKai