diff --git a/src/app/(home)/log-parser/_components/pvp-blinds.tsx b/src/app/(home)/log-parser/_components/pvp-blinds.tsx index e68999a..d7fe975 100644 --- a/src/app/(home)/log-parser/_components/pvp-blinds.tsx +++ b/src/app/(home)/log-parser/_components/pvp-blinds.tsx @@ -13,7 +13,8 @@ import { // Define the structure for hand scores within a PVP blind export type HandScore = { timestamp: Date - score: number + gainedScore: number + totalScore: number handsLeft: number isLogOwner: boolean } @@ -172,7 +173,7 @@ function PvpHandScoresTable({ // Group hand scores by player and filter out zero scores const logOwnerScores = sortedHandScores.filter((score) => score.isLogOwner) const opponentScores = sortedHandScores.filter( - (score) => !score.isLogOwner && score.score > 0 + (score) => !score.isLogOwner && score.gainedScore > 0 ) // Determine the maximum number of hands @@ -183,11 +184,11 @@ function PvpHandScoresTable({ // Calculate total scores const totalLogOwnerScore = logOwnerScores.reduce( - (sum, score) => sum + score.score, + (sum, score) => sum + score.gainedScore, 0 ) const totalOpponentScore = opponentScores.reduce( - (sum, score) => sum + score.score, + (sum, score) => sum + score.gainedScore, 0 ) @@ -211,12 +212,12 @@ function PvpHandScoresTable({ {handNumber} {index < logOwnerScores.length - ? formatNumber(logOwnerScores[index]?.score) + ? formatNumber(logOwnerScores[index]?.gainedScore) : '-'} {index < opponentScores.length - ? formatNumber(opponentScores[index]?.score) + ? formatNumber(opponentScores[index]?.gainedScore) : '-'} diff --git a/src/app/(home)/log-parser/page.tsx b/src/app/(home)/log-parser/page.tsx index 340fb55..4f771b7 100644 --- a/src/app/(home)/log-parser/page.tsx +++ b/src/app/(home)/log-parser/page.tsx @@ -355,12 +355,12 @@ export default function LogParser() { const handsLeftMatch = line.match(/handsLeft: *(\d+)/) if (scoreMatch?.[1]) { - const score = Number.parseInt(scoreMatch[1], 10) + const totalScore = Number.parseInt(scoreMatch[1], 10) const handsLeft = handsLeftMatch?.[1] ? Number.parseInt(handsLeftMatch[1], 10) : 0 - if (!Number.isNaN(score)) { + if (!Number.isNaN(totalScore)) { const currentBlindIndex = currentGame.currentPvpBlind - 1 if ( currentBlindIndex >= 0 && @@ -371,21 +371,23 @@ export default function LogParser() { continue } // Update opponent score in current blind - currentBlind.opponentScore += score + const gainedScore = totalScore - currentBlind.opponentScore + currentBlind.opponentScore = totalScore // Add hand score currentBlind.handScores.push({ timestamp, - score, + gainedScore, + totalScore, handsLeft, isLogOwner: false, }) - // Add event for opponent score only if score > 0 - if (score > 0) { + // Add event for opponent score only if gainedScore > 0 + if (gainedScore > 0) { currentGame.events.push({ timestamp, - text: `Opponent score: ${score} (Hands left: ${handsLeft})`, + text: `Opponent scored: ${gainedScore} (Total: ${totalScore}, hands left: ${handsLeft})`, type: 'event', }) } @@ -600,12 +602,12 @@ export default function LogParser() { const handsLeftMatch = line.match(/handsLeft:(\d+)/) if (scoreMatch?.[1]) { - const score = Number.parseInt(scoreMatch[1], 10) + const totalScore = Number.parseInt(scoreMatch[1], 10) const handsLeft = handsLeftMatch?.[1] ? Number.parseInt(handsLeftMatch[1], 10) : 0 - if (!Number.isNaN(score)) { + if (!Number.isNaN(totalScore)) { const currentBlindIndex = currentGame.currentPvpBlind - 1 if ( currentBlindIndex >= 0 && @@ -617,21 +619,23 @@ export default function LogParser() { continue } // Update log owner score in current blind - currentBlind.logOwnerScore += score + const gainedScore = totalScore - currentBlind.logOwnerScore + currentBlind.logOwnerScore = totalScore // Add hand score currentBlind.handScores.push({ timestamp, - score, + gainedScore, + totalScore, handsLeft, isLogOwner: true, }) - // Add event for log owner score only if score > 0 - if (score > 0) { + // Add event for log owner score only if gainedScore > 0 + if (gainedScore > 0) { currentGame.events.push({ timestamp, - text: `Your score: ${score} (Hands left: ${handsLeft})`, + text: `You scored: ${gainedScore} (Total: ${totalScore}, hands left: ${handsLeft})`, type: 'event', }) }