Modifications in managers to make class based skill tree work.

This commit is contained in:
Ka0rX 2022-10-16 21:50:20 +02:00
parent bde947a877
commit 706413e8e8
2 changed files with 19 additions and 2 deletions

View File

@ -231,6 +231,9 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
classinfo.addProperty("skill-points", info.getSkillPoints());
classinfo.addProperty("attribute-points", info.getAttributePoints());
classinfo.addProperty("attribute-realloc-points", info.getAttributeReallocationPoints());
classinfo.addProperty("skill-reallocation-points",info.getSkillReallocationPoints());
classinfo.addProperty("skill-tree-reallocation-points",info.getSkillTreeReallocationPoints());
JsonObject skillinfo = new JsonObject();
for (String skill : info.getSkillKeys())
skillinfo.addProperty(skill, info.getSkillLevel(skill));
@ -240,6 +243,16 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
attributeinfo.addProperty(attribute, info.getAttributeLevel(attribute));
classinfo.add("attribute", attributeinfo);
JsonObject nodeLevelsInfo = new JsonObject();
for (SkillTreeNode node : info.getNodeKeys())
attributeinfo.addProperty(node.getFullId(), info.getNodeLevel(node));
classinfo.add("node-levels", nodeLevelsInfo);
JsonObject skillTreePointsInfo = new JsonObject();
for (String skillTreeId : info.getSkillTreePointsKeys())
attributeinfo.addProperty(skillTreeId, info.getSkillTreePoints(skillTreeId));
classinfo.add("skill-tree-points", skillTreePointsInfo);
json.add(c, classinfo);
}

View File

@ -175,11 +175,15 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
config.set("class-info." + key + ".skill-points", info.getSkillPoints());
config.set("class-info." + key + ".attribute-points", info.getAttributePoints());
config.set("class-info." + key + ".attribute-realloc-points", info.getAttributeReallocationPoints());
config.set("class-info." + key + ".skill-tree-reallocation-points", info.getSkillTreeReallocationPoints());
config.set("class-info." + key + ".skill-reallocation-points", info.getSkillReallocationPoints());
info.getSkillKeys().forEach(skill -> config.set("class-info." + key + ".skill." + skill, info.getSkillLevel(skill)));
info.getAttributeKeys()
.forEach(attribute -> config.set("class-info." + key + ".attribute." + attribute, info.getAttributeLevel(attribute)));
info.getAttributeKeys().forEach(attribute -> config.set("class-info." + key + ".attribute." + attribute, info.getAttributeLevel(attribute)));
info.getNodeKeys().forEach(node -> config.set("class-info." + key + ".node-levels." + node.getFullId(), info.getNodeLevel(node)));
info.getSkillTreePointsKeys().forEach(skillTreeId -> config.set("class-info." + key + ".skill-tree-points." + skillTreeId, info.getAttributeLevel(skillTreeId)));
}
file.save();
}