zenno/doc/spark: make spark select searchable
This commit is contained in:
@@ -144,3 +144,25 @@ export async function sparks(): Promise<Spark[]> {
|
||||
const resp = await fetch('/api/global/spark');
|
||||
return resp.json();
|
||||
}
|
||||
|
||||
export interface SparkGroup {
|
||||
spark_group: number;
|
||||
name: string;
|
||||
description: string;
|
||||
type: Type;
|
||||
effects: Effect[][];
|
||||
spark_ids: number[];
|
||||
}
|
||||
|
||||
export function byGroup(sparks: Spark[]): SparkGroup[] {
|
||||
const r = new Map<number, SparkGroup>();
|
||||
for (const {spark_id, name, description, spark_group, type, effects} of sparks) {
|
||||
let g = r.get(spark_group);
|
||||
if (g == null) {
|
||||
g = {spark_group, name, description, type, effects, spark_ids: []};
|
||||
r.set(spark_group, g);
|
||||
}
|
||||
g.spark_ids.push(spark_id);
|
||||
}
|
||||
return [...r.values()];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user