Changes
no edit summary
local Ship = {}
local BaseData = require('Module:BaseData')
local ShipData
local Ship = BaseData{
_ships = {},
_data_class = false,
}
function Ship:_prepareShipData()
function Ship:_prepareShipData()
self._data_class = self._data_class or require('Module:ShipData')
end
end
self:_prepareShipData()
self:_prepareShipData()
if name == nil then
if name == nil then
return ShipData()
return self._data_class()
end
end
if model == nil then
if model == nil then
end
end
--check if we already have it
--check if we already have it
if ships[name] and ships[name][model] then
if self._ships[name] and self._ships[name][model] then
return ships[name][model]
return self._ships[name][model]
else
else
local ship = ShipData(self:get_table(name, model))
local ship = self._data_class(self:get_table(name, model))
if not ships[name] then
if not self._ships[name] then
self._ships[name] = {}
end
end
self._ships[name][model] = ship
return ship
return ship
end
end
end
end
return mw.ustring.format('Module:%s', name)
return mw.ustring.format('Module:%s', name)
end
function Ship:extend(data)
data = data or {}
setmetatable(data, data)
data.__index = self
data.__call = self.__call
return data
end
end