mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 12:05:39 +00:00
Properly level up characters with the character exp virtual item
This commit is contained in:
parent
ab343aebd4
commit
61e4491ed1
@ -15,6 +15,7 @@ import emu.grasscutter.database.DatabaseHelper;
|
|||||||
import emu.grasscutter.game.GenshinPlayer;
|
import emu.grasscutter.game.GenshinPlayer;
|
||||||
import emu.grasscutter.game.avatar.AvatarStorage;
|
import emu.grasscutter.game.avatar.AvatarStorage;
|
||||||
import emu.grasscutter.game.avatar.GenshinAvatar;
|
import emu.grasscutter.game.avatar.GenshinAvatar;
|
||||||
|
import emu.grasscutter.game.entity.EntityAvatar;
|
||||||
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarEquipChangeNotify;
|
import emu.grasscutter.server.packet.send.PacketAvatarEquipChangeNotify;
|
||||||
import emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify;
|
import emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify;
|
||||||
@ -187,6 +188,8 @@ public class Inventory implements Iterable<GenshinItem> {
|
|||||||
existingItem.save();
|
existingItem.save();
|
||||||
return existingItem;
|
return existingItem;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set ownership and save to db
|
// Set ownership and save to db
|
||||||
@ -207,6 +210,11 @@ public class Inventory implements Iterable<GenshinItem> {
|
|||||||
|
|
||||||
private void addVirtualItem(int itemId, int count) {
|
private void addVirtualItem(int itemId, int count) {
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
|
case 101: // Character exp
|
||||||
|
for (EntityAvatar entity : getPlayer().getTeamManager().getActiveTeam()) {
|
||||||
|
getPlayer().getServer().getInventoryManager().upgradeAvatar(player, entity.getAvatar(), count);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 102: // Adventure exp
|
case 102: // Adventure exp
|
||||||
getPlayer().addExpDirectly(count);
|
getPlayer().addExpDirectly(count);
|
||||||
break;
|
break;
|
||||||
|
@ -660,6 +660,19 @@ public class InventoryManager {
|
|||||||
player.getInventory().removeItem(feedItem, count);
|
player.getInventory().removeItem(feedItem, count);
|
||||||
|
|
||||||
// Level up
|
// Level up
|
||||||
|
upgradeAvatar(player, avatar, promoteData, expGain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void upgradeAvatar(GenshinPlayer player, GenshinAvatar avatar, int expGain) {
|
||||||
|
AvatarPromoteData promoteData = GenshinData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel());
|
||||||
|
if (promoteData == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
upgradeAvatar(player, avatar, promoteData, expGain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void upgradeAvatar(GenshinPlayer player, GenshinAvatar avatar, AvatarPromoteData promoteData, int expGain) {
|
||||||
int maxLevel = promoteData.getUnlockMaxLevel();
|
int maxLevel = promoteData.getUnlockMaxLevel();
|
||||||
int level = avatar.getLevel();
|
int level = avatar.getLevel();
|
||||||
int oldLevel = level;
|
int oldLevel = level;
|
||||||
|
Loading…
Reference in New Issue
Block a user