diff --git a/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte b/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte index 9e1f6be..148b84c 100644 --- a/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte +++ b/src/routes/tournaments/[tournamentguid]/matches/[matchGuid]/+page.svelte @@ -103,6 +103,17 @@ // Reactive statements $: isAnyPlayerPlaying = matchPlayers.some(player => (player.playState as any) === User_PlayStates.InGame); + $: if(isAnyPlayerPlaying && currentSong) { + matchPlayers + .filter(x => x.playState == User_PlayStates.InGame) + .forEach(player => { + const playerKey = `${player.guid}-${currentSong.beatmap.levelId.toLowerCase()}`; + if (!activeSongPlayers.has(playerKey)) { + activeSongPlayers.add(playerKey); + } + }); + } + if ($authTokenStore) { const cleanToken = $authTokenStore.replace('Bearer ', ''); client.setAuthToken(cleanToken); @@ -638,20 +649,23 @@ newRts.accuracy = calculateAccuracy(rts, map); // Check if any players are still playing this song - const playersStillPlaying = Array.from(activeSongPlayers) - .some(key => key.endsWith(`-${levelId.toLowerCase()}`)); + const playersStillPlaying = Array.from(activeSongPlayers).some(key => key.endsWith(`-${levelId.toLowerCase()}`)); + console.log("Players still playing:", playersStillPlaying) const completionType = playersStillPlaying ? 'Still Awaiting Scores' : 'Completed'; + console.log("CompletionType", completionType) // Find or create the result record const existingRecordIndex = previousMatchResults.findIndex(x => x.completionType === 'Still Awaiting Scores' && x.taData.gameplayParameters?.beatmap?.levelId.toUpperCase() === levelId.toUpperCase() ); + console.log("existingRecordIndex", existingRecordIndex) if (existingRecordIndex === -1) { + console.log("creating new record") previousMatchResults = [ { taData: map.taData,