• 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
no edit summary
Line 1: Line 1:  +
local U = require('Module:Utils')
 +
local ArtistData = require('Module:ArtistData')
 +
 
local Artist = {}
 
local Artist = {}
    
local artists = {}
 
local artists = {}
   −
local ArtistData = require('Module:ArtistData')
+
function Artist:get(stat, name)
 +
  return self:create(name)[stat]()
 +
end
   −
function Artist:get(stat, name)
+
local function requireArtistModule(name)
return self:create(name)[stat]()
+
  local success, data = U.requireModule(name)
 +
  if not success then
 +
    success, data = U.requireModule('Data/Artist/' .. name)
 +
  end
 +
  if not success then
 +
    data = {_name = name}
 +
  end
 +
  return data
 
end
 
end
    
function Artist:create(name)
 
function Artist:create(name)
if name == nil then
+
  if not name then
return ArtistData()
+
    return ArtistData()
--check if we already have it
+
  end
elseif artists[name] then
+
  if not artists[name] then
return artists[name]
+
    artists[name] = ArtistData(requireArtistModule(name))
else
+
  end
--Catch a failed require
+
  return artists[name]
local success, artist_table = pcall(function () return require(self:get_module(name)) end)
  −
--require failed
  −
if not success then
  −
--create a ArtistData with what we have
  −
artist_table = {_name = name}
  −
end
  −
local artist = ArtistData(artist_table)
  −
artists[name] = artist
  −
return artist
  −
end
   
end
 
end
    
function Artist:get_module(name)
 
function Artist:get_module(name)
if name == nil then
+
  return name and string.format('Module:Data/Artist/%s', name) or nil
return nil
  −
end
  −
return mw.ustring.format('Module:Artist/%s', name)
   
end
 
end
    
function Artist:extend(data)
 
function Artist:extend(data)
data = data or {}
+
  data = data or {}
setmetatable(data, data)
+
  setmetatable(data, data)
data.__index = self
+
  data.__index = self
data.__call = self.__call
+
  data.__call = self.__call
return data
+
  return data
 
end
 
end
  
cssedit, gkautomate
6,926

edits

Navigation menu