Module:CryptogullJr/Codes: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(update for mutations rework) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local cargo = mw.ext.cargo | local cargo = mw.ext.cargo | ||
local textutil = require'Module:Text Utility' | |||
--[1 NAME, stats (2 STR, 3 AGI, 4 TUF, 5 INT, 6 WIL, 7 EGO),]-- | --[1 NAME, stats (2 STR, 3 AGI, 4 TUF, 5 INT, 6 WIL, 7 EGO),]-- | ||
Line 54: | Line 40: | ||
} | } | ||
statBonus = { | |||
['Doubled-muscled'] = {2, 0, 0, 0, 0, 0}, | |||
['Triple-jointed'] = {0, 2, 0, 0, 0, 0}, | |||
['Two-hearted'] = {0, 0, 2, 0, 0, 0}, | |||
['Beak'] = {0, 0, 0, 0, 0, 1}, | |||
['No Cybernetic'] = {0, 0, 1, 0, 0, 0} | |||
} | |||
function p.mergeCodes(muttable, cybtable) | |||
finaltable = muttable | |||
for k,v in pairs(cybtable) do | |||
if finaltable[k] then | |||
error("there are cybernetics and mutations that have the same creation code!") | |||
end | |||
finaltable[k] = v | |||
end | |||
return finaltable | |||
end | |||
function getMutCodes() | |||
local mutresult = cargo.query('Mutations', '_pageName=Name, CreationCode, Variants, Type', | |||
{where='_pageNamespace="0" AND CreationCode <> ""', | |||
default=nil, | |||
orderBy='CreationCode ASC'} ) | |||
--[If there was no result, search by alias instead] | |||
if not next(mutresult) then | |||
error('There was no defined mutation table, or it wasn\'t found.') | |||
else | |||
-- Next, reorganize the table so it's [code] = {other, fields} | |||
mutresulttable = {} | |||
for _,j in ipairs(mutresult) do | |||
mutresulttable[j['CreationCode']] = {j['Name'], textutil.split(j['Variants']), j['Type'] } | |||
end | |||
-- Add unstable genome stacks because they're not stored | |||
mutresulttable['u2'] = {"Unstable Genome(2)", "", "Genotype"} | |||
mutresulttable['u3'] = {"Unstable Genome(3)", "", "Genotype"} | |||
mutresulttable['u4'] = {"Unstable Genome(4)", "", "Genotype"} | |||
mutresulttable['u5'] = {"Unstable Genome(5)", "", "Genotype"} | |||
mutresulttable['u6'] = {"Unstable Genome(6)", "", "Genotype"} | |||
mutresulttable['u7'] = {"Unstable Genome(7)", "", "Genotype"} | |||
mutresulttable['u8'] = {"Unstable Genome(8)", "", "Genotype"} | |||
mutresulttable['u9'] = {"Unstable Genome(9)", "", "Genotype"} | |||
return mutresulttable | |||
end | |||
end | |||
function getCyberneticsCodes() | |||
local cyberneticresult = cargo.query('Cybernetics', | |||
'Name, CreationCode, StartingCybernetic', | |||
{where='_pageNamespace="10002" AND CreationCode <> ""', | |||
default=nil, | |||
orderBy='CreationCode ASC'} ) | |||
--[If there was no result, search by alias instead] | |||
if not next(cyberneticresult) then | |||
error('There was no defined cybernetic table, or it wasn\'t found.') | |||
else | |||
-- Next, reorganize the table so it's [code] = {other, fields} | |||
cyberneticresulttable = {} | |||
arcologycybertable = {} | |||
for _,j in ipairs(cyberneticresult) do | |||
if j['CreationCode'] ~= "16" then -- no 16 variants | |||
cyberneticresulttable[j['CreationCode']] = {j['Name'], j['StartingCybernetic']} | |||
end | |||
end | |||
-- add no cybernetic because its not stored | |||
cyberneticresulttable['00'] = {"No Cybernetic", "", ""} | |||
return cyberneticresulttable | |||
end | |||
end | |||
muts = p.mergeCodes(getMutCodes(), getCyberneticsCodes()) | |||
function p.TrueKinSubtype(code) | function p.TrueKinSubtype(code) | ||
Line 179: | Line 120: | ||
function p.MutantSubtype(code) | function p.MutantSubtype(code) | ||
return calling[code] | return calling[code] | ||
end | |||
function p.getStatBonus(code) | |||
return statBonus[code] | |||
end | end | ||
Line 184: | Line 129: | ||
if code ~= nil and code == '16' then | if code ~= nil and code == '16' then | ||
if subtypeC < 'e' then | if subtypeC < 'e' then | ||
return { 'nocturnal apex' | return { 'nocturnal apex'} | ||
elseif subtypeC < 'i' then | elseif subtypeC < 'i' then | ||
return { 'cherubic visage' | return { 'cherubic visage'} | ||
else | else | ||
return { 'air current microsensor' | return { 'air current microsensor'} | ||
end | end | ||
else | else | ||
return muts[code] | return muts[code] | ||
end | end | ||
end | end | ||
return p | return p |