Skip to content

Commit 39672be

Browse files
committed
fix fight id in enemy/pet actor lists
1 parent 6fcf22c commit 39672be

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/route/wcl/fights.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,28 +190,33 @@ type ActorInput<T extends ActorKind> = Required<
190190
>[T][number];
191191
type ActorAppender<T extends ActorKind> = (
192192
v: ActorInput<T>,
193-
actor: ActorType[T]
193+
actor: ActorType[T],
194+
fight: WCLFight,
194195
) => void;
195196

196-
const mapEnemy: ActorAppender<"enemyNPCs" | "enemyPets"> = (input, actor) => {
197+
const mapEnemy: ActorAppender<"enemyNPCs" | "enemyPets"> = (
198+
input,
199+
actor,
200+
fight,
201+
) => {
197202
actor.fights.push({
198-
id: input.id,
203+
id: fight.id,
199204
instances: input.instanceCount,
200205
groups: input.groupCount,
201206
});
202207
};
203208

204-
const mapPet: ActorAppender<"friendlyPets"> = (input, actor) => {
209+
const mapPet: ActorAppender<"friendlyPets"> = (input, actor, fight) => {
205210
actor.fights.push({
206-
id: input.id,
211+
id: fight.id,
207212
instances: input.instanceCount,
208213
});
209214
};
210215

211216
function withFights<T extends ActorKind>(
212217
report: FightData["reportData"]["report"],
213218
kind: T,
214-
appender: ActorAppender<T>
219+
appender: ActorAppender<T>,
215220
): Array<ActorType[T]> {
216221
const result: Map<number, ActorType[typeof kind]> = report.masterData.actors
217222
.map((actor) => ({
@@ -232,7 +237,7 @@ function withFights<T extends ActorKind>(
232237
if (!actor) {
233238
return;
234239
}
235-
appender(entry, actor);
240+
appender(entry, actor, fight);
236241
});
237242
}
238243

@@ -253,7 +258,7 @@ function reportDataCompat({ reportData: { report } }: FightData): WCLReport {
253258
}
254259

255260
return fight;
256-
}
261+
},
257262
),
258263
phases:
259264
report.phases?.map(({ boss, phases, separatesWipes }) => ({
@@ -286,7 +291,7 @@ function reportDataCompat({ reportData: { report } }: FightData): WCLReport {
286291
...rest,
287292
server: server.slug,
288293
region: server.region.slug,
289-
})
294+
}),
290295
),
291296
};
292297
}
@@ -305,10 +310,10 @@ const fights = wrapEndpoint(
305310
},
306311
{
307312
refreshToken: req.user?.data.wcl?.refreshToken,
308-
}
313+
},
309314
);
310315
return reportDataCompat(rawData);
311-
}
316+
},
312317
);
313318

314319
export default fights;

0 commit comments

Comments
 (0)