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
749ef3ff
Commit
749ef3ff
authored
May 14, 2022
by
ShigemoriHakura
Committed by
GitHub
May 13, 2022
Browse files
Add support for codexQuests (#870)
parent
ab6aa961
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/GameData.java
View file @
749ef3ff
...
@@ -9,7 +9,6 @@ import java.util.Map;
...
@@ -9,7 +9,6 @@ import java.util.Map;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.data.custom.AbilityEmbryoEntry
;
import
emu.grasscutter.data.custom.AbilityEmbryoEntry
;
import
emu.grasscutter.data.custom.AbilityModifier
;
import
emu.grasscutter.data.custom.AbilityModifierEntry
;
import
emu.grasscutter.data.custom.AbilityModifierEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.MainQuestData
;
import
emu.grasscutter.data.custom.MainQuestData
;
...
@@ -65,6 +64,8 @@ public class GameData {
...
@@ -65,6 +64,8 @@ public class GameData {
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
<
CodexQuest
>
codexQuestMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
CodexQuest
>
codexQuestIdMap
=
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
<>();
private
static
final
Int2ObjectMap
<
RewardData
>
rewardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
...
@@ -293,6 +294,10 @@ public class GameData {
...
@@ -293,6 +294,10 @@ public class GameData {
return
fetters
;
return
fetters
;
}
}
public
static
Int2ObjectMap
<
CodexQuest
>
getCodexQuestMap
(){
return
codexQuestMap
;}
public
static
Int2ObjectMap
<
CodexQuest
>
getCodexQuestIdMap
(){
return
codexQuestIdMap
;}
public
static
Int2ObjectMap
<
WorldLevelData
>
getWorldLevelDataMap
()
{
public
static
Int2ObjectMap
<
WorldLevelData
>
getWorldLevelDataMap
()
{
return
worldLevelDataMap
;
return
worldLevelDataMap
;
}
}
...
...
src/main/java/emu/grasscutter/data/def/CodexQuest.java
0 → 100644
View file @
749ef3ff
package
emu.grasscutter.data.def
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
@ResourceType
(
name
=
{
"QuestCodexExcelConfigData.json"
},
loadPriority
=
ResourceType
.
LoadPriority
.
HIGH
)
public
class
CodexQuest
extends
GameResource
{
private
int
Id
;
private
int
ParentQuestId
;
private
int
ChapterId
;
private
int
SortOrder
;
private
boolean
IsDisuse
;
public
int
getParentQuestId
()
{
return
ParentQuestId
;
}
public
int
getId
()
{
return
Id
;
}
public
int
getChapterId
()
{
return
ChapterId
;
}
public
int
getSortOrder
()
{
return
SortOrder
;
}
public
boolean
getIsDisuse
()
{
return
IsDisuse
;
}
@Override
public
void
onLoad
()
{
if
(!
this
.
getIsDisuse
())
{
GameData
.
getCodexQuestIdMap
().
put
(
this
.
getParentQuestId
(),
this
);
}
}
}
src/main/java/emu/grasscutter/game/player/Player.java
View file @
749ef3ff
...
@@ -1212,6 +1212,7 @@ public class Player {
...
@@ -1212,6 +1212,7 @@ public class Player {
session
.
send
(
new
PacketAvatarDataNotify
(
this
));
session
.
send
(
new
PacketAvatarDataNotify
(
this
));
session
.
send
(
new
PacketFinishedParentQuestNotify
(
this
));
session
.
send
(
new
PacketFinishedParentQuestNotify
(
this
));
session
.
send
(
new
PacketQuestListNotify
(
this
));
session
.
send
(
new
PacketQuestListNotify
(
this
));
session
.
send
(
new
PacketCodexDataFullNotify
(
this
));
session
.
send
(
new
PacketServerCondMeetQuestListUpdateNotify
(
this
));
session
.
send
(
new
PacketServerCondMeetQuestListUpdateNotify
(
this
));
session
.
send
(
new
PacketAllWidgetDataNotify
(
this
));
session
.
send
(
new
PacketAllWidgetDataNotify
(
this
));
session
.
send
(
new
PacketWidgetGadgetAllDataNotify
());
session
.
send
(
new
PacketWidgetGadgetAllDataNotify
());
...
...
src/main/java/emu/grasscutter/game/quest/GameMainQuest.java
View file @
749ef3ff
...
@@ -3,6 +3,7 @@ package emu.grasscutter.game.quest;
...
@@ -3,6 +3,7 @@ package emu.grasscutter.game.quest;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
emu.grasscutter.server.packet.send.PacketCodexDataUpdateNotify
;
import
org.bson.types.ObjectId
;
import
org.bson.types.ObjectId
;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Entity
;
...
@@ -91,6 +92,7 @@ public class GameMainQuest {
...
@@ -91,6 +92,7 @@ public class GameMainQuest {
this
.
isFinished
=
true
;
this
.
isFinished
=
true
;
this
.
state
=
ParentQuestState
.
PARENT_QUEST_STATE_FINISHED
;
this
.
state
=
ParentQuestState
.
PARENT_QUEST_STATE_FINISHED
;
this
.
getOwner
().
getSession
().
send
(
new
PacketFinishedParentQuestUpdateNotify
(
this
));
this
.
getOwner
().
getSession
().
send
(
new
PacketFinishedParentQuestUpdateNotify
(
this
));
this
.
getOwner
().
getSession
().
send
(
new
PacketCodexDataUpdateNotify
(
this
));
this
.
save
();
this
.
save
();
}
}
...
...
src/main/java/emu/grasscutter/game/quest/GameQuest.java
View file @
749ef3ff
...
@@ -11,6 +11,7 @@ import emu.grasscutter.game.player.Player;
...
@@ -11,6 +11,7 @@ import emu.grasscutter.game.player.Player;
import
emu.grasscutter.game.quest.enums.LogicType
;
import
emu.grasscutter.game.quest.enums.LogicType
;
import
emu.grasscutter.game.quest.enums.QuestState
;
import
emu.grasscutter.game.quest.enums.QuestState
;
import
emu.grasscutter.net.proto.QuestOuterClass.Quest
;
import
emu.grasscutter.net.proto.QuestOuterClass.Quest
;
import
emu.grasscutter.server.packet.send.PacketCodexDataUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketQuestListUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketQuestListUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketQuestProgressUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketQuestProgressUpdateNotify
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
...
...
src/main/java/emu/grasscutter/game/quest/QuestManager.java
View file @
749ef3ff
...
@@ -66,6 +66,12 @@ public class QuestManager {
...
@@ -66,6 +66,12 @@ public class QuestManager {
}
}
}
}
}
}
public
void
forEachMainQuest
(
Consumer
<
GameMainQuest
>
callback
)
{
for
(
GameMainQuest
mainQuest
:
getQuests
().
values
())
{
callback
.
accept
(
mainQuest
);
}
}
// TODO
// TODO
public
void
forEachActiveQuest
(
Consumer
<
GameQuest
>
callback
)
{
public
void
forEachActiveQuest
(
Consumer
<
GameQuest
>
callback
)
{
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java
0 → 100644
View file @
749ef3ff
package
emu.grasscutter.server.packet.send
;
import
java.util.Collections
;
import
java.util.List
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.CodexDataFullNotifyOuterClass.CodexDataFullNotify
;
import
emu.grasscutter.net.proto.CodexTypeDataOuterClass.CodexTypeData
;
import
emu.grasscutter.net.proto.CodexTypeOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
public
class
PacketCodexDataFullNotify
extends
BasePacket
{
public
PacketCodexDataFullNotify
(
Player
player
)
{
super
(
PacketOpcodes
.
CodexDataFullNotify
,
true
);
//Quests
CodexTypeData
.
Builder
questTypeData
=
CodexTypeData
.
newBuilder
()
.
setTypeValue
(
1
);
//Tips
CodexTypeData
.
Builder
pushTipsTypeData
=
CodexTypeData
.
newBuilder
()
.
setTypeValue
(
6
);
//Views
CodexTypeData
.
Builder
viewTypeData
=
CodexTypeData
.
newBuilder
()
.
setTypeValue
(
7
);
//Weapons
CodexTypeData
.
Builder
weaponTypeData
=
CodexTypeData
.
newBuilder
()
.
setTypeValue
(
2
);
player
.
getQuestManager
().
forEachMainQuest
(
mainQuest
->
{
if
(
mainQuest
.
isFinished
()){
var
codexQuest
=
GameData
.
getCodexQuestIdMap
().
get
(
mainQuest
.
getParentQuestId
());
if
(
codexQuest
!=
null
){
questTypeData
.
addCodexIdList
(
codexQuest
.
getId
()).
addAllHaveViewedList
(
Collections
.
singleton
(
true
));
}
}
});
CodexDataFullNotify
.
Builder
proto
=
CodexDataFullNotify
.
newBuilder
()
.
addTypeDataList
(
questTypeData
.
build
())
.
addTypeDataList
(
pushTipsTypeData
.
build
())
.
addTypeDataList
(
viewTypeData
.
build
())
.
addTypeDataList
(
weaponTypeData
);
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataUpdateNotify.java
0 → 100644
View file @
749ef3ff
package
emu.grasscutter.server.packet.send
;
import
java.util.Collections
;
import
java.util.List
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.CodexDataUpdateNotifyOuterClass.CodexDataUpdateNotify
;
import
emu.grasscutter.server.game.GameSession
;
public
class
PacketCodexDataUpdateNotify
extends
BasePacket
{
public
PacketCodexDataUpdateNotify
(
GameMainQuest
quest
)
{
super
(
PacketOpcodes
.
CodexDataUpdateNotify
,
true
);
var
codexQuest
=
GameData
.
getCodexQuestIdMap
().
get
(
quest
.
getParentQuestId
());
if
(
codexQuest
!=
null
){
CodexDataUpdateNotify
proto
=
CodexDataUpdateNotify
.
newBuilder
()
.
setTypeValue
(
1
)
.
setId
(
codexQuest
.
getId
())
.
build
();
this
.
setData
(
proto
);
}
}
}
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