Wir laden dich herzlich auf den Star Citizen Wiki Discord Server ein! Du kannst uns auch auf unserem neuen YouTube-Chanel finden!
Modul:Volk
From Star Citizen Wiki
Views
Actions
Namespaces
Variants
Tools
Modulabhängigkeiten
Dieses Modul benötigt Modul:Sternensystem
Dieses Modul benötigt Modul:Common
Dieses Modul benötigt Modul:Infobox
Dieses Modul benötigt Modul:Arguments
Modulinfo
Dieses Modul setzt die Vorlage:Volk um. Anweisungen zur Verwendung findest du auf der Vorlagenseite.
local Volk = {}
local metatable = {}
local methodtable = {}
metatable.__index = methodtable
-- Needed Extensions
local infobox = require( 'Module:Infobox' )
local common = require( 'Module:Common' )
-- Creates the main title
function methodtable.getTitle( self )
local title = ''
if self.args[ 'title' ] ~= nil then
title = self.args[ 'title' ] .. ' ' .. mw.title.getCurrentTitle().subpageText
else
title = mw.title.getCurrentTitle().subpageText
end
return title
end
-- Adds the main category
function methodtable.setMainCategory( self )
table.insert( self.categories, '[[Category:Volk]]' )
end
--
function methodtable.getSystemCounts( self )
if self.args.code == nil then
return ''
end
local starsystem = require( 'Module:Sternensystem' )
local code = self.args.code
if code == 'Xi\'an' then
code = 'Xi\'An'
end
local query = {
'[[Kontrolle::' .. code .. ']][[Kategorie:Sternensystem]]',
'?#-=page',
'mainlabel=-',
}
local systems = mw.smw.ask( query )
local controlled = 0
if systems ~= nil and systems[ 1 ] ~= nil then
controlled = table.maxn( systems )
end
local smwQueryLink = mw.getCurrentFrame():preprocess( '{{#ask: [[Kontrolle::' .. code .. ']][[Kategorie:Sternensystem]]|format=ul|limit=0|searchlabel=Systeme|class=ul-col-3}}')
local line = starsystem.getAffiliationLines( code ) .. ' ' .. controlled .. ' ' .. smwQueryLink
query = {
'[[Kontrolle::Unclaimed]][[Kategorie:Sternensystem]]',
'?#-=page',
'mainlabel=-',
}
systems = mw.smw.ask( query )
controlled = 0
if systems ~= nil and systems[ 1 ] ~= nil then
controlled = table.maxn( systems )
end
smwQueryLink = mw.getCurrentFrame():preprocess( '{{#ask: [[Kontrolle::Unclaimed]][[Kategorie:Sternensystem]]|format=ul|limit=0|searchlabel=Systeme|class=ul-col-3}}')
line = line .. '<br>' .. starsystem.getAffiliationLines( 'UNCLAIMED' ) .. ' ' .. controlled .. ' ' .. smwQueryLink
return line
end
-- Public functions
--
function methodtable.getInfobox( self )
local box = infobox.create( {
bodyClass = 'floatright',
allowReplace = true,
} )
local titleImage = common.getImage( self.args[ 'image' ] or self.args[ 'Bild' ] )
box:addImage( titleImage )
if titleImage == false then
table.insert( self.categories, '[[Category:Volk mit fehlendem Bild]]' )
end
box:addTitle( self:getTitle() )
:addRow( 'Heimatplanet', self.args.homeworld, nil, 'col1' )
:addRow( 'Erstkontakt', self.args.first_contact, nil, 'col1' )
:addRow( 'Religion', self.args.religion, nil, 'col1' )
:addRow( 'Souverän', self.args.sovereign, nil, 'col1' )
:addRow( 'Regierungsform', self.args.government, nil, 'col1' )
:addRow( 'Währung', self.args.currency, nil, 'col1' )
:addRow( 'Territorien', self:getSystemCounts(), nil, 'col1' )
box:addRowsFromArgs( self.args, '!' )
return tostring( box ) .. tostring( table.concat( self.categories, '' ) )
end
--- Entrypoint for {{#seo:}}
--- @return void
function methodtable.setSeoData( self )
-- Call to {{#seo:}}
mw.ext.seo.set{
author = self.frame:preprocess( '{{SERVER}}/Benutzer:{{urlencode:{{REVISIONUSER}}|WIKI}}' ),
section = 'Universum',
url = tostring( mw.uri.fullUrl( mw.title.getCurrentTitle().text ) ),
title = table.concat({
mw.title.getCurrentTitle().subpageText,
'Volk',
self.frame:preprocess( '{{SITENAME}}' )
}, ' - '),
title_mode = 'replace',
locale = 'de_DE',
type = 'article',
}
end
--- Sets the frame and extracts the args
--- @param frame table
function methodtable.setFrame( self, frame )
self.frame = frame
self.args = require( 'Module:Arguments' ).getArgs( frame )
end
--- Entry point for template calls
--- @return string
function Volk.infoBox( frame )
local instance = Volk:new()
instance:setFrame( frame )
instance:setSeoData()
instance:setMainCategory()
return instance:getInfobox()
end
--- New Instance
--- Library entrance
function Volk.new( self )
local instance = {
frame = nil,
args = nil,
categories = {},
}
setmetatable( instance, metatable )
return instance
end
return Volk