Refactor avatar skilldepot and constellation/talent changing

Ensures Traveler retains talent levels and constellations on inactive elements when switching elements.
Relevant for any other skillDepot-changing activities like Windtrace too, though keeping those in the db might not be as useful.

Refactor avatar talent upgrade and access
Refactor skillExtraCharges
This commit is contained in:
AnimeGitB
2022-08-17 19:48:41 +09:30
Unverified
parent 78b7fb70ac
commit fb1bacb0f8
14 changed files with 399 additions and 476 deletions
@@ -15,7 +15,6 @@ import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import java.util.List;
import java.util.Set;
@Command(
label = "setConst",
@@ -33,7 +32,7 @@ public final class SetConstCommand implements CommandHandler {
try {
int constLevel = Integer.parseInt(args.get(0));
if (constLevel < 0 || constLevel > 6) {
if (constLevel < -1 || constLevel > 6) {
CommandHandler.sendTranslatedMessage(sender, "commands.setConst.range_error");
return;
}
@@ -52,19 +51,7 @@ public final class SetConstCommand implements CommandHandler {
private void setConstellation(Player player, Avatar avatar, int constLevel) {
int currentConstLevel = avatar.getCoreProudSkillLevel();
IntArrayList talentIds = new IntArrayList(avatar.getSkillDepot().getTalents());
Set<Integer> talentIdList = avatar.getTalentIdList();
talentIdList.clear();
avatar.setCoreProudSkillLevel(0);
for(int talent = 0; talent < constLevel; talent++) {
AvatarTalentData talentData = GameData.getAvatarTalentDataMap().get(talentIds.getInt(talent));
int mainCostItemId = talentData.getMainCostItemId();
player.getInventory().addItem(mainCostItemId);
Grasscutter.getGameServer().getInventorySystem().unlockAvatarConstellation(player, avatar.getGuid());
}
avatar.forceConstellationLevel(constLevel);
// force player to reload scene when necessary
if (constLevel < currentConstLevel) {