Changes

Undo revision 544742 by Ckwng (talk) Wrong page!!!!
Line 1: Line 1: −
local Ship = {}
+
local BaseData = require('Module:BaseData')
local ships = {}
     −
local ShipData
+
local Ship = BaseData{
 +
_ships = {},
 +
_data_class = false,
 +
}
    
function Ship:_prepareShipData()
 
function Ship:_prepareShipData()
ShipData = ShipData or require('Module:ShipData')
+
self._data_class = self._data_class or require('Module:ShipData')
 
end
 
end
   Line 15: Line 17:  
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
Line 24: Line 26:  
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
ships[name] = {}
+
self._ships[name] = {}
 
end
 
end
ships[name][model] = ship
+
self._ships[name][model] = ship
 
return ship
 
return ship
 
end
 
end
Line 91: Line 93:  
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
  
Anonymous user