mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-07 10:36:41 +01:00
Copy some files from Grasscutter-Quests
NOT completely finished, nor is it completely done. Protocol issues remain! (including lack of packet IDs)
This commit is contained in:
@@ -1,109 +1,121 @@
|
||||
package emu.grasscutter.data.excels;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import emu.grasscutter.game.quest.enums.LogicType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.enums.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.*;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
@ResourceType(name = "QuestExcelConfigData.json")
|
||||
@Getter
|
||||
@ToString
|
||||
public class QuestData extends GameResource {
|
||||
private int subId;
|
||||
private int mainId;
|
||||
private int order;
|
||||
private long descTextMapHash;
|
||||
@Getter private int subId;
|
||||
@Getter private int mainId;
|
||||
@Getter private int order;
|
||||
@Getter private long descTextMapHash;
|
||||
|
||||
private boolean finishParent;
|
||||
private boolean isRewind;
|
||||
@Getter private boolean finishParent;
|
||||
@Getter private boolean isRewind;
|
||||
|
||||
private LogicType acceptCondComb;
|
||||
private LogicType finishCondComb;
|
||||
private LogicType failCondComb;
|
||||
@Getter private LogicType acceptCondComb;
|
||||
@Getter private LogicType finishCondComb;
|
||||
@Getter private LogicType failCondComb;
|
||||
|
||||
private List<QuestCondition> acceptCond;
|
||||
private List<QuestCondition> finishCond;
|
||||
private List<QuestCondition> failCond;
|
||||
private List<QuestExecParam> beginExec;
|
||||
private List<QuestExecParam> finishExec;
|
||||
private List<QuestExecParam> failExec;
|
||||
private Guide guide;
|
||||
@Getter private List<QuestAcceptCondition> acceptCond;
|
||||
@Getter private List<QuestContentCondition> finishCond;
|
||||
@Getter private List<QuestContentCondition> failCond;
|
||||
@Getter private List<QuestExecParam> beginExec;
|
||||
@Getter private List<QuestExecParam> finishExec;
|
||||
@Getter private List<QuestExecParam> failExec;
|
||||
@Getter private Guide guide;
|
||||
@Getter private List<Integer> trialAvatarList;
|
||||
|
||||
public static String questConditionKey(
|
||||
@Nonnull Enum<?> type, int firstParam, @Nullable String paramsStr) {
|
||||
return type.name() + firstParam + (paramsStr != null ? paramsStr : "");
|
||||
}
|
||||
|
||||
// ResourceLoader not happy if you remove getId() ~~
|
||||
public int getId() {
|
||||
return subId;
|
||||
}
|
||||
|
||||
// Added getSubId() for clarity
|
||||
public int getSubId() {
|
||||
return subId;
|
||||
}
|
||||
|
||||
public int getMainId() {
|
||||
return mainId;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public long getDescTextMapHash() {
|
||||
return descTextMapHash;
|
||||
}
|
||||
|
||||
public boolean finishParent() {
|
||||
return finishParent;
|
||||
}
|
||||
|
||||
public boolean isRewind() {
|
||||
return isRewind;
|
||||
}
|
||||
|
||||
public LogicType getAcceptCondComb() {
|
||||
return acceptCondComb == null ? LogicType.LOGIC_NONE : acceptCondComb;
|
||||
}
|
||||
|
||||
public List<QuestCondition> getAcceptCond() {
|
||||
return acceptCond;
|
||||
}
|
||||
|
||||
public LogicType getFinishCondComb() {
|
||||
return finishCondComb == null ? LogicType.LOGIC_NONE : finishCondComb;
|
||||
}
|
||||
|
||||
public List<QuestCondition> getFinishCond() {
|
||||
return finishCond;
|
||||
}
|
||||
|
||||
public LogicType getFailCondComb() {
|
||||
return failCondComb == null ? LogicType.LOGIC_NONE : failCondComb;
|
||||
}
|
||||
|
||||
public List<QuestCondition> getFailCond() {
|
||||
return failCond;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.acceptCond = acceptCond.stream().filter(p -> p.type != null).toList();
|
||||
this.finishCond = finishCond.stream().filter(p -> p.type != null).toList();
|
||||
this.failCond = failCond.stream().filter(p -> p.type != null).toList();
|
||||
this.acceptCond = acceptCond.stream().filter(p -> p.getType() != null).toList();
|
||||
this.finishCond = finishCond.stream().filter(p -> p.getType() != null).toList();
|
||||
this.failCond = failCond.stream().filter(p -> p.getType() != null).toList();
|
||||
|
||||
this.beginExec = beginExec.stream().filter(p -> p.type != null).toList();
|
||||
this.finishExec = finishExec.stream().filter(p -> p.type != null).toList();
|
||||
this.failExec = failExec.stream().filter(p -> p.type != null).toList();
|
||||
|
||||
if (this.acceptCondComb == null) this.acceptCondComb = LogicType.LOGIC_NONE;
|
||||
|
||||
if (this.finishCondComb == null) this.finishCondComb = LogicType.LOGIC_NONE;
|
||||
|
||||
if (this.failCondComb == null) this.failCondComb = LogicType.LOGIC_NONE;
|
||||
|
||||
addToCache();
|
||||
}
|
||||
|
||||
private void addToCache() {
|
||||
if (this.acceptCond == null) {
|
||||
Grasscutter.getLogger().warn("missing AcceptConditions for quest {}", getSubId());
|
||||
return;
|
||||
}
|
||||
|
||||
var cacheMap = GameData.getBeginCondQuestMap();
|
||||
if (getAcceptCond().isEmpty()) {
|
||||
var list =
|
||||
cacheMap.computeIfAbsent(
|
||||
QuestData.questConditionKey(QuestCond.QUEST_COND_NONE, 0, null),
|
||||
e -> new ArrayList<>());
|
||||
list.add(this);
|
||||
} else {
|
||||
this.getAcceptCond()
|
||||
.forEach(
|
||||
questCondition -> {
|
||||
if (questCondition.getType() == null) {
|
||||
Grasscutter.getLogger().warn("null accept type for quest {}", getSubId());
|
||||
return;
|
||||
}
|
||||
|
||||
var key = questCondition.asKey();
|
||||
var list = cacheMap.computeIfAbsent(key, e -> new ArrayList<>());
|
||||
list.add(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class QuestCondition {
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public static class QuestExecParam {
|
||||
@SerializedName("_type")
|
||||
private QuestTrigger type;
|
||||
QuestExec type;
|
||||
|
||||
@SerializedName("_param")
|
||||
String[] param;
|
||||
|
||||
@SerializedName("_count")
|
||||
String count;
|
||||
}
|
||||
|
||||
public static class QuestAcceptCondition extends QuestCondition<QuestCond> {}
|
||||
|
||||
public static class QuestContentCondition extends QuestCondition<QuestContent> {}
|
||||
|
||||
@Data
|
||||
public static class QuestCondition<TYPE extends Enum<?> & QuestTrigger> {
|
||||
@SerializedName("_type")
|
||||
private TYPE type;
|
||||
|
||||
@SerializedName("_param")
|
||||
private int[] param;
|
||||
@@ -112,7 +124,11 @@ public class QuestData extends GameResource {
|
||||
private String paramStr;
|
||||
|
||||
@SerializedName("_count")
|
||||
private String count;
|
||||
private int count;
|
||||
|
||||
public String asKey() {
|
||||
return questConditionKey(getType(), getParam()[0], getParamStr());
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -121,17 +137,4 @@ public class QuestData extends GameResource {
|
||||
private List<String> param;
|
||||
private int guideScene;
|
||||
}
|
||||
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public class QuestExecParam {
|
||||
@SerializedName("_type")
|
||||
QuestTrigger type;
|
||||
|
||||
@SerializedName("_param")
|
||||
String[] param;
|
||||
|
||||
@SerializedName("_count")
|
||||
String count;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user