mirror of
https://github.com/YouHaveTrouble/DiscipleOfLand.git
synced 2026-05-12 06:26:56 +00:00
add node type filter
This commit is contained in:
+24
-2
@@ -1,16 +1,19 @@
|
||||
import {Job, jobFromString} from "@/enums/Job";
|
||||
import {NodeType, nodeTypeFromString} from "@/enums/NodeType";
|
||||
|
||||
export default class Filters {
|
||||
|
||||
minLevel: number;
|
||||
maxLevel: number;
|
||||
jobs: Job[] = [];
|
||||
jobs: Set<Job> = new Set();
|
||||
nodeTypes: Set<NodeType> = new Set();
|
||||
|
||||
constructor(
|
||||
data?: {
|
||||
minLevel?: number,
|
||||
maxLevel?: number,
|
||||
jobs?: string[],
|
||||
nodeTypes?: string[],
|
||||
},
|
||||
) {
|
||||
this.minLevel = data?.minLevel || 91;
|
||||
@@ -20,9 +23,28 @@ export default class Filters {
|
||||
for (const job of jobData) {
|
||||
const parsedJob = jobFromString(job);
|
||||
if (!parsedJob) continue;
|
||||
this.jobs.push(parsedJob);
|
||||
this.jobs.add(parsedJob);
|
||||
}
|
||||
|
||||
const nodeTypeData = data?.nodeTypes || [
|
||||
NodeType.UNSPOILED,
|
||||
];
|
||||
|
||||
for (const nodeType of nodeTypeData) {
|
||||
const parsedNodeType = nodeTypeFromString(nodeType);
|
||||
if (!parsedNodeType) continue;
|
||||
this.nodeTypes.add(parsedNodeType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
serialize(): string {
|
||||
return JSON.stringify({
|
||||
minLevel: this.minLevel,
|
||||
maxLevel: this.maxLevel,
|
||||
jobs: Array.from(this.jobs).map(job => job),
|
||||
nodeTypes: Array.from(this.nodeTypes).map(nodeType => nodeType),
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user