Commit 749ef3ff authored by ShigemoriHakura's avatar ShigemoriHakura Committed by GitHub
Browse files

Add support for codexQuests (#870)

parent ab6aa961
...@@ -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;
} }
......
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);
}
}
}
...@@ -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());
......
...@@ -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();
} }
......
...@@ -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;
......
...@@ -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) {
......
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);
}
}
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);
}
}
}
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