Add timeline advantage events

This commit is contained in:
dahyeon committed 2026-07-02 23:31:19 -07:00
1 parent 1e2f1695ce
commit d35843a8e2
5 files changed
+342 -1

No files matched your search

@@ -269,4 +269,121 @@ describe('TimelineDerivedService', () => {
expect(derived.objectiveWindows).toHaveLength(1);
expect(derived.objectiveWindows[0].monsterType).toBe('BARON_NASHOR');
});
it('builds weighted advantage events for kills, plates, towers, and objectives', () => {
const derived = service.buildDerivedData(
createTimelinePayload([
[
{
type: 'CHAMPION_KILL',
timestamp: 10_000,
killerId: 1,
victimId: 6,
assistingParticipantIds: [2],
victimDamageReceived: [{ participantId: 3, magicDamageDone: 80 }],
},
{
type: 'TURRET_PLATE_DESTROYED',
timestamp: 20_000,
killerId: 0,
teamId: 200,
},
{
type: 'BUILDING_KILL',
timestamp: 30_000,
killerId: 2,
assistingParticipantIds: [3, 4],
buildingType: 'TOWER_BUILDING',
teamId: 200,
towerType: 'OUTER_TURRET',
},
{
type: 'ELITE_MONSTER_KILL',
timestamp: 40_000,
killerId: 3,
killerTeamId: 100,
monsterType: 'RIFTHERALD',
},
{
type: 'ELITE_MONSTER_KILL',
timestamp: 50_000,
killerId: 8,
killerTeamId: 200,
monsterType: 'BARON_NASHOR',
},
],
]),
);
expect(derived.advantageEvents).toEqual([
{
timestampMs: 10_000,
teamId: 100,
type: 'championKill',
score: 1,
participantIds: [1, 2, 3],
},
{
timestampMs: 20_000,
teamId: 100,
type: 'turretPlate',
score: 0.5,
participantIds: [],
},
{
timestampMs: 30_000,
teamId: 100,
type: 'tower',
score: 1.5,
participantIds: [2, 3, 4],
},
{
timestampMs: 40_000,
teamId: 100,
type: 'riftHerald',
score: 1.5,
participantIds: [3],
},
{
timestampMs: 50_000,
teamId: 200,
type: 'baron',
score: 3,
participantIds: [8],
},
]);
});
it('omits advantage events when the scoring team cannot be inferred', () => {
const derived = service.buildDerivedData(
createTimelinePayload([
[
{
type: 'CHAMPION_KILL',
timestamp: 10_000,
killerId: 0,
victimId: 6,
},
{
type: 'TURRET_PLATE_DESTROYED',
timestamp: 20_000,
killerId: 0,
},
{
type: 'BUILDING_KILL',
timestamp: 30_000,
buildingType: 'TOWER_BUILDING',
},
{
type: 'ELITE_MONSTER_KILL',
timestamp: 40_000,
killerId: 0,
monsterType: 'DRAGON',
},
],
]),
);
expect(derived.advantageEvents).toEqual([]);
});
});