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
3baef42a
Commit
3baef42a
authored
Apr 23, 2022
by
Yazawazi
Committed by
GitHub
Apr 23, 2022
Browse files
Name Card Done!!!!!!!!!!!
parent
ad1c3f9a
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/GenshinData.java
View file @
3baef42a
...
@@ -59,6 +59,7 @@ public class GenshinData {
...
@@ -59,6 +59,7 @@ public class GenshinData {
private
static
final
Int2ObjectMap
<
SceneData
>
sceneDataMap
=
new
Int2ObjectLinkedOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
SceneData
>
sceneDataMap
=
new
Int2ObjectLinkedOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterData
>
fetterDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterData
>
fetterDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterCharacterCardData
>
fetterCharacterCardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterCharacterCardData
>
fetterCharacterCardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardData
>
rewardDataMap
=
new
Int2ObjectOpenHashMap
<>();
// Cache
// Cache
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
...
@@ -243,6 +244,10 @@ public class GenshinData {
...
@@ -243,6 +244,10 @@ public class GenshinData {
return
sceneDataMap
;
return
sceneDataMap
;
}
}
public
static
Int2ObjectMap
<
RewardData
>
getRewardDataMap
()
{
return
rewardDataMap
;
}
public
static
Map
<
Integer
,
List
<
Integer
>>
getFetterDataEntries
()
{
public
static
Map
<
Integer
,
List
<
Integer
>>
getFetterDataEntries
()
{
if
(
fetters
.
isEmpty
())
{
if
(
fetters
.
isEmpty
())
{
fetterDataMap
.
forEach
((
k
,
v
)
->
{
fetterDataMap
.
forEach
((
k
,
v
)
->
{
...
...
src/main/java/emu/grasscutter/data/def/AvatarData.java
View file @
3baef42a
...
@@ -58,6 +58,7 @@ public class AvatarData extends GenshinResource {
...
@@ -58,6 +58,7 @@ public class AvatarData extends GenshinResource {
private
List
<
Integer
>
fetters
;
private
List
<
Integer
>
fetters
;
private
int
nameCardRewardId
;
private
int
nameCardRewardId
;
private
int
nameCardId
;
@Override
@Override
public
int
getId
(){
public
int
getId
(){
...
@@ -204,6 +205,10 @@ public class AvatarData extends GenshinResource {
...
@@ -204,6 +205,10 @@ public class AvatarData extends GenshinResource {
return
nameCardRewardId
;
return
nameCardRewardId
;
}
}
public
int
getNameCardId
()
{
return
nameCardId
;
}
@Override
@Override
public
void
onLoad
()
{
public
void
onLoad
()
{
this
.
skillDepot
=
GenshinData
.
getAvatarSkillDepotDataMap
().
get
(
this
.
SkillDepotId
);
this
.
skillDepot
=
GenshinData
.
getAvatarSkillDepotDataMap
().
get
(
this
.
SkillDepotId
);
...
@@ -214,6 +219,10 @@ public class AvatarData extends GenshinResource {
...
@@ -214,6 +219,10 @@ public class AvatarData extends GenshinResource {
if
(
GenshinData
.
getFetterCharacterCardDataMap
().
get
(
this
.
Id
)
!=
null
)
{
if
(
GenshinData
.
getFetterCharacterCardDataMap
().
get
(
this
.
Id
)
!=
null
)
{
this
.
nameCardRewardId
=
GenshinData
.
getFetterCharacterCardDataMap
().
get
(
this
.
Id
).
getRewardId
();
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
();
int
size
=
GenshinData
.
getAvatarCurveDataMap
().
size
();
this
.
hpGrowthCurve
=
new
float
[
size
];
this
.
hpGrowthCurve
=
new
float
[
size
];
...
...
src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java
View file @
3baef42a
...
@@ -94,6 +94,7 @@ public class GenshinAvatar {
...
@@ -94,6 +94,7 @@ public class GenshinAvatar {
private
int
fetterExp
;
private
int
fetterExp
;
private
int
nameCardRewardId
;
private
int
nameCardRewardId
;
private
int
nameCardId
;
public
GenshinAvatar
()
{
public
GenshinAvatar
()
{
// Morhpia only!
// Morhpia only!
...
@@ -113,6 +114,7 @@ public class GenshinAvatar {
...
@@ -113,6 +114,7 @@ public class GenshinAvatar {
this
();
this
();
this
.
avatarId
=
data
.
getId
();
this
.
avatarId
=
data
.
getId
();
this
.
nameCardRewardId
=
data
.
getNameCardRewardId
();
this
.
nameCardRewardId
=
data
.
getNameCardRewardId
();
this
.
nameCardId
=
data
.
getNameCardId
();
this
.
data
=
data
;
this
.
data
=
data
;
this
.
bornTime
=
(
int
)
(
System
.
currentTimeMillis
()
/
1000
);
this
.
bornTime
=
(
int
)
(
System
.
currentTimeMillis
()
/
1000
);
this
.
flyCloak
=
140001
;
this
.
flyCloak
=
140001
;
...
@@ -311,6 +313,14 @@ public class GenshinAvatar {
...
@@ -311,6 +313,14 @@ public class GenshinAvatar {
this
.
fetterExp
=
fetterExp
;
this
.
fetterExp
=
fetterExp
;
}
}
public
int
getNameCardId
()
{
return
nameCardId
;
}
public
void
setNameCardId
(
int
nameCardId
)
{
this
.
nameCardId
=
nameCardId
;
}
public
float
getCurrentHp
()
{
public
float
getCurrentHp
()
{
return
currentHp
;
return
currentHp
;
}
}
...
@@ -434,6 +444,7 @@ public class GenshinAvatar {
...
@@ -434,6 +444,7 @@ public class GenshinAvatar {
// Fetters
// Fetters
this
.
setFetterList
(
data
.
getFetters
());
this
.
setFetterList
(
data
.
getFetters
());
this
.
setNameCardRewardId
(
data
.
getNameCardRewardId
());
this
.
setNameCardRewardId
(
data
.
getNameCardRewardId
());
this
.
setNameCardId
(
data
.
getNameCardId
());
// 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
);
...
@@ -746,6 +757,13 @@ public class GenshinAvatar {
...
@@ -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
()
AvatarInfo
.
Builder
avatarInfo
=
AvatarInfo
.
newBuilder
()
.
setAvatarId
(
this
.
getAvatarId
())
.
setAvatarId
(
this
.
getAvatarId
())
.
setGuid
(
this
.
getGuid
())
.
setGuid
(
this
.
getGuid
())
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java
View file @
3baef42a
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.GenshinData
;
import
emu.grasscutter.data.def.RewardData
;
import
emu.grasscutter.data.def.RewardData
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.props.ActionReason
;
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.PacketAvatarFetterDataNotify
;
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.PacketItemAddHintNotify
;
import
emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify
;
import
emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify
;
...
@@ -25,18 +26,19 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
...
@@ -25,18 +26,19 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
}
else
{
}
else
{
long
avatarGuid
=
req
.
getAvatarGuid
();
long
avatarGuid
=
req
.
getAvatarGuid
();
int
rewardId
=
session
GenshinAvatar
avatar
=
session
.
getPlayer
()
.
getPlayer
()
.
getAvatars
()
.
getAvatars
()
.
getAvatarByGuid
(
avatarGuid
)
.
getAvatarByGuid
(
avatarGuid
);
.
getNameCardRewardId
();
int
rewardId
=
avatar
.
getNameCardRewardId
();
RewardData
card
=
GenshinData
.
getRewardDataMap
().
get
(
rewardId
);
RewardData
card
=
GenshinData
.
getRewardDataMap
().
get
(
rewardId
);
int
cardId
=
card
.
getRewardItemList
().
get
(
0
).
getItemId
();
int
cardId
=
card
.
getRewardItemList
().
get
(
0
).
getItemId
();
if
(
session
.
getPlayer
().
getNameCardList
().
contains
(
cardId
))
{
if
(
session
.
getPlayer
().
getNameCardList
().
contains
(
cardId
))
{
// Already got divorce certificate.
// Already got divorce certificate.
session
.
getPlayer
().
sendPacket
(
new
PacketAvatarFetterLevelRewardRsp
(
req
.
getAvatarGuid
(),
req
.
getFetterLevel
()));
session
.
getPlayer
().
sendPacket
(
new
PacketAvatarFetterLevelRewardRsp
(
req
.
getAvatarGuid
(),
req
.
getFetterLevel
()
,
rewardId
));
return
;
return
;
}
}
...
@@ -45,6 +47,7 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
...
@@ -45,6 +47,7 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
session
.
getPlayer
().
sendPacket
(
new
PacketItemAddHintNotify
(
item
,
ActionReason
.
FetterLevelReward
));
session
.
getPlayer
().
sendPacket
(
new
PacketItemAddHintNotify
(
item
,
ActionReason
.
FetterLevelReward
));
session
.
getPlayer
().
sendPacket
(
new
PacketUnlockNameCardNotify
(
cardId
));
session
.
getPlayer
().
sendPacket
(
new
PacketUnlockNameCardNotify
(
cardId
));
session
.
send
(
new
PacketAvatarFetterLevelRewardRsp
(
avatarGuid
,
req
.
getFetterLevel
(),
rewardId
));
session
.
send
(
new
PacketAvatarFetterLevelRewardRsp
(
avatarGuid
,
req
.
getFetterLevel
(),
rewardId
));
session
.
send
(
new
PacketAvatarFetterDataNotify
(
avatar
));
}
}
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java
View file @
3baef42a
...
@@ -26,6 +26,13 @@ public class PacketAvatarFetterDataNotify extends GenshinPacket {
...
@@ -26,6 +26,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
();
AvatarFetterInfo
avatarFetterInfo
=
avatarFetter
.
build
();
...
...
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