feat: enrich internal match game analysis
This commit is contained in:
1 parent
9f698a8fec
commit
aa675199af
22 files changed
+3123
-241
No files matched your search
@@ -214,4 +214,52 @@ describe('RiotMatchService', () => {
|
||||
levelUpType: 'NORMAL',
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects non-numeric champion kill victim ids', async () => {
|
||||
const payload = {
|
||||
metadata: {
|
||||
dataVersion: '2',
|
||||
matchId: 'KR_8188913502',
|
||||
participants: ['puuid-1'],
|
||||
},
|
||||
info: {
|
||||
frameInterval: 60_000,
|
||||
frames: [
|
||||
{
|
||||
timestamp: 60_000,
|
||||
events: [
|
||||
{
|
||||
type: 'CHAMPION_KILL',
|
||||
timestamp: 30_000,
|
||||
killerId: 1,
|
||||
victimId: '2',
|
||||
},
|
||||
],
|
||||
participantFrames: {
|
||||
'1': {
|
||||
participantId: 1,
|
||||
totalGold: 1_150,
|
||||
xp: 550,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
const riotClientService = {
|
||||
get: jest.fn(
|
||||
<T>(_path: string, _options: unknown, parser?: RiotResponseParser<T>) =>
|
||||
Promise.resolve().then(() =>
|
||||
parser ? parser(payload) : (payload as T),
|
||||
),
|
||||
),
|
||||
} as unknown as RiotClientService;
|
||||
const service = new RiotMatchService(riotClientService);
|
||||
|
||||
await expect(
|
||||
service.getMatchTimeline('KR_8188913502', { region: 'asia' }),
|
||||
).rejects.toThrow(
|
||||
'timeline.info.frames[0].events[0].victimId must be a finite number when present.',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -415,6 +415,10 @@ function parseTimelineEvent(
|
||||
value.type,
|
||||
`timeline.info.frames[${frameIndex}].events[${eventIndex}].type`,
|
||||
),
|
||||
victimId: optionalNumber(
|
||||
value.victimId,
|
||||
`timeline.info.frames[${frameIndex}].events[${eventIndex}].victimId`,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -291,6 +291,7 @@ export interface RiotMatchTimelineEventDto extends Record<string, unknown> {
|
||||
skillSlot?: number;
|
||||
teamId?: number;
|
||||
towerType?: string;
|
||||
victimId?: number;
|
||||
}
|
||||
|
||||
export interface RiotMatchTimelineParticipantFrameDto
|
||||
|
||||
Reference in new issue
Block a user