mirror of
https://github.com/Anime-Game-Servers/Grasscutter-Quests.git
synced 2024-11-23 04:29:42 +00:00
[experimental] load quests from generated quest jsons including patches
This commit is contained in:
parent
675f8ba5f8
commit
77d0720ab1
@ -442,10 +442,11 @@ public class ResourceLoader {
|
||||
|
||||
private static void loadQuests() {
|
||||
try {
|
||||
Files.list(getResourcePath("BinOutput/Quest/")).forEach(path -> {
|
||||
Files.list(getResourcePath("Generated/Quest")).forEach(path -> {
|
||||
try {
|
||||
val mainQuest = JsonUtils.loadToClass(path, MainQuestData.class);
|
||||
GameData.getMainQuestDataMap().put(mainQuest.getId(), mainQuest);
|
||||
mainQuest.onLoad();
|
||||
if(mainQuest.getTalks() != null) {
|
||||
mainQuest.getTalks().forEach(talkData -> GameData.getQuestTalkMap().put(talkData.getId(), mainQuest.getId()));
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package emu.grasscutter.data.binout;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.QuestData;
|
||||
import emu.grasscutter.game.quest.enums.QuestType;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
@ -16,7 +18,7 @@ public class MainQuestData {
|
||||
private int[] suggestTrackMainQuestList;
|
||||
private int[] rewardIdList;
|
||||
|
||||
private SubQuestData[] subQuests;
|
||||
private QuestData[] subQuests;
|
||||
private List<TalkData> talks;
|
||||
private long[] preloadLuaList;
|
||||
|
||||
@ -44,7 +46,7 @@ public class MainQuestData {
|
||||
return rewardIdList;
|
||||
}
|
||||
|
||||
public SubQuestData[] getSubQuests() {
|
||||
public QuestData[] getSubQuests() {
|
||||
return subQuests;
|
||||
}
|
||||
public List<TalkData> getTalks() {
|
||||
@ -52,7 +54,15 @@ public class MainQuestData {
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.talks = talks.stream().filter(Objects::nonNull).toList();
|
||||
if(talks != null) {
|
||||
this.talks = talks.stream().filter(Objects::nonNull).toList();
|
||||
}
|
||||
if(subQuests!= null && subQuests.length > 0) {
|
||||
for (QuestData subQuest : subQuests) {
|
||||
subQuest.onLoad();
|
||||
GameData.getQuestDataMap().put(subQuest.getSubId(), subQuest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -57,6 +57,17 @@ public class QuestData extends GameResource {
|
||||
this.finishExec = finishExec.stream().filter(p -> p.type != null).toList();
|
||||
this.failExec = failExec.stream().filter(p -> p.type != null).toList();
|
||||
|
||||
finishCond.stream().filter(p -> p.getType() != null).forEach(c -> {
|
||||
if(c.getParamStr() == null){
|
||||
c.setParamStr("");
|
||||
}
|
||||
});
|
||||
failCond.stream().filter(p -> p.getType() != null).forEach(c -> {
|
||||
if(c.getParamStr() == null){
|
||||
c.setParamStr("");
|
||||
}
|
||||
});
|
||||
|
||||
if (this.acceptCondComb == null)
|
||||
this.acceptCondComb = LogicType.LOGIC_NONE;
|
||||
|
||||
@ -94,11 +105,11 @@ public class QuestData extends GameResource {
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public static class QuestExecParam {
|
||||
@SerializedName("_type")
|
||||
@SerializedName(value = "type", alternate = {"_type"})
|
||||
QuestExec type;
|
||||
@SerializedName("_param")
|
||||
@SerializedName(value = "param", alternate = {"_param"})
|
||||
String[] param;
|
||||
@SerializedName("_count")
|
||||
@SerializedName(value = "count", alternate = {"_count"})
|
||||
String count;
|
||||
}
|
||||
|
||||
@ -108,13 +119,13 @@ public class QuestData extends GameResource {
|
||||
|
||||
@Data
|
||||
public static class QuestCondition<TYPE extends Enum<?> & QuestTrigger> {
|
||||
@SerializedName("_type")
|
||||
@SerializedName(value = "type", alternate = {"_type"})
|
||||
private TYPE type;
|
||||
@SerializedName("_param")
|
||||
@SerializedName(value = "param", alternate = {"_param"})
|
||||
private int[] param;
|
||||
@SerializedName("_param_str")
|
||||
@SerializedName(value = "paramStr", alternate = {"_param_str", "param_str"})
|
||||
private String paramStr;
|
||||
@SerializedName("_count")
|
||||
@SerializedName(value = "count", alternate = {"_count"})
|
||||
private int count;
|
||||
|
||||
public String asKey() {
|
||||
|
@ -64,7 +64,7 @@ public class GameMainQuest {
|
||||
}
|
||||
|
||||
private void addAllChildQuests() {
|
||||
List<Integer> subQuestIds = Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests()).map(SubQuestData::getSubId).toList();
|
||||
List<Integer> subQuestIds = Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests()).map(QuestData::getSubId).toList();
|
||||
for (Integer subQuestId : subQuestIds) {
|
||||
QuestData questConfig = GameData.getQuestDataMap().get(subQuestId);
|
||||
this.childQuests.put(subQuestId, new GameQuest(this, questConfig));
|
||||
|
@ -240,8 +240,8 @@ public class QuestManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
Arrays.stream(mainQuestData.getSubQuests())
|
||||
.min(Comparator.comparingInt(MainQuestData.SubQuestData::getOrder))
|
||||
.map(MainQuestData.SubQuestData::getSubId)
|
||||
.min(Comparator.comparingInt(QuestData::getOrder))
|
||||
.map(QuestData::getSubId)
|
||||
.ifPresent(this::addQuest);
|
||||
//TODO find a better way then hardcoding to detect needed required quests
|
||||
if(mainQuestId == 355){
|
||||
|
Loading…
Reference in New Issue
Block a user