Module:Ship

Revision as of 03:36, 13 February 2015 by com>Ckwng

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

local Ship = {}
local ships = {}

local ShipData = require('Module:ShipData')

function Ship:get(stat, name, model)
	return self:create(name, model)[stat]()
end

function Ship:create(name, model)
	if model == nil then
		model = ""
	end
	if ships[name] and ships[name][model] then
		return ships[name][model]
	else
		local ship_table = require(mw.ustring.format('Module:%s', name))
		local ship = ShipData(ship_table[model])
		if not ships[name] then
			ships[name] = {}
		end
		ships[name][model] = ship
		return ship
	end
end

Ship.__call = Ship.create
setmetatable(Ship, Ship)

return Ship