Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
3bc249f0
Commit
3bc249f0
authored
Apr 23, 2022
by
Yazawazi
Committed by
GitHub
Apr 23, 2022
Browse files
Try to give name card
parent
042bdc2f
Changes
4
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/common/RewardItemData.java
0 → 100644
View file @
3bc249f0
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
;
}
}
src/main/java/emu/grasscutter/data/def/RewardData.java
0 → 100644
View file @
3bc249f0
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
()
{
}
}
src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java
View file @
3bc249f0
...
@@ -433,6 +433,7 @@ public class GenshinAvatar {
...
@@ -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
?
1
f
:
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
/
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
float
hpPercent
=
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
<=
0
?
1
f
:
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
/
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java
View file @
3bc249f0
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
)
...
@@ -24,8 +31,18 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
...
@@ -24,8 +31,18 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
.
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
));
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment