- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Changes
Jump to navigation
Jump to search
Line 1:
Line 1:
− +
− local ships = {}+
+
+
− local EnemyShipData = require('Module:EnemyShipData')+
− +
−
− return self:create(name, model)[stat]()
− end
−
− function EnemyShip:create(name, model)
− if name == nil then
− return EnemyShipData()
− end
− if model == nil then
− model = ""
− end
− --check if we already have it
− if ships[name] and ships[name][model] then
− return ships[name][model]
− else
− --Catch a failed require
− local success, ship_table = pcall(function () return require(mw.ustring.format('Module:%s', name)) end)
− --require succeeded
− if success then
− ship_table = ship_table[model]
− if not ship_table then
− --Instantiate EnemyShipData with what we have
− ship_table = {_name = name, _suffix = model}
− end
− --require failed
− else
− --Instantiate EnemyShipData with what we have
− ship_table = {_name = name, _suffix = model}
− end
− local ship = EnemyShipData(ship_table)
− if not ships[name] then
− ships[name] = {}
− end
− ships[name][model] = ship
− return ship
− end
− +
− function EnemyShip:get_module(name)
− if name == nil then
− return nil
− end
− return mw.ustring.format('Module:%s', name)
− end
−
− EnemyShip.__call = EnemyShip.create
− setmetatable(EnemyShip, EnemyShip)
−
Make EnemyShip an extension of Ship
local EnemyShip = {}
local EnemyShip = Ship:extend{
_ships = {}, --maintain a separate cache from Ship
_data_class = false,
}
function EnemyShip:_prepareShipData()
self._data_class = self._data_class or require('Module:EnemyShipData')
function EnemyShip:get(stat, name, model)
end
end
return EnemyShip
return EnemyShip