Add timeline roam frames
This commit is contained in:
1 parent
df0e43d884
commit
d4e7cb6e8b
4 files changed
+296
No files matched your search
@@ -38,6 +38,13 @@ interface TimelineFrameSnapshot {
|
||||
participantPositions: Map<number, TimelinePosition>;
|
||||
}
|
||||
|
||||
interface TimelineRoamParticipant {
|
||||
participantId: number;
|
||||
teamId: 100 | 200;
|
||||
assignedLaneZone: SummonersRiftMapZone;
|
||||
baseZone: SummonersRiftMapZone;
|
||||
}
|
||||
|
||||
export interface TimelineFightCluster {
|
||||
startTimeMs: number;
|
||||
endTimeMs: number;
|
||||
@@ -77,11 +84,22 @@ export interface TimelineDeathEvent {
|
||||
nearestAllyDistanceApprox: number | null;
|
||||
}
|
||||
|
||||
export interface TimelineRoamFrame {
|
||||
t: number;
|
||||
participantId: number;
|
||||
teamId: number;
|
||||
x: number;
|
||||
y: number;
|
||||
zone: SummonersRiftMapZone;
|
||||
assignedLaneZone: SummonersRiftMapZone;
|
||||
}
|
||||
|
||||
export interface TimelineDerivedData {
|
||||
fightClusters: TimelineFightCluster[];
|
||||
advantageEvents: TimelineAdvantageEvent[];
|
||||
deathEvents: TimelineDeathEvent[];
|
||||
objectiveWindows: TimelineObjectiveWindow[];
|
||||
roamFrames: TimelineRoamFrame[];
|
||||
}
|
||||
|
||||
const FIGHT_CLUSTER_MAX_GAP_MS = 15_000;
|
||||
@@ -89,6 +107,8 @@ const FIGHT_CLUSTER_MAX_DISTANCE = 3_000;
|
||||
const CLEANUP_WINDOW_MS = 5_000;
|
||||
const OBJECTIVE_WINDOW_BEFORE_MS = 120_000;
|
||||
const OBJECTIVE_WINDOW_AFTER_MS = 30_000;
|
||||
const ROAM_FRAME_START_MS = 8 * 60_000;
|
||||
const ROAM_FRAME_END_MS = 14 * 60_000;
|
||||
const OBJECTIVE_MONSTER_TYPES = new Set([
|
||||
'DRAGON',
|
||||
'RIFTHERALD',
|
||||
@@ -320,6 +340,68 @@ function opposingTeamId(teamId: 100 | 200 | undefined): 100 | 200 | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function assignedLaneZoneForRole(
|
||||
teamPosition: string | undefined,
|
||||
): SummonersRiftMapZone | undefined {
|
||||
switch (teamPosition) {
|
||||
case 'TOP':
|
||||
return 'topLane';
|
||||
case 'MIDDLE':
|
||||
return 'middleLane';
|
||||
case 'BOTTOM':
|
||||
case 'UTILITY':
|
||||
return 'bottomLane';
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function baseZoneForTeamId(
|
||||
teamId: 100 | 200 | undefined,
|
||||
): SummonersRiftMapZone | undefined {
|
||||
switch (teamId) {
|
||||
case 100:
|
||||
return 'blueBase';
|
||||
case 200:
|
||||
return 'redBase';
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function parseRoamParticipants(
|
||||
rawMatch: Record<string, unknown> | undefined,
|
||||
): TimelineRoamParticipant[] {
|
||||
const info = asRecord(rawMatch?.info);
|
||||
return asArray(info.participants)
|
||||
.map(asRecord)
|
||||
.flatMap((participant) => {
|
||||
const participantId = asParticipantId(participant.participantId);
|
||||
const teamId = toTeamId(participant.teamId);
|
||||
const assignedLaneZone = assignedLaneZoneForRole(
|
||||
asString(participant.teamPosition),
|
||||
);
|
||||
const baseZone = baseZoneForTeamId(teamId);
|
||||
if (
|
||||
participantId === undefined ||
|
||||
teamId === undefined ||
|
||||
assignedLaneZone === undefined ||
|
||||
baseZone === undefined
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
participantId,
|
||||
teamId,
|
||||
assignedLaneZone,
|
||||
baseZone,
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
function scoringParticipantIds(event: TimelineChampionKillEvent): number[] {
|
||||
return toSortedIds(
|
||||
[
|
||||
@@ -802,10 +884,60 @@ function buildDeathEvents(
|
||||
});
|
||||
}
|
||||
|
||||
function buildRoamFrames(
|
||||
frameSnapshots: TimelineFrameSnapshot[],
|
||||
rawMatch: Record<string, unknown> | undefined,
|
||||
): TimelineRoamFrame[] {
|
||||
const roamParticipants = parseRoamParticipants(rawMatch);
|
||||
if (roamParticipants.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return frameSnapshots.flatMap((frame) => {
|
||||
if (
|
||||
frame.timestamp < ROAM_FRAME_START_MS ||
|
||||
frame.timestamp > ROAM_FRAME_END_MS
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return roamParticipants.flatMap((participant) => {
|
||||
const position = frame.participantPositions.get(
|
||||
participant.participantId,
|
||||
);
|
||||
if (!position) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const zone = classifySummonersRiftPosition(position);
|
||||
if (
|
||||
zone === 'unknown' ||
|
||||
zone === participant.assignedLaneZone ||
|
||||
zone === participant.baseZone
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
t: frame.timestamp,
|
||||
participantId: participant.participantId,
|
||||
teamId: participant.teamId,
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
zone,
|
||||
assignedLaneZone: participant.assignedLaneZone,
|
||||
},
|
||||
];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TimelineDerivedService {
|
||||
public buildDerivedData(
|
||||
timeline: Record<string, unknown>,
|
||||
rawMatch?: Record<string, unknown>,
|
||||
): TimelineDerivedData {
|
||||
const {
|
||||
advantageEvents,
|
||||
@@ -819,6 +951,7 @@ export class TimelineDerivedService {
|
||||
advantageEvents,
|
||||
deathEvents: buildDeathEvents(championKills, frameSnapshots),
|
||||
objectiveWindows: buildObjectiveWindows(eliteMonsterKills),
|
||||
roamFrames: buildRoamFrames(frameSnapshots, rawMatch),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user