Module:CryptogullJr/Codes

From Caves of Qud Wiki
Jump to navigation Jump to search

local p = {}
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),]--
    --[8 Skills, Resist(9 ACID, 10 ELEC, 11 COLD, 12 HEAT, 13 BLEED), 14 bonusstart]--
caste = {
        --[The Toxic Arboreta of Ekuemekiyye, the Holy City]
        ['a'] = { "Horticulturist", 0, 0, 0, 3, 0, 0, "Harvestry, Axe Proficiency, Steady Hands, Draw a Bead, Wilderness Lore: Jungles", 0, 0, 0, 0, 2, "Start with a bio-scanning bracelet" },
        ['b'] = { "Priest of All Suns", 0, 0, 0, 0, 0, 3, "Cudgel Proficiency, Heal, Snake Oiler, Intimidate, Wilderness Lore: Jungles", 0, 0, 0, 0, 2, "Start with a smiling sun mask" },
        ['c'] = { "Priest of All Moons", 0, 0, 2, 0, 2, 0, "Axe Proficiency, Butchery, Lionheart, Poison Tolerance, Wilderness Lore: Jungles", 0, 0, 0, 0, 2, "Start with a frowning moon mask" },
        ['d'] = { "Syzygyrior", 0, 3, 0, 0, 0, 0, "Offhand Strikes, Ambidexterity, Wayfaring: Jungles", 0, 0, 0, 0, 0, "" },
        --[he Ice-Sheathed Arcology of Ibul]
        ['e'] = { "Artifex", 0, 0, 0, 3, 0, 0, "Repair, Disassemble, Deploy Turret, Tinker I, Tinker II", 0, 0, 15, 0, 0, "" },
        ['f'] = { "Consul", 0, 0, 0, 0, 0, 3, "Inspiring Presence, Proselytize", 0, 0, 15, 0, 0, "" },
        ['g'] = { "Praetorian", 2, 0, 1, 0, 1, 0, "Long Blade Proficiency, Shield Slam, Steady Hands, Draw a Bead", 0, 0, 15, 0, 0, "" },
        ['h'] = { "Eunuch", 0, 2, 0, 2, 0, 0, "Hobble, Weak Spotter, Spry, Hurdle", 0, 0, 15, 0, 0, "" },
        --[The Crustal Mortars of Yawningmoon]
        ['i'] = { "Child of the Hearth", 3, 0, 0, 0, 0, 0, "Slam, Calloused, Strapping Shoulders", 0, 0, 0, 15, 0, "" },
        ['j'] = { "Child of the Wheel", 1, 2, 0, 0, 0, 1, "Short Blades Proficiency, Cleave, Offhand Strikes, Iron Mind", 0, 0, 0, 15, 0, "" },
        ['k'] = { "Child of the Deep", 0, 0, 3, 0, 0, 0, "Tank, Strapping Shoulders, Shake It Off, Wilderness Lore: Mountains, Wilderness Lore: Canyons", 0, 0, 0, 15, 0, "" },
        ['l'] = { "Fuming God-Child", 0, 0, 0, 0, 4, 0, "Fasting Way, Lionheart, Poison Tolerance, Intimidate", 0, 0, 0, 15, 0, "" }
    }

    --[NAME, stats (STR, AGI, TUF, INT, WIL, EGO),]--
    --[Skills, Resist(ACID, ELEC, COLD, HEAT, BLEED), bonusstart]--
calling = {
        ['a'] = { "Apostle", 0, 0, 0, 0, 0, 2, "Intimidate, Proselytize, Tactful", 0, 0, 0, 0, 0, "" },
        ['b'] = { "Arconaut", 0, 2, 0, 0, 0, 0, "Short Blades Proficiency, Scavenger, Gadget Inspector, Spry", 0, 0, 0, 0, 0, "Start with random junk and artifacts" },
        ['c'] = { "Greybeard", -1, 0, 0, 0, 3, 0, "Cudgel Proficiency, Berate, Calloused", 0, 0, 0, 0, 0, "Start with +100 bear reputation" },
        ['d'] = { "Gunslinger", 0, 2, 0, 0, 0, 0, "Weak Spotter", 0, 0, 0, 0, 0, "Start with +200 reputation with mysterious strangers" },
        ['e'] = { "Marauder", 2, 0, 0, 0, 0, 0, "Dismember, Charge, Butchery", 0, 0, 0, 0, 0, "" },
        ['f'] = { "Pilgrim", 0, 0, 0, 0, 2, 0, "Meditate, Fasting Way, Iron Mind, Mind's Compass", 0, 0, 0, 0, 0, "" },
        ['g'] = { "Nomad", 0, 0, 2, 0, 0, 0, "Mind's Compass, Wilderness Lore: Salt Pans, Harvestry, Weathered", 0, 0, 15, 15, 0, "Starts with +200 Issachari reputation and a recycling suit" },
        ['h'] = { "Scholar", 0, 0, 0, 2, 0, 0, "Gadget Inspector, Heal, Harvestry, Hurdle, Tactful", 0, 0, 0, 0, 0, "" },
        ['i'] = { "Tinker", 0, 0, 0, 2, 0, 0, "Gadget Inspector, Lay Mine, Disassemble, Repair, Tinker I", 0, 0, 0, 0, 0, "Begins with a number of random artifacts and scrap and +100 Barathrumites reputation" },
        ['j'] = { "Warden", 2, 0, 0, 0, 0, 0, "Long Blades Proficiency, Shield Slam, Steady Hands, Draw a Bead, Pistol Proficiency", 0, 0, 0, 0, 0, "Starts with +300 Warden reputation" },
        ['k'] = { "Water Merchant", 0, 0, 0, 0, 0, 2, "Menacing Stare, Snake Oiler", 0, 0, 0, 0, 0, "Starts with trade goods and a merchant's token" },
        ['l'] = { "Watervine Farmer", 0, 0, 2, 0, 0, 0, "Cooking and Gathering, Harvestry, Axe Proficiency, Wilderness Lore: Salt Marshes", 0, 0, 0, 0, 0, "Starts with +100 reputation with the villagers of Joppa and a farmer's token" }
    }


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='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='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)
    return caste[code]
end

function p.MutantSubtype(code)
    return calling[code]
end

function p.getStatBonus(code)
	return statBonus[code]
end

function p.getexts(code, subtypeC)
    if code ~= nil and code == '16' then
        if subtypeC < 'e' then
            return { 'nocturnal apex'}
        elseif subtypeC < 'i' then
            return { 'cherubic visage'}
        else
            return { 'air current microsensor'}
        end
    else
        return muts[code]
    end
end

return p