diff --git a/src/main/java/emu/grasscutter/data/GenshinData.java b/src/main/java/emu/grasscutter/data/GenshinData.java index 155ebb60c..98f235c1e 100644 --- a/src/main/java/emu/grasscutter/data/GenshinData.java +++ b/src/main/java/emu/grasscutter/data/GenshinData.java @@ -58,6 +58,7 @@ public class GenshinData { private static final Int2ObjectMap sceneDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap fetterDataMap = new Int2ObjectOpenHashMap<>(); + private static final Int2ObjectMap fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>(); // Cache private static Map> fetters = new HashMap<>(); @@ -119,6 +120,10 @@ public class GenshinData { return avatarFetterLevelDataMap; } + public static Int2ObjectMap getFetterCharacterCardDataMap() { + return fetterCharacterCardDataMap; + } + public static Int2ObjectMap getAvatarLevelDataMap() { return avatarLevelDataMap; } diff --git a/src/main/java/emu/grasscutter/data/def/AvatarData.java b/src/main/java/emu/grasscutter/data/def/AvatarData.java index 8097e04a7..a714344ae 100644 --- a/src/main/java/emu/grasscutter/data/def/AvatarData.java +++ b/src/main/java/emu/grasscutter/data/def/AvatarData.java @@ -57,6 +57,7 @@ public class AvatarData extends GenshinResource { private IntList abilities; private List fetters; + private int nameCardRewardId; @Override public int getId(){ @@ -199,12 +200,20 @@ public class AvatarData extends GenshinResource { return fetters; } + public int getNameCardRewardId() { + return nameCardRewardId; + } + @Override public void onLoad() { this.skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.SkillDepotId); // Get fetters from GenshinData this.fetters = GenshinData.getFetterDataEntries().get(this.Id); + + if (GenshinData.getFetterCharacterCardDataMap().get(this.Id) != null) { + this.nameCardRewardId = GenshinData.getFetterCharacterCardDataMap().get(this.Id).getRewardId(); + } int size = GenshinData.getAvatarCurveDataMap().size(); this.hpGrowthCurve = new float[size]; diff --git a/src/main/java/emu/grasscutter/data/def/FetterCharacterCardData.java b/src/main/java/emu/grasscutter/data/def/FetterCharacterCardData.java new file mode 100644 index 000000000..2bf96ad8e --- /dev/null +++ b/src/main/java/emu/grasscutter/data/def/FetterCharacterCardData.java @@ -0,0 +1,24 @@ +package emu.grasscutter.data.def; + +import emu.grasscutter.data.GenshinResource; +import emu.grasscutter.data.ResourceType; +import emu.grasscutter.data.ResourceType.LoadPriority; + +@ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) +public class FetterCharacterCardData extends GenshinResource { + private int AvatarId; + private int RewardId; + + @Override + public int getId() { + return AvatarId; + } + + public int getRewardId() { + return RewardId; + } + + @Override + public void onLoad() { + } +} diff --git a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java index d4e998d46..5ad553f9c 100644 --- a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java @@ -92,6 +92,8 @@ public class GenshinAvatar { private int fetterLevel = 1; private int fetterExp; + + private int nameCardRewardId; public GenshinAvatar() { // Morhpia only! @@ -110,6 +112,7 @@ public class GenshinAvatar { public GenshinAvatar(AvatarData data) { this(); this.avatarId = data.getId(); + this.nameCardRewardId = data.getNameCardRewardId(); this.data = data; this.bornTime = (int) (System.currentTimeMillis() / 1000); this.flyCloak = 140001; @@ -172,6 +175,14 @@ public class GenshinAvatar { this.satiation = satiation; } + public int getNameCardRewardId() { + return nameCardRewardId; + } + + public void setNameCardRewardId(int nameCardRewardId) { + this.nameCardRewardId = nameCardRewardId; + } + public int getSatiationPenalty() { return satiationPenalty; } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java new file mode 100644 index 000000000..d3431d535 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java @@ -0,0 +1,32 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.AvatarFetterLevelRewardReqOuterClass.AvatarFetterLevelRewardReq; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketAvatarFetterLevelRewardRsp; +import emu.grasscutter.net.packet.PacketHandler; + +@Opcodes(PacketOpcodes.AvatarFetterLevelRewardReq) +public class HandlerAvatarFetterLevelRewardReq extends PacketHandler { + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + AvatarFetterLevelRewardReq req = AvatarFetterLevelRewardReq.parseFrom(payload); + if (req.getFetterLevel() < 10) { + // You don't have a full level of fetter level, why do you want to get a divorce certificate? + session.send(new PacketAvatarFetterLevelRewardRsp(req.getAvatarGuid(), req.getFetterLevel())); + } else { + long avatarGuid = req.getAvatarGuid(); + + int rewardId = session + .getPlayer() + .getAvatars() + .getAvatarByGuid(avatarGuid) + .getNameCardRewardId(); + + // Here need to send the packets, I am not at all clear ah! + + session.send(new PacketAvatarFetterLevelRewardRsp(avatarGuid, req.getFetterLevel(), rewardId)); + } + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterLevelRewardRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterLevelRewardRsp.java new file mode 100644 index 000000000..e9d4895ff --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterLevelRewardRsp.java @@ -0,0 +1,35 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.AvatarFetterLevelRewardRspOuterClass.AvatarFetterLevelRewardRsp; + +public class PacketAvatarFetterLevelRewardRsp extends GenshinPacket { + + public PacketAvatarFetterLevelRewardRsp(long guid, int fetterLevel, int rewardId) { + super(PacketOpcodes.AvatarFetterLevelRewardRsp); + + AvatarFetterLevelRewardRsp proto = AvatarFetterLevelRewardRsp.newBuilder() + .setAvatarGuid(guid) + .setFetterLevel(fetterLevel) + .setRetcode(0) + .setRewardId(rewardId) + .build(); + + this.setData(proto); + } + + public PacketAvatarFetterLevelRewardRsp(long guid, int fetterLevel) { + super(PacketOpcodes.AvatarFetterLevelRewardRsp); + + AvatarFetterLevelRewardRsp proto = AvatarFetterLevelRewardRsp.newBuilder() + .setAvatarGuid(guid) + .setFetterLevel(fetterLevel) + .setRetcode(1) + .setRewardId(0) + .build(); + + this.setData(proto); + } + +}