mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 13:32:52 +08:00
Try to give name card
This commit is contained in:
parent
042bdc2ff2
commit
3bc249f042
@ -0,0 +1,22 @@
|
|||||||
|
package emu.grasscutter.data.common;
|
||||||
|
|
||||||
|
public class RewardItemData {
|
||||||
|
private int ItemId;
|
||||||
|
private int ItemCount;
|
||||||
|
|
||||||
|
public int getItemId() {
|
||||||
|
return ItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(int itemId) {
|
||||||
|
ItemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemCount() {
|
||||||
|
return ItemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemCount(int itemCount) {
|
||||||
|
ItemCount = itemCount;
|
||||||
|
}
|
||||||
|
}
|
27
src/main/java/emu/grasscutter/data/def/RewardData.java
Normal file
27
src/main/java/emu/grasscutter/data/def/RewardData.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package emu.grasscutter.data.def;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import emu.grasscutter.data.GenshinResource;
|
||||||
|
import emu.grasscutter.data.ResourceType;
|
||||||
|
import emu.grasscutter.data.common.RewardItemData;
|
||||||
|
|
||||||
|
@ResourceType(name = "RewardExcelConfigData.json")
|
||||||
|
public class RewardData extends GenshinResource {
|
||||||
|
public int RewardId;
|
||||||
|
public List<RewardItemData> RewardItemList;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return RewardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RewardItemData> getRewardItemList() {
|
||||||
|
return RewardItemList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -433,6 +433,7 @@ public class GenshinAvatar {
|
|||||||
|
|
||||||
// Fetters
|
// Fetters
|
||||||
this.setFetterList(data.getFetters());
|
this.setFetterList(data.getFetters());
|
||||||
|
this.setNameCardRewardId(data.getNameCardRewardId());
|
||||||
|
|
||||||
// Get hp percent, set to 100% if none
|
// 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);
|
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);
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package emu.grasscutter.server.packet.recv;
|
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.inventory.GenshinItem;
|
||||||
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
import emu.grasscutter.net.packet.Opcodes;
|
import emu.grasscutter.net.packet.Opcodes;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.AvatarFetterLevelRewardReqOuterClass.AvatarFetterLevelRewardReq;
|
import emu.grasscutter.net.proto.AvatarFetterLevelRewardReqOuterClass.AvatarFetterLevelRewardReq;
|
||||||
import emu.grasscutter.server.game.GameSession;
|
import emu.grasscutter.server.game.GameSession;
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarFetterLevelRewardRsp;
|
import emu.grasscutter.server.packet.send.PacketAvatarFetterLevelRewardRsp;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify;
|
||||||
import emu.grasscutter.net.packet.PacketHandler;
|
import emu.grasscutter.net.packet.PacketHandler;
|
||||||
|
|
||||||
@Opcodes(PacketOpcodes.AvatarFetterLevelRewardReq)
|
@Opcodes(PacketOpcodes.AvatarFetterLevelRewardReq)
|
||||||
@ -23,9 +30,19 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
|
|||||||
.getAvatars()
|
.getAvatars()
|
||||||
.getAvatarByGuid(avatarGuid)
|
.getAvatarByGuid(avatarGuid)
|
||||||
.getNameCardRewardId();
|
.getNameCardRewardId();
|
||||||
|
|
||||||
// Here need to send the packets, I am not at all clear ah!
|
|
||||||
|
|
||||||
|
RewardData card = GenshinData.getRewardDataMap().get(rewardId);
|
||||||
|
int cardId = card.getRewardItemList().get(0).getItemId();
|
||||||
|
|
||||||
|
if (session.getPlayer().getNameCardList().contains(cardId)) {
|
||||||
|
// Already got divorce certificate.
|
||||||
|
session.send(new PacketAvatarFetterLevelRewardRsp(req.getAvatarGuid(), req.getFetterLevel()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GenshinItem item = new GenshinItem(cardId);
|
||||||
|
session.getPlayer().sendPacket(new PacketItemAddHintNotify(item, ActionReason.FetterLevelReward));
|
||||||
|
session.send(new PacketUnlockNameCardNotify(cardId));
|
||||||
session.send(new PacketAvatarFetterLevelRewardRsp(avatarGuid, req.getFetterLevel(), rewardId));
|
session.send(new PacketAvatarFetterLevelRewardRsp(avatarGuid, req.getFetterLevel(), rewardId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user