• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Difference between revisions of "Module:ShipMetaKai"

From Kancolle Wiki
Jump to navigation Jump to search
com>Ckwng
(WIP)
(No difference)

Revision as of 06:11, 2 August 2016

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

local BaseData = require('Module:BaseData')
local Equipment = require('Module:Equipment')
local EquipmentCardKai = require('Module:EquipmentCardKai')
local EquipmentGraphicKai = require('Module:EquipmentGraphicKai')
local Formatting = require('Module:Formatting')
local Tabber = require('Module:Tabber')

local format = require('Module:StringInterpolation').format

local ShipMetaKai = BaseData{
	_template = [[{|class="wikitable" style="float: right;" 
|-
!colspan=2|${name} ${japanese_name}
|-
!Class
|${class}
|-
!${voice_actor_header}
|${voice_actor}
|-
!${artist_header}
|${artist}
|-
!Availability
|${availability}
|-
!Implemented on
|${implementation_date}
|}]],
    _voice_actor_header = "[[Glossary#List of Vessels by Japanese Voice Actresses|Seiyuu]]",
    _artist_header = "[[Glossary#List of Vessels by Artist|Artist]]",
	_fields = {
	    "name",
	    "class",
	    "voice_actor",
	    "artist",
	    "availability",
	    "implementation_date",
	},
}

function ShipMetaKai:Infobox(args)
	return self{
		_args = args,
	}:create_infobox()
end

function ShipMetaKai:create_item()
	if self._args.name then
		self._ship = Ship(self._args.name, self._args.model)
	else
		self._ship = Ship(self._args[1])
	end
end

function ShipMetaKai:get_module()
	self._ship_data_module = Ship:get_module(self._args.name or self._args[1])
end

function ShipMetaKai:create_infobox_prep()
	self._vars = {}
	local table_classes = {"infobox"}
	if self._args.classes then
		table.insert(table_classes, self._args.classes)
	end
	local collapsible = self._args.collapsible
	if collapsible then
		table.insert(table_classes, "mw-collapsible")
		table.insert(table_classes, "mw-collapsed")
	end
	self._vars.table_class = table.concat(table_classes, " ")
	self._vars.table_id = collapsible and collapsible ~= "true" and ("mw-customcollapsible-" .. collapsible) or ""
	self._vars.float = self._args.float and format{self._float_style_template, float = self._args.float} or ""
end

function ShipMetaKai:format_template()
	for _, field in ipairs(self._fields) do
		self[field](self)
	end
	return format(self._template, self._vars)
end

function ShipMetaKai:add_fields()
	return
end

function ShipMetaKai:create_infobox()
	self:add_fields()
	self:create_item()
	self:get_module()
	self:create_infobox_prep()
	return self:format_template()
end

return ShipMetaKai