Commit 3baef42a authored by Yazawazi's avatar Yazawazi Committed by GitHub
Browse files

Name Card Done!!!!!!!!!!!

parent ad1c3f9a
......@@ -59,6 +59,7 @@ public class GenshinData {
private static final Int2ObjectMap<SceneData> sceneDataMap = new Int2ObjectLinkedOpenHashMap<>();
private static final Int2ObjectMap<FetterData> fetterDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<FetterCharacterCardData> fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
// Cache
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
......@@ -243,6 +244,10 @@ public class GenshinData {
return sceneDataMap;
}
public static Int2ObjectMap<RewardData> getRewardDataMap() {
return rewardDataMap;
}
public static Map<Integer, List<Integer>> getFetterDataEntries() {
if (fetters.isEmpty()) {
fetterDataMap.forEach((k, v) -> {
......
......@@ -58,6 +58,7 @@ public class AvatarData extends GenshinResource {
private List<Integer> fetters;
private int nameCardRewardId;
private int nameCardId;
@Override
public int getId(){
......@@ -204,6 +205,10 @@ public class AvatarData extends GenshinResource {
return nameCardRewardId;
}
public int getNameCardId() {
return nameCardId;
}
@Override
public void onLoad() {
this.skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.SkillDepotId);
......@@ -215,6 +220,10 @@ public class AvatarData extends GenshinResource {
this.nameCardRewardId = GenshinData.getFetterCharacterCardDataMap().get(this.Id).getRewardId();
}
if (GenshinData.getRewardDataMap().get(this.nameCardRewardId) != null) {
this.nameCardId = GenshinData.getRewardDataMap().get(this.nameCardRewardId).getRewardItemList().get(0).getItemId();
}
int size = GenshinData.getAvatarCurveDataMap().size();
this.hpGrowthCurve = new float[size];
this.attackGrowthCurve = new float[size];
......
......@@ -94,6 +94,7 @@ public class GenshinAvatar {
private int fetterExp;
private int nameCardRewardId;
private int nameCardId;
public GenshinAvatar() {
// Morhpia only!
......@@ -113,6 +114,7 @@ public class GenshinAvatar {
this();
this.avatarId = data.getId();
this.nameCardRewardId = data.getNameCardRewardId();
this.nameCardId = data.getNameCardId();
this.data = data;
this.bornTime = (int) (System.currentTimeMillis() / 1000);
this.flyCloak = 140001;
......@@ -311,6 +313,14 @@ public class GenshinAvatar {
this.fetterExp = fetterExp;
}
public int getNameCardId() {
return nameCardId;
}
public void setNameCardId(int nameCardId) {
this.nameCardId = nameCardId;
}
public float getCurrentHp() {
return currentHp;
}
......@@ -434,6 +444,7 @@ public class GenshinAvatar {
// Fetters
this.setFetterList(data.getFetters());
this.setNameCardRewardId(data.getNameCardRewardId());
this.setNameCardId(data.getNameCardId());
// Get hp percent, set to 100% if none
float hpPercent = this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 ? 1f : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
......@@ -746,6 +757,13 @@ public class GenshinAvatar {
}
}
int rewardId = this.getNameCardRewardId();
int cardId = this.getNameCardId();
if (this.getPlayer().getNameCardList().contains(cardId)) {
avatarFetter.addRewardedFetterLevelList(rewardId);
}
AvatarInfo.Builder avatarInfo = AvatarInfo.newBuilder()
.setAvatarId(this.getAvatarId())
.setGuid(this.getGuid())
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.def.RewardData;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.props.ActionReason;
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.PacketAvatarFetterDataNotify;
import emu.grasscutter.server.packet.send.PacketAvatarFetterLevelRewardRsp;
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
import emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify;
......@@ -25,18 +26,19 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
} else {
long avatarGuid = req.getAvatarGuid();
int rewardId = session
GenshinAvatar avatar = session
.getPlayer()
.getAvatars()
.getAvatarByGuid(avatarGuid)
.getNameCardRewardId();
.getAvatarByGuid(avatarGuid);
int rewardId = avatar.getNameCardRewardId();
RewardData card = GenshinData.getRewardDataMap().get(rewardId);
int cardId = card.getRewardItemList().get(0).getItemId();
if (session.getPlayer().getNameCardList().contains(cardId)) {
// Already got divorce certificate.
session.getPlayer().sendPacket(new PacketAvatarFetterLevelRewardRsp(req.getAvatarGuid(), req.getFetterLevel()));
session.getPlayer().sendPacket(new PacketAvatarFetterLevelRewardRsp(req.getAvatarGuid(), req.getFetterLevel(), rewardId));
return;
}
......@@ -45,6 +47,7 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
session.getPlayer().sendPacket(new PacketItemAddHintNotify(item, ActionReason.FetterLevelReward));
session.getPlayer().sendPacket(new PacketUnlockNameCardNotify(cardId));
session.send(new PacketAvatarFetterLevelRewardRsp(avatarGuid, req.getFetterLevel(), rewardId));
session.send(new PacketAvatarFetterDataNotify(avatar));
}
}
}
......@@ -27,6 +27,13 @@ public class PacketAvatarFetterDataNotify extends GenshinPacket {
}
}
int rewardId = avatar.getNameCardRewardId();
int cardId = avatar.getNameCardId();
if (avatar.getPlayer().getNameCardList().contains(cardId)) {
avatarFetter.addRewardedFetterLevelList(rewardId);
}
AvatarFetterInfo avatarFetterInfo = avatarFetter.build();
AvatarFetterDataNotify proto = AvatarFetterDataNotify.newBuilder()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment