Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend give command "skill level" & shortening /talent all #1865

Merged
merged 15 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Small cleanup:
Removed the special case from Avatar to be handled inside of GiveCommand
  • Loading branch information
natsurepo committed Oct 18, 2022
commit ea55f48c72efe906c97dba205b21b9245fa45acd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameDepot;
import emu.grasscutter.data.excels.AvatarData;
import emu.grasscutter.data.excels.AvatarSkillDepotData;
import emu.grasscutter.data.excels.ItemData;
import emu.grasscutter.data.excels.ReliquaryAffixData;
import emu.grasscutter.data.excels.ReliquaryMainPropData;
Expand Down Expand Up @@ -221,7 +222,7 @@ private static Avatar makeAvatar(AvatarData avatarData, int level, int promoteLe
Avatar avatar = new Avatar(avatarData);
avatar.setLevel(level);
avatar.setPromoteLevel(promoteLevel);
avatar.setSkillLevel(-1 , skillLevel);
avatar.getSkillDepot().getSkillsAndEnergySkill().forEach(id -> avatar.setSkillLevel(id, skillLevel));
avatar.forceConstellationLevel(constellation);
avatar.recalcStats(true);
avatar.save();
Expand Down
27 changes: 10 additions & 17 deletions src/main/java/emu/grasscutter/game/avatar/Avatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -754,24 +754,17 @@ public boolean upgradeSkill(int skillId) {

public boolean setSkillLevel(int skillId, int level) {
if (level < 0 || level > 15) return false;
// Special case for GiveCommand
if (skillId == -1) {
skillDepot.getSkillsAndEnergySkill().forEach(id -> this.setSkillLevel(id, level));
}
else {
var validLevels = GameData.getAvatarSkillLevels(skillId);
if (validLevels != null && !validLevels.contains(level)) return false;

int oldLevel = this.skillLevelMap.getOrDefault(skillId, 0); // just taking the return value of put would have null concerns
this.skillLevelMap.put(skillId, level);
this.save();
var validLevels = GameData.getAvatarSkillLevels(skillId);
if (validLevels != null && !validLevels.contains(level)) return false;
int oldLevel = this.skillLevelMap.getOrDefault(skillId, 0); // just taking the return value of put would have null concerns
this.skillLevelMap.put(skillId, level);
this.save();

// Packet
val player = this.getPlayer();
if (player != null) {
player.sendPacket(new PacketAvatarSkillChangeNotify(this, skillId, oldLevel, level));
player.sendPacket(new PacketAvatarSkillUpgradeRsp(this, skillId, oldLevel, level));
}
// Packet
val player = this.getPlayer();
if (player != null) {
player.sendPacket(new PacketAvatarSkillChangeNotify(this, skillId, oldLevel, level));
player.sendPacket(new PacketAvatarSkillUpgradeRsp(this, skillId, oldLevel, level));
}
return true;
}
Expand Down