Skip to content

Commit 3d3800f

Browse files
justjuanguijustjuangui
andauthored
Added validation for the existence of stats in passive skills, active skills, and mods (#488)
* Added validation for the existence of stats in passive skills, active skills, and mods * Ignore stats doesnt have number values in set levels --------- Co-authored-by: justjuangui <servicios@juacarvajal.com>
1 parent 9df386d commit 3d3800f

File tree

7 files changed

+133
-15
lines changed

7 files changed

+133
-15
lines changed

src/Data/StatDescriptions/Specific_Skill_Stat_Descriptions/sniper_gas_shot_statset_1.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ return {
122122
["active_skill_base_area_of_effect_radius"]=4,
123123
["base_secondary_skill_effect_duration"]=2,
124124
["base_skill_effect_duration"]=5,
125-
parent="specific_skill_stat_descriptions/sniper_gas_shot\statset_0",
125+
parent="specific_skill_stat_descriptions/sniper_gas_shot_statset_0",
126126
["secondary_skill_effect_duration"]=1,
127127
["skill_effect_duration"]=6
128128
}

src/Data/StatDescriptions/Specific_Skill_Stat_Descriptions/sniper_gas_shot_statset_2.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ return {
1414
},
1515
["active_skill_area_of_effect_radius"]=2,
1616
["active_skill_base_area_of_effect_radius"]=1,
17-
parent="specific_skill_stat_descriptions/sniper_gas_shot\statset_0"
17+
parent="specific_skill_stat_descriptions/sniper_gas_shot_statset_0"
1818
}

src/Export/Scripts/mods.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,17 @@ local function writeMods(outName, condFunc)
2121
out:write('-- Item data (c) Grinding Gear Games\n\nreturn {\n')
2222
for mod in dat("Mods"):Rows() do
2323
if condFunc(mod) then
24-
local stats, orders = describeMod(mod)
24+
local stats, orders, missing = describeMod(mod)
25+
if missing[1] then
26+
ConPrintf("====================================")
27+
ConPrintf("Mod '"..mod.Id.."' is missing stats:")
28+
for k, _ in pairs(missing) do
29+
if k ~= 1 then
30+
ConPrintf('%s', k)
31+
end
32+
end
33+
ConPrintf("====================================")
34+
end
2535
if #orders > 0 then
2636
out:write('\t["', mod.Id, '"] = { ')
2737
if mod.GenerationType == 1 then

src/Export/Scripts/passivetree.lua

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ local cacheExtract = main.treeCacheExtract
99
if not loadStatFile then
1010
dofile("statdesc.lua")
1111
end
12-
loadStatFile("stat_descriptions.csd")
1312
loadStatFile("passive_skill_stat_descriptions.csd")
1413

1514
local function extractFromGgpk(listToExtract, useRegex)
@@ -654,6 +653,7 @@ printf("Generating tree groups...")
654653

655654
local orbitsConstants = { }
656655
local ascendancyGroups = {}
656+
local missingStatInfo = {}
657657
for i, group in ipairs(psg.groups) do
658658
local groupIsAscendancy = false
659659
local treeGroup = {
@@ -721,12 +721,33 @@ for i, group in ipairs(psg.groups) do
721721

722722
-- Stats
723723
if passiveRow.Stats ~= nil then
724-
node["stats"] = {}
724+
node["stats"] = node["stats"] or {}
725725
local parseStats = {}
726+
local totalStats = 0
727+
local namesStats = ""
726728
for k, stat in ipairs(passiveRow.Stats) do
727729
parseStats[stat.Id] = { min = passiveRow["Stat" .. k], max = passiveRow["Stat" .. k] }
730+
totalStats = totalStats + 1
731+
namesStats = namesStats .. stat.Id .. " | "
732+
end
733+
local out, orders, missing = describeStats(parseStats)
734+
if #out < totalStats then
735+
table.insert(missingStatInfo, "====================================")
736+
table.insert(missingStatInfo,"Stats not found for passive " .. passiveRow.Name .. " " .. passive.id)
737+
table.insert(missingStatInfo,"Stats found: " .. totalStats)
738+
table.insert(missingStatInfo,namesStats)
739+
table.insert(missingStatInfo,"Stats out: " .. #out)
740+
for k, line in ipairs(out) do
741+
table.insert(missingStatInfo,line)
742+
end
743+
table.insert(missingStatInfo,"Missing: ")
744+
for k, _ in pairs(missing) do
745+
if k ~= 1 then
746+
table.insert(missingStatInfo,k)
747+
end
748+
end
749+
table.insert(missingStatInfo,"====================================")
728750
end
729-
local out, orders = describeStats(parseStats)
730751
for k, line in ipairs(out) do
731752
table.insert(node["stats"], line)
732753
end
@@ -761,6 +782,22 @@ for i, group in ipairs(psg.groups) do
761782
for _, gemEffect in pairs(passiveRow.GrantedSkill.GemEffects) do
762783
local skillname = gemEffect.GrantedEffect.ActiveSkill.DisplayName
763784
table.insert(node["stats"], "Grants Skill: " .. skillname)
785+
786+
-- -- include the stat description
787+
local statDescription =string.sub(string.lower(gemEffect.GrantedEffect.ActiveSkill.StatDescription), 1, -2)
788+
local handle = NewFileSearch("ggpk/" .. statDescription ..".csd")
789+
local almostOnce = false
790+
while handle do
791+
almostOnce = true
792+
print(statDescription:gsub("metadata/statdescriptions", "") .. ".csd")
793+
-- loadStatFile(statDescription:gsub("metadata/statdescriptions/", "") .. ".csd")
794+
if not handle:NextFile() then
795+
break
796+
end
797+
end
798+
if not almostOnce then
799+
table.insert(missingStatInfo, "===================================>Missing stat" .. statDescription)
800+
end
764801
end
765802
end
766803

@@ -875,6 +912,15 @@ for i, group in ipairs(psg.groups) do
875912
end
876913
end
877914

915+
-- write file with missing Stats
916+
if #missingStatInfo > 0 then
917+
local file = io.open(basePath .. version .. "/missingStats.txt", "w")
918+
for _, line in ipairs(missingStatInfo) do
919+
file:write(line .. "\n")
920+
end
921+
file:close()
922+
end
923+
878924
-- updating skillsPerOrbit
879925
printf("Updating skillsPerOrbit...")
880926
for i, orbit in ipairs(orbitsConstants) do

src/Export/Scripts/skills.lua

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,44 @@ local directiveTable = { }
219219
local fromSpec = nil
220220
local minionList = nil
221221

222+
local loadedStatDescriptionLua = { }
223+
function checkModInStatDescription(statDescription, line)
224+
local searchIn = statDescription
225+
local stat
226+
227+
repeat
228+
if loadedStatDescriptionLua[searchIn] then
229+
stat = loadedStatDescriptionLua[searchIn]
230+
else
231+
local errMsg, newStat
232+
errMsg, newStat = PLoadModule("../Data/StatDescriptions/"..searchIn..".lua")
233+
if errMsg then
234+
errMsg, newStat = PLoadModule("../Data/StatDescriptions/Specific_Skill_Stat_Descriptions/"..searchIn..".lua")
235+
236+
if errMsg then
237+
ConPrintf("Error loading stat description: %s", errMsg)
238+
return false
239+
end
240+
end
241+
242+
loadedStatDescriptionLua[searchIn] = newStat
243+
stat = newStat
244+
end
245+
246+
if stat[line] then
247+
return true
248+
end
249+
250+
if stat.parent then
251+
searchIn = stat.parent
252+
else
253+
searchIn = ""
254+
end
255+
until searchIn == ""
256+
257+
return false
258+
end
259+
222260
-- #noGem
223261
-- Disables the gem component of the next skill
224262
directiveTable.noGem = function(state, args, out)
@@ -242,6 +280,7 @@ directiveTable.skill = function(state, args, out)
242280
grantedId = args
243281
displayName = args
244282
end
283+
state.infoGrantedId = grantedId
245284
out:write('skills["', grantedId, '"] = {\n')
246285
local granted = dat("GrantedEffects"):GetRow("Id", grantedId)
247286
if not granted then
@@ -722,12 +761,13 @@ directiveTable.set = function(state, args, out)
722761
out:write('\t\t\tdamageIncrementalEffectiveness = ', grantedEffectStatSet.DamageIncrementalEffectiveness, ',\n')
723762
end
724763
if state.granted.IsSupport then
725-
out:write('\t\t\tstatDescriptionScope = "gem_stat_descriptions",\n')
764+
state.statDescriptionScope = "gem_stat_descriptions"
726765
else
727-
out:write('\t\t\tstatDescriptionScope = "', state.granted.ActiveSkill.StatDescription:gsub("^Metadata/StatDescriptions/", ""):
766+
state.statDescriptionScope = state.granted.ActiveSkill.StatDescription:gsub("^Metadata/StatDescriptions/", ""):
728767
-- Need to subtract 1 from setIndex because GGG indexes from 0
729-
gsub("specific_skill_stat_descriptions/", ""):gsub("statset_0", "statset_"..(skill.setIndex - 1)):gsub("/$", ""):gsub("/", "_"), '",\n')
768+
gsub("specific_skill_stat_descriptions/", ""):gsub("statset_0", "statset_"..(skill.setIndex - 1)):gsub("/$", ""):gsub("/", "_"), '",\n'
730769
end
770+
out:write('\t\t\tstatDescriptionScope = "' .. state.statDescriptionScope .. '",\n')
731771
skill.setIndex = skill.setIndex + 1
732772
end
733773

@@ -829,6 +869,22 @@ directiveTable.mods = function(state, args, out)
829869
out:write('\t\t\t},\n')
830870
end
831871
out:write('\t\t},\n')
872+
873+
-- validate stats
874+
local printHeader = true
875+
for i = 1, #set.stats do
876+
if not set.levels[i] or type(set.levels[i]) ~= "number" then
877+
break
878+
end
879+
local stat = set.stats[i]
880+
if not checkModInStatDescription(state.statDescriptionScope, stat.id) then
881+
if printHeader then
882+
printHeader = false
883+
ConPrintf("====================================\nSkill %s: ", state.infoGrantedId)
884+
end
885+
ConPrintf("Stat %s not found in stat description %s", stat.id, state.statDescriptionScope)
886+
end
887+
end
832888
state.set = nil
833889
end
834890

src/Export/Scripts/statdesc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local function processStatFile(name, changeOutLocation)
1414
end
1515
local parent = line:match('include "Metadata/StatDescriptions/(.+)%.csd"$')
1616
if parent then
17-
statDescriptor.parent = parent:gsub("/statset", "_statset")
17+
statDescriptor.parent = parent:gsub("\\", "/"):gsub("/statset", "_statset")
1818
return
1919
end
2020
local noDesc = line:match("no_description ([%w_%+%-%%]+)")

src/Export/statdesc.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,15 @@ function describeStats(stats)
148148
local out = { }
149149
local orders = { }
150150
local descriptors = { }
151+
local missing = {false}
151152
for s, v in pairs(stats) do
152-
if s ~= "Type" and (v.min ~= 0 or v.max ~= 0) and statDescriptor[s] and statDescriptor[s].stats then
153-
descriptors[statDescriptor[s]] = true
153+
if s ~= "Type" and statDescriptor[s] and statDescriptor[s].stats then
154+
if (v.min ~= 0 or v.max ~= 0) then
155+
descriptors[statDescriptor[s]] = true
156+
end
157+
elseif s ~= "Type" then
158+
missing[1] = true
159+
missing[s] = v
154160
end
155161
end
156162
local descOrdered = { }
@@ -390,7 +396,7 @@ function describeStats(stats)
390396
end
391397
end
392398
end
393-
return out, orders
399+
return out, orders, missing
394400
end
395401

396402
function describeMod(mod)
@@ -403,9 +409,9 @@ function describeMod(mod)
403409
if mod.Type then
404410
stats.Type = mod.Type
405411
end
406-
local out, orders = describeStats(stats)
412+
local out, orders, missing = describeStats(stats)
407413
out.modTags = describeModTags(mod.ImplicitTags)
408-
return out, orders
414+
return out, orders, missing
409415
end
410416

411417
function describeScalability(fileName)

0 commit comments

Comments
 (0)