Modul:Adelskalendarium: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K (Schützte „Modul:Adelskalendarium“: SyncBot ([Bearbeiten=Nur Administratoren erlauben] (unbeschränkt))) |
K (SyncBot) |
||
| Zeile 29: | Zeile 29: | ||
..'|?Kennziffer' | ..'|?Kennziffer' | ||
..'|?Lehensebene' | ..'|?Lehensebene' | ||
..'|?Lehenstyp' | |||
..'|?Einwohner' | ..'|?Einwohner' | ||
..'|?Wappen ist#' | ..'|?Wappen ist#' | ||
| Zeile 49: | Zeile 50: | ||
end | end | ||
return s | return s | ||
end | |||
function farbeLehensebene(lehensebene) | |||
if lehensebene=='Herr' then return '#c0c0c0' end | |||
if lehensebene=='Junker' then return '#404040' end | |||
if lehensebene=='Baron' then return '#008000' end | |||
if lehensebene=='Graf' then return '#ffcc00' end | |||
if lehensebene=='Provinzherr' then return '#d40000' end | |||
if lehensebene=='Kaiser' then return '#0000c0' end | |||
if lehensebene=='Kirche' then return '#ffffff' end | |||
return '' | |||
end | end | ||
| Zeile 71: | Zeile 83: | ||
function classNachLevel(level) | function classNachLevel(level) | ||
local class=' | local class='' | ||
if level | if level==0 then | ||
class='dunkel' | class='dunkel' | ||
end | |||
if level==1 then | |||
class='mittel' | |||
end | |||
if level==2 then | |||
class='hell' | |||
end | end | ||
return class | return class | ||
| Zeile 86: | Zeile 104: | ||
end | end | ||
function starteTabelle() | function starteTabelle(maxlevel) | ||
local result='{| style="width:100%;border:none;"' | local result='{| style="width:100%;border:none;border-collapse:collapse"' | ||
..'\n|- style="font-style:italic;font-size:0.7em"' | |||
for i=1,maxlevel do | |||
result=result..'\n|width="10px"|' | |||
end | |||
result=result | |||
..'\n|width="30px"|' | |||
..'\n|width="10%"|Kennziffer' | |||
..'\n|width="20%"|Lehen' | |||
..'\n|width="10%" style="text-align:right;padding-right:1em"|Einwohner' | |||
..'\n|width="30%" |Herrscher' | |||
..'\n|width="10%" style="text-align:center"|Briefspiel' | |||
..'\n|width="10%" style="text-align:center"|Ebene' | |||
..'\n' | |||
return result | return result | ||
end | end | ||
| Zeile 125: | Zeile 156: | ||
end | end | ||
function formatiereInfos(lehen, | function lehensLevel(lehenstyp) | ||
if(lehenstyp=='Reich') then return 0 end | |||
if(lehenstyp=='Provinz') then return 1 end | |||
if(lehenstyp=='Grafschaft') then return 2 end | |||
if(lehenstyp=='Baronie') then return 3 end | |||
if(lehenstyp=='Großjunkertum') then return 4 end | |||
if(lehenstyp=='Junkertum') then return 5 end | |||
if(lehenstyp=='Herrschaft') then return 6 end | |||
if(lehenstyp=='Ortschaft') then return 7 end | |||
if(lehenstyp=='Bauwerk') then return 8 end | |||
return 9 | |||
end | |||
function formatiereInfos(lehen,extern,rekursion,columns,maxlevel,maxrekursion) | |||
local result='' | local result='' | ||
for k,v in spairs(lehen,function(lehen,a,b) | for k,v in spairs(lehen,function(lehen,a,b) | ||
return lehen[a]['Kennziffer']<lehen[b]['Kennziffer'] | return lehen[a]['Kennziffer']<lehen[b]['Kennziffer'] | ||
end) do | end) do | ||
local level=lehensLevel(nonil(v['Lehenstyp'])) | |||
local style=styleNachLevel(rekursion) | |||
local class=classNachLevel(rekursion) | |||
local wappendatei=nonil(v['Wappen ist']) | local wappendatei=nonil(v['Wappen ist']) | ||
local wappen='[['..wappendatei..'|30x30px|link=]]' | local wappen='[['..wappendatei..'|30x30px|link=]]' | ||
| Zeile 154: | Zeile 199: | ||
lehensebene='[[Datei:'..iconLehensebene(nonil(v['Lehensebene']),namespace,name)..'.svg|30x30px|link=|'..nonil(v['Lehensebene'])..']]' | lehensebene='[[Datei:'..iconLehensebene(nonil(v['Lehensebene']),namespace,name)..'.svg|30x30px|link=|'..nonil(v['Lehensebene'])..']]' | ||
end | end | ||
result=result | local farbe=farbeLehensebene(nonil(v['Lehensebene'])) | ||
if farbe=='' then class='' end | |||
local thiscolumn='\n|class="'..class..'"|' | |||
if level<=maxlevel then | |||
result=result | |||
..'\n|- style="'..style..'" class="'..class..'"' | |||
..columns | |||
..'\n| style="border:none;" colspan="'..(1+maxrekursion-rekursion)..'"|'..wappen | |||
..'\n| style="border:none;"|'..kennziffer | |||
if level<maxlevel then | ..'\n| style="border:none;padding-left:'..(rekursion*10)..'px"|'..artikellink | ||
..'\n| style="border:none;text-align:right;padding-right:1em"|'..einwohner | |||
..'\n| style="border:none;"|'..formatiereHerrscher(herrscher) | |||
..'\n| style="border:none;text-align:center"|'..formatiereBriefspieler(v['Briefspieler']) | |||
..'\n| style="border:none;text-align:center;background-color:'..farbe..'"|'..lehensebene | |||
end | |||
if (level<maxlevel) and (rekursion<maxrekursion) then | |||
local vasallen=holeInfos(artikel,extern,true) | local vasallen=holeInfos(artikel,extern,true) | ||
result=result..formatiereInfos(vasallen, | result=result..formatiereInfos(vasallen,extern,rekursion+1,columns..thiscolumn,maxlevel,maxrekursion) | ||
end | end | ||
end | end | ||
| Zeile 178: | Zeile 229: | ||
local extern=robusttrim(frame.args[2]) | local extern=robusttrim(frame.args[2]) | ||
local maxlevel=robusttrim(frame.args[3]) | local maxlevel=robusttrim(frame.args[3]) | ||
local maxrekursion=robusttrim(frame.args[4]) | |||
local selbst=holeInfos(lehen,extern,false) | local selbst=holeInfos(lehen,extern,false) | ||
local result=starteTabelle() | local result=starteTabelle(tonumber(maxrekursion)) | ||
..formatiereInfos(selbst,0, | ..formatiereInfos(selbst,extern,0,'',tonumber(maxlevel),tonumber(maxrekursion)) | ||
..endeTabelle() | ..endeTabelle() | ||
return result | return result | ||
Version vom 21. November 2024, 06:44 Uhr
Dokumentation und Testfälle unter Modul:Adelskalendarium/Doku.
local p = {}
require("Modul:Hilfsfunktionen")
function holeHerrscher(lehen)
if lehen=='' then return {} end
local herrscher=mw.smw.ask('[[Herrscher von Lehen::'..lehen..']] [[Herrscher von BisIndex::99990000]]'
..'|mainlabel=-'
..'|?Herrscher von Titel#=Titel'
..'|?=Herrscher'
..'|?Herrscher von Lehen#=Lehen'
..'|?Herrscher von Anzeige=Anzeige'
..'|?Herrscher von Von#=Von'
..'|limit=10'
)
if herrscher==nil then return {} end
return herrscher
end
function holeInfos(lehen,extern,vasallen)
if lehen=='' then return {} end
local s='[['..lehen..']]'
if vasallen then
s='[[Vasallenlehen von::'..lehen..']]'
end
local vasallen=mw.smw.ask(s..' [[Extern::'..extern..']]'
..'|mainlabel=-'
..'|?#-=Artikel'
..'|?Kennziffer'
..'|?Lehensebene'
..'|?Lehenstyp'
..'|?Einwohner'
..'|?Wappen ist#'
..'|?Icon ist#'
..'|?Briefspieler#'
..'|sort=Kennziffer'
..'|limit=500'
..'|searchlabel='
)
if vasallen==nil then return {} end
return vasallen
end
function nonil(s)
if(type(s)=='table') then
return 'TABLE'
end
if((s==nil)or(type(s)=='table')) then
return ''
end
return s
end
function farbeLehensebene(lehensebene)
if lehensebene=='Herr' then return '#c0c0c0' end
if lehensebene=='Junker' then return '#404040' end
if lehensebene=='Baron' then return '#008000' end
if lehensebene=='Graf' then return '#ffcc00' end
if lehensebene=='Provinzherr' then return '#d40000' end
if lehensebene=='Kaiser' then return '#0000c0' end
if lehensebene=='Kirche' then return '#ffffff' end
return ''
end
function iconLehensebene(lehensebene,namespace,name)
if lehensebene=='Herr' then return 'Edlenkrone' end
if lehensebene=='Junker' then return 'Junkerskrone' end
if lehensebene=='Baron' then return 'Baronskrone' end
if lehensebene=='Graf' then return 'Grafenkrone' end
if lehensebene=='Provinzherr' then
if namespace=='Garetien' then return 'Debrekskrone' end
if namespace=='Perricum' or namespace=='Greifenfurt' then return 'Markgrafenkrone' end
if namespace=='' then
if name=='Rommilyser Mark' or name=='Sonnenmark' or name=='Rabenmark' or name=='Markgrafschaft Warunk' or name=='Markgrafschaft Windhag' then return 'Markgrafenkrone' end
if name=='Fürstentum Albernia' or name=='Fürstentum Almada' or name=='Fürstentum Maraskan' or name=='Fürstentum Kosch' then return 'Fürstenkrone' end
if name=='Herzogtum Weiden' or name=='Herzogtum Tobrien' or name=='Herzogtum Nordmarken' then return 'Herzogenkrone' end
end
end
if lehensebene=='Kaiser' then return 'Raulskrone' end
if lehensebene=='Kirche' then return 'Kirchenkrone' end
return ''
end
function classNachLevel(level)
local class=''
if level==0 then
class='dunkel'
end
if level==1 then
class='mittel'
end
if level==2 then
class='hell'
end
return class
end
function styleNachLevel(level)
local style='font-size:'..(1.2-level/10)..'em;border:none;'
if level==0 then
style=style..'font-weight:bold;'
end
return style
end
function starteTabelle(maxlevel)
local result='{| style="width:100%;border:none;border-collapse:collapse"'
..'\n|- style="font-style:italic;font-size:0.7em"'
for i=1,maxlevel do
result=result..'\n|width="10px"|'
end
result=result
..'\n|width="30px"|'
..'\n|width="10%"|Kennziffer'
..'\n|width="20%"|Lehen'
..'\n|width="10%" style="text-align:right;padding-right:1em"|Einwohner'
..'\n|width="30%" |Herrscher'
..'\n|width="10%" style="text-align:center"|Briefspiel'
..'\n|width="10%" style="text-align:center"|Ebene'
..'\n'
return result
end
function endeTabelle()
local result='\n|}\n'
return result
end
function formatiereHerrscher(herrscher)
local result=''
for k,v in pairs(herrscher) do
result=result
..nonil(v['Titel'])..' '
..nonil(v['Herrscher'])..' '
..'[['..nonil(v['Lehen'])..'|'..v['Anzeige']..']] '
..'(seit '..nonil(v['Von'])..')<br>'
end
return result
end
function formatiereBriefspieler(briefspieler)
local result=''
if(briefspieler==nil) then return '' end
if(type(briefspieler)~='table') then briefspieler={briefspieler} end
for k,v in pairs(briefspieler) do
if v~='' then
local benutzer=string.match(v,"Benutzer:(.*)")
if benutzer~=nil then
result=result..'[[Datei:Bespielt.svg|20x20px|link='..v..']]'
else
result=result..'[[Datei:Bespielt NSC.svg|20x20px|link='..v..']]'
end
end
end
return result
end
function lehensLevel(lehenstyp)
if(lehenstyp=='Reich') then return 0 end
if(lehenstyp=='Provinz') then return 1 end
if(lehenstyp=='Grafschaft') then return 2 end
if(lehenstyp=='Baronie') then return 3 end
if(lehenstyp=='Großjunkertum') then return 4 end
if(lehenstyp=='Junkertum') then return 5 end
if(lehenstyp=='Herrschaft') then return 6 end
if(lehenstyp=='Ortschaft') then return 7 end
if(lehenstyp=='Bauwerk') then return 8 end
return 9
end
function formatiereInfos(lehen,extern,rekursion,columns,maxlevel,maxrekursion)
local result=''
for k,v in spairs(lehen,function(lehen,a,b)
return lehen[a]['Kennziffer']<lehen[b]['Kennziffer']
end) do
local level=lehensLevel(nonil(v['Lehenstyp']))
local style=styleNachLevel(rekursion)
local class=classNachLevel(rekursion)
local wappendatei=nonil(v['Wappen ist'])
local wappen='[['..wappendatei..'|30x30px|link=]]'
if wappendatei=='Datei:Wappen blanko.svg' then
wappen=''
end
local kennziffer=nonil(v['Kennziffer'])
local artikel=nonil(v['Artikel'])
local namespace=string.match(artikel,"(.*):")
if namespace==nil then
namespace=''
end
local name=string.match(artikel,":(.*)")
if name==nil then
name=artikel
end
local artikellink='[['..artikel..'|'..name..']]'
local einwohner=nonil(v['Einwohner'])
local herrscher=holeHerrscher(artikel)
lehensebene='[['..nonil(v['Icon ist'])..'|30x30px|link=|'..nonil(v['Lehensebene'])..']]'
if nonil(v['Icon ist'])==nonil(v['Wappen ist']) then
lehensebene='[[Datei:'..iconLehensebene(nonil(v['Lehensebene']),namespace,name)..'.svg|30x30px|link=|'..nonil(v['Lehensebene'])..']]'
end
local farbe=farbeLehensebene(nonil(v['Lehensebene']))
if farbe=='' then class='' end
local thiscolumn='\n|class="'..class..'"|'
if level<=maxlevel then
result=result
..'\n|- style="'..style..'" class="'..class..'"'
..columns
..'\n| style="border:none;" colspan="'..(1+maxrekursion-rekursion)..'"|'..wappen
..'\n| style="border:none;"|'..kennziffer
..'\n| style="border:none;padding-left:'..(rekursion*10)..'px"|'..artikellink
..'\n| style="border:none;text-align:right;padding-right:1em"|'..einwohner
..'\n| style="border:none;"|'..formatiereHerrscher(herrscher)
..'\n| style="border:none;text-align:center"|'..formatiereBriefspieler(v['Briefspieler'])
..'\n| style="border:none;text-align:center;background-color:'..farbe..'"|'..lehensebene
end
if (level<maxlevel) and (rekursion<maxrekursion) then
local vasallen=holeInfos(artikel,extern,true)
result=result..formatiereInfos(vasallen,extern,rekursion+1,columns..thiscolumn,maxlevel,maxrekursion)
end
end
return result
end
function p.Abfrage(frame)
if (frame.args[1]==nil) then
return 'no parameter found'
end
local lehen=robusttrim(frame.args[1])
local extern=robusttrim(frame.args[2])
local maxlevel=robusttrim(frame.args[3])
local maxrekursion=robusttrim(frame.args[4])
local selbst=holeInfos(lehen,extern,false)
local result=starteTabelle(tonumber(maxrekursion))
..formatiereInfos(selbst,extern,0,'',tonumber(maxlevel),tonumber(maxrekursion))
..endeTabelle()
return result
end
return p