Difference between revisions of "Module:Factions"
Jump to navigation
Jump to search
Amidatelion (talk | contribs) |
|||
Line 19: | Line 19: | ||
ClanWolf = '[[Clan Wolf]]', | ClanWolf = '[[Clan Wolf]]', | ||
ComStar = '[[ComStar]]', | ComStar = '[[ComStar]]', | ||
+ | DaneSacellum = '[[Dane Sacellum]]', | ||
Davion = '[[Federated Suns|Federated Suns (Davion)]]', | Davion = '[[Federated Suns|Federated Suns (Davion)]]', | ||
DarkCaste = '[[Dark Caste]]', | DarkCaste = '[[Dark Caste]]', | ||
Line 24: | Line 25: | ||
Hanse = '[[Hanseatic League]]', | Hanse = '[[Hanseatic League]]', | ||
Ives = '[[St. Ives Compact]]', | Ives = '[[St. Ives Compact]]', | ||
+ | JacobsonHaven = '[[Jacobson Haven]]', | ||
JarnFolk = '[[JàrnFòlk]]', | JarnFolk = '[[JàrnFòlk]]', | ||
Kurita = '[[Draconis Combine|Draconis Combine (Kurita)]]', | Kurita = '[[Draconis Combine|Draconis Combine (Kurita)]]', | ||
Line 29: | Line 31: | ||
Locals = 'Local Government', | Locals = 'Local Government', | ||
MagistracyofCanopus = '[[Magistracy of Canopus]]', | MagistracyofCanopus = '[[Magistracy of Canopus]]', | ||
− | + | MallardRepublic = '[[Mallard Republic]]', | |
Marian = '[[Marian Hegemony]]', | Marian = '[[Marian Hegemony]]', | ||
Marik = '[[Free Worlds League|Free Worlds League (Marik)]]', | Marik = '[[Free Worlds League|Free Worlds League (Marik)]]', | ||
Line 35: | Line 37: | ||
Rasalhague = '[[Free Rasalhague Republic]]', | Rasalhague = '[[Free Rasalhague Republic]]', | ||
Rim = '[[Rim Collection]]', | Rim = '[[Rim Collection]]', | ||
+ | SanctuaryAlliance = '[[Sanctuary Alliance]]', | ||
Steiner = '[[Lyran Commonwealth|Lyran Commonwealth (Steiner)]]', | Steiner = '[[Lyran Commonwealth|Lyran Commonwealth (Steiner)]]', | ||
TaurianConcordat = '[[Taurian Concordat]]', | TaurianConcordat = '[[Taurian Concordat]]', |
Revision as of 05:37, 15 February 2023
Documentation for this module may be created at Module:Factions/doc
-- Module:Factions handles translating faction tags to their full names local p = {} local mechs = require('Module:Mech').core local getArgs = require('Module:Arguments').getArgs p.factionTags = { AuriganDirectorate = 'Aurigan Directorate', AuriganMercenaries = 'Mercenaries', AuriganPirates = '[[Local Pirates|Pirates]]', AuriganRestoration = '[[Aurigan Coalition|Aurigan Restoration (Arano)]]', Chainelane = '[[Chainelane Isles]]', Circinus = '[[Circinus Federation]]', ClanDiamondShark = '[[Clan Diamond Shark]]', ClanGhostBear = '[[Clan Ghost Bear]]', ClanJadeFalcon = '[[Clan Jade Falcon]]', ClanNovaCat = '[[Clan Nova Cat]]', ClanWolf = '[[Clan Wolf]]', ComStar = '[[ComStar]]', DaneSacellum = '[[Dane Sacellum]]', Davion = '[[Federated Suns|Federated Suns (Davion)]]', DarkCaste = '[[Dark Caste]]', Delphi = '[[New Delphi Compact]]', Hanse = '[[Hanseatic League]]', Ives = '[[St. Ives Compact]]', JacobsonHaven = '[[Jacobson Haven]]', JarnFolk = '[[JàrnFòlk]]', Kurita = '[[Draconis Combine|Draconis Combine (Kurita)]]', Liao = '[[Capellan Confederation|Capellan Confederation (Liao)]]', Locals = 'Local Government', MagistracyofCanopus = '[[Magistracy of Canopus]]', MallardRepublic = '[[Mallard Republic]]', Marian = '[[Marian Hegemony]]', Marik = '[[Free Worlds League|Free Worlds League (Marik)]]', Outworld = '[[Outworlds Alliance]]', Rasalhague = '[[Free Rasalhague Republic]]', Rim = '[[Rim Collection]]', SanctuaryAlliance = '[[Sanctuary Alliance]]', Steiner = '[[Lyran Commonwealth|Lyran Commonwealth (Steiner)]]', TaurianConcordat = '[[Taurian Concordat]]', Tortuga = '[[Tortuga Dominions]]', WordOfBlake = '[[Word of Blake]]' } function p.factionMechs(frame) local tpl_args = getArgs(frame, {parentFirst=true}) local faction = tpl_args[1] local where = string.format('Mech.MechTags HOLDS "%s"', faction) -- some mechs share the same name but have different tonnages and therefore -- different pages to be linked to local function MakeMechLink(name, variant, tonnage) if (name == "Blackjack" and tonnage ~= "45") or (name == "Centurion" and tonnage ~= "50") or (name == "Corsair" and tonnage ~= "95") or (name == "Stalker" and tonnage ~= "85") or (name == "Mad Cat MK II" and tonnage ~= "90") then return string.format('[[%s_(%sT)#%s|%s (%sT) %s]]', name, tonnage, variant, name, tonnage, variant) elseif string.find(variant, "ZEU-X", 1, true) then return string.format('[[Zeus_X#%s|Zeus X %s]]', variant, variant) else return string.format('[[%s#%s|%s %s]]', name, variant, name, variant) end end -- when querying for mechs, set the limit to 2000. this is arbitrarily high -- (larger than the total number of mechs). without this, factions with lots -- of mechs would not show all of them. local factionMechData = mw.ext.cargo.query( 'Mech,Chassis','Chassis.Name=Name,Chassis.VariantName=VariantName,Chassis.Tonnage=Tonnage', { join = 'Mech.ChassisID=Chassis.Id', where=where, limit=2000 } ) local mechsList = mw.html.create('ul') mechsList:cssText('column-count: 3;-moz-column-count: 3;-webkit-column-count: 3') for _, mech in ipairs(factionMechData) do mechsList:tag('li'):wikitext(MakeMechLink(mech.Name, mech.VariantName, tostring(mech.Tonnage))) end return mechsList end function p.mechFactions(frame) local tpl_args = getArgs(frame, {parentFirst=true}) variant = tpl_args[1] local mech = mechs.mech.byVariant(variant) if mech == nil then return mw.html.create('div').wikitext("''Mech not found''") end local tags = {} local factionList = mw.html.create('ul') for _, tag in ipairs(mech.tags) do if p.factionTags[tag] ~= nil then table.insert(tags, p.factionTags[tag]) end end table.sort(tags) for _, tag in ipairs(tags) do factionList:tag('li'):wikitext(tag) end return factionList end return p