Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:SoulUnlock

From The Deadlock Wiki
Revision as of 03:04, 26 October 2024 by Sur (talk | contribs) (working version of accumulate())

Overview

Data for what is unlocked at each increment of Souls. Data is stored and loaded from Data:SoulUnlockData.json.

The data is accumulated into another format that is used by the currently written functions.

Functions

get_max

Retrieve's maximum value for a given key in the accumulated data

Examples

{{#invoke:SoulUnlock|get_max|RequiredSouls}} Script error: The function "get_max" does not exist.
{{#invoke:SoulUnlock|get_max|PowerIncrease}} Script error: The function "get_max" does not exist.
{{#invoke:SoulUnlock|get_max|AbilityUnlocks}} Script error: The function "get_max" does not exist.
{{#invoke:SoulUnlock|get_max|AbilityPoints}} Script error: The function "get_max" does not exist.

localize

Localize a key as its stored to the current language using Module:Lang.

Examples

{{#invoke:SoulUnlock|localize|RequiredSouls}} Script error: The function "localize" does not exist.
{{#invoke:SoulUnlock|localize|PowerIncrease}} Script error: The function "localize" does not exist.
{{#invoke:SoulUnlock|localize|AbilityUnlocks}} Script error: The function "localize" does not exist.
{{#invoke:SoulUnlock|localize|AbilityPoints}} Script error: The function "localize" does not exist.

write_accumulated

Writes the accumulated data to wikitext. Not a format that is ready to be displayed on a wiki page yet. Used for debugging for any lua editors working off of the accumulated data as opposed to the original data.

Note: the keys outputted are localized to english. See the localization map at the top of the Module source.

Example

{{#invoke:SoulUnlock|write_accumulated}}
Index1: RequiredSouls:0 AbilityUnlocks:1
Index2: AbilityUnlocks:1 PowerIncrease:1 RequiredSouls:300 AbilityPoints:1
Index3: AbilityUnlocks:2 PowerIncrease:2 RequiredSouls:900 AbilityPoints:1
Index4: AbilityUnlocks:2 PowerIncrease:3 RequiredSouls:1800 AbilityPoints:2
Index5: AbilityUnlocks:3 PowerIncrease:4 RequiredSouls:3300 AbilityPoints:2
Index6: AbilityUnlocks:3 PowerIncrease:5 RequiredSouls:5500 AbilityPoints:3
Index7: AbilityUnlocks:4 PowerIncrease:6 RequiredSouls:8500 AbilityPoints:3
Index8: AbilityUnlocks:4 PowerIncrease:7 RequiredSouls:12300 AbilityPoints:4
Index9: AbilityUnlocks:4 PowerIncrease:8 RequiredSouls:16900 AbilityPoints:5
Index10: AbilityUnlocks:4 PowerIncrease:9 RequiredSouls:22300 AbilityPoints:6
Index11: AbilityUnlocks:4 PowerIncrease:10 RequiredSouls:28500 AbilityPoints:7
Index12: AbilityUnlocks:4 PowerIncrease:11 RequiredSouls:35600 AbilityPoints:8
Index13: AbilityUnlocks:4 PowerIncrease:12 RequiredSouls:43600 AbilityPoints:9
Index14: AbilityUnlocks:4 PowerIncrease:13 RequiredSouls:52600 AbilityPoints:10
Index15: AbilityUnlocks:4 PowerIncrease:14 RequiredSouls:62800 AbilityPoints:11
Index16: AbilityUnlocks:4 PowerIncrease:15 RequiredSouls:74400 AbilityPoints:12
Index17: AbilityUnlocks:4 PowerIncrease:16 RequiredSouls:87600 AbilityPoints:13
Index18: AbilityUnlocks:4 PowerIncrease:17 RequiredSouls:102600 AbilityPoints:14
Index19: AbilityUnlocks:4 PowerIncrease:18 RequiredSouls:119600 AbilityPoints:15
Index20: AbilityUnlocks:4 PowerIncrease:19 RequiredSouls:138600 AbilityPoints:16
Index21: AbilityUnlocks:4 PowerIncrease:20 RequiredSouls:159600 AbilityPoints:17
Index22: AbilityUnlocks:4 PowerIncrease:21 RequiredSouls:182600 AbilityPoints:18
Index23: AbilityUnlocks:4 PowerIncrease:22 RequiredSouls:207600 AbilityPoints:19
Index24: AbilityUnlocks:4 PowerIncrease:23 RequiredSouls:234600 AbilityPoints:20
Index25: AbilityUnlocks:4 PowerIncrease:24 RequiredSouls:263600 AbilityPoints:21
Index26: AbilityUnlocks:4 PowerIncrease:25 RequiredSouls:294600 AbilityPoints:22
Index27: AbilityUnlocks:4 PowerIncrease:26 RequiredSouls:327600 AbilityPoints:23
Index28: AbilityUnlocks:4 PowerIncrease:27 RequiredSouls:362600 AbilityPoints:24
Index29: AbilityUnlocks:4 PowerIncrease:28 RequiredSouls:399600 AbilityPoints:25
Index30: AbilityUnlocks:4 PowerIncrease:29 RequiredSouls:438600 AbilityPoints:26
Index31: AbilityUnlocks:4 PowerIncrease:30 RequiredSouls:479600 AbilityPoints:27
Index32: AbilityUnlocks:4 PowerIncrease:31 RequiredSouls:522600 AbilityPoints:28
Index33: AbilityUnlocks:4 PowerIncrease:32 RequiredSouls:567600 AbilityPoints:29

write_table

Example

Script error: The function "write_table" does not exist.

Script error: The function "write_table" does not exist.


local p = {}
local util_module = require('Module:Utilities')
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json")

-- Accumulate the data from a list of entries of unlocks, AP, and PI's, to a hash with the # of each
local function accumulate() 
	local accumulated_data = {} --holds the sum at each gold count
	local sums = {} --holds only the current sums
	
	for i, su_data in ipairs(soul_unlocks_data) do
		for key, value in pairs(su_data) do
			-- Determine how many to increase sum by
			local num
			if type(value) == 'boolean' then 
				if value == true then
					num = 1
				else
					num = 0
				end
			elseif type(value) == 'number' then 
				num = value 
			else
				return "Module:SoulUnlockaccumulate() error, invalid value type"
			end
			
			
			-- Start at 0
			if sums[key] == nil then sums[key] = 0 end
			
			-- Sum the value, but not for gold because its already summed
			if key == 'RequiredGold' then
				sums[key] = num
			else
				sums[key] = sums[key] + num
			end
		end
		
		-- Add the current sum to accumulated_data
		table.insert(accumulated_data, util_module.deep_copy(sums))
	end
	
	return accumulated_data
end

local accumulated_data = accumulate()

function p.write_accumulated(frame)
	ret = ""
	for i, data in pairs(accumulated_data) do
		ret = ret .. "Index" .. i .. ": "
		for key, value in pairs(data) do
			ret = ret .. string.format("  %s:%s", key, value)	
		end
		ret = ret .. '<br>'
	end
	return ret
	--return accumulated_data['0']['AbilityUnlocks']
end

return p