Dear visitors, IOP Wiki is currently the target of a denial of service campaign. We are investigating countermeasures. In the meantime, the Wiki may experience periods of unplanned downtime.

Module:PNCStats

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Jump to navigation Jump to search

Documentation for this module may be created at Module:PNCStats/doc

--This is a module to take the raw hero data and export all values for a given character, growth stage and value type
--The returned list is a string with comma separators in order to interface Lua and Javascript
--"Base", "Growth" and "Extra" data is related to hero rarity, "Potential" data is related to hero breakthrough
local p = {}

function p.display( frame )
	--Get invoke parameters
	local hero_ids = tonumber(frame.args[1])--1001... Value type-sanitized but not checked for range, all lists return 0 if not in range
	local level_id = tonumber(frame.args[2])--1 to 10. Value sanitized upstream by Widget:
	local type_id = frame.args[3]--atrBaseDic, atrGrowthDic, atrExtraDic or potential
	
	--Import raw values
	if type_id == 'potential' then
		potential_module = require("Module:Hero_potential")
		potential = potential_module.hero_potential
	else
		hero_module = require("Module:Hero_star")
		hero_star = hero_module.hero_star
	end
	
	local attributes = {102,103,104,105,107,109,110,112,115,126,127,128,202,203,204,212,226,227,228}
	--[[Info from LuaConfigs.attribute. 
	Other attributes exist but are not affected by hero growth. 
	Numbers >200 needed for atrExtraDic values.
	102,202 = Max HP
	103,203 = ATK
	104,204 = Physical Defense
	105 = Attack Speed
	107 = Dodge Rate
	109 = Critical Rate
	110 = Critical Damage (constant so far, but still explicitly included in the raw data)
	112,212 = Physical Penetration
	115 = HP Regeneration at turn end
	126,226 = Hashrate
	127,227 = Operands Defense
	128,228 = Operands Penetration]]

	local attributes_list = ''
	if type_id == 'potential' then
		for k,v in ipairs(attributes) do
			--The raw data sometimes skips values,
			--so we have to check and default to 0 where necessary
			if potential[hero_ids] and potential[hero_ids][level_id-1]['atrDic'] and potential[hero_ids][level_id-1]['atrDic'][v] then
				attributes_list = attributes_list..potential[hero_ids][level_id-1]['atrDic'][v]..','
			else
				attributes_list = attributes_list..'0,'
			end
		end
	else
		for k,v in ipairs(attributes) do
			--The raw data sometimes skips attributes,
			--so we have to check and default to 0 where necessary
			if hero_star[hero_ids] and hero_star[hero_ids][level_id][type_id] and hero_star[hero_ids][level_id][type_id][v] then
				attributes_list = attributes_list..hero_star[hero_ids][level_id][type_id][v]..','
			else
				attributes_list = attributes_list..'0,'
			end
		end
	end
	
	--Return raw list with comma separators
	--It is possible to have a valid list filled with 0, data check must be performed elsewhere
	return tostring( attributes_list )
end

return p