tauri-app: set event color depending on event type
All checks were successful
record-daemon / Build, check and test (push) Successful in 2m3s
All checks were successful
record-daemon / Build, check and test (push) Successful in 2m3s
This commit is contained in:
@@ -95,11 +95,7 @@ function getEventColor(event: TimestampedEvent): string {
|
|||||||
return "#60a5fa"; // blue
|
return "#60a5fa"; // blue
|
||||||
case "kill":
|
case "kill":
|
||||||
case "champions_killed":
|
case "champions_killed":
|
||||||
return "#f87171"; // red
|
return getKillEventColor(event);
|
||||||
case "death":
|
|
||||||
return "#ef4444"; // darker red
|
|
||||||
case "assist":
|
|
||||||
return "#a78bfa"; // purple
|
|
||||||
case "objective":
|
case "objective":
|
||||||
return "#fbbf24"; // yellow
|
return "#fbbf24"; // yellow
|
||||||
default:
|
default:
|
||||||
@@ -107,6 +103,43 @@ function getEventColor(event: TimestampedEvent): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get kill event color based on player involvement
|
||||||
|
function getKillEventColor(event: TimestampedEvent): string {
|
||||||
|
const rawEvent = event.event as { killer?: string; victim?: string } | null;
|
||||||
|
const rawData = event.raw_data as { Assisters?: string[] } | null;
|
||||||
|
|
||||||
|
if (!rawEvent) return "#9ca3af"; // gray for unknown
|
||||||
|
|
||||||
|
const killer = rawEvent.killer;
|
||||||
|
const victim = rawEvent.victim;
|
||||||
|
const assisters = rawData?.Assisters || [];
|
||||||
|
|
||||||
|
// Get local player's summoner name
|
||||||
|
const localPlayerName = localPlayer.value?.riotIdGameName;
|
||||||
|
|
||||||
|
if (!localPlayerName) {
|
||||||
|
return "#9ca3af"; // gray if we can't determine local player
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player got a kill
|
||||||
|
if (killer === localPlayerName) {
|
||||||
|
return "#4ade80"; // green for kills by player
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player died
|
||||||
|
if (victim === localPlayerName) {
|
||||||
|
return "#ef4444"; // red for deaths (player was killed)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player assisted
|
||||||
|
if (assisters.includes(localPlayerName)) {
|
||||||
|
return "#a78bfa"; // purple for assists
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player not involved
|
||||||
|
return "#9ca3af"; // gray for neutral kills
|
||||||
|
}
|
||||||
|
|
||||||
// Player stats from end game data
|
// Player stats from end game data
|
||||||
interface PlayerData {
|
interface PlayerData {
|
||||||
puuid: string;
|
puuid: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user