diff --git a/Log.tsx b/Log.tsx index 11accd8..0e0cc06 100644 --- a/Log.tsx +++ b/Log.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { Medal, CheckCircle2, History } from 'lucide-react'; import { useCTF } from './CTFContext'; -import { calculateChallengeValue, getFirstBloodBonusFactor } from './services/scoring'; +import { calculateChallengeValue, getFirstBloodBonusFactor, calculateTeamTotalScore } from './services/scoring'; export const Log: React.FC = () => { const { state } = useCTF(); @@ -10,11 +10,34 @@ export const Log: React.FC = () => { return [...state.solves].sort((a, b) => b.timestamp - a.timestamp); }, [state.solves]); + const topTeams = useMemo(() => { + return state.teams + .filter(t => !t.isAdmin && !t.isDisabled) + .map(team => ({ ...team, score: calculateTeamTotalScore(team.id, state.challenges, state.solves) })) + .sort((a, b) => b.score - a.score) + .slice(0, 3); + }, [state]); + return (
-
- -

Event Log

+
+
+ +

Event Log

+
+ {topTeams.length > 0 && ( +
+ {topTeams.map((team, idx) => ( +
+ + {idx + 1} + + {team.name} + {team.score} PTS +
+ ))} +
+ )}
{sortedSolves.length === 0 ? (