diff --git a/src/app/(home)/log-parser/page.tsx b/src/app/(home)/log-parser/page.tsx index 6e98b82..a2dc933 100644 --- a/src/app/(home)/log-parser/page.tsx +++ b/src/app/(home)/log-parser/page.tsx @@ -35,7 +35,7 @@ import { } from '@/components/ui/tooltip' import { jokers } from '@/shared/jokers' import { useFormatter } from 'next-intl' -import { useState } from 'react' +import { Fragment, useState } from 'react' // Define the structure for individual log events within a game type LogEvent = { @@ -85,6 +85,7 @@ type Game = { opponentFinalJokers: string[] // Opponent's final jokers events: LogEvent[] rerolls: number + winner: 'logOwner' | 'opponent' | null // Who won the game } // Helper to initialize a new game object @@ -114,6 +115,7 @@ const initGame = (id: number, startDate: Date): Game => ({ opponentFinalJokers: [], events: [], rerolls: 0, + winner: null, }) // Helper to format duration @@ -431,6 +433,27 @@ export default function LogParser() { continue } + // Detect win/lose game messages + if (line.includes('Client got winGame message: (action: winGame)')) { + currentGame.winner = 'logOwner' + currentGame.events.push({ + timestamp, + text: 'You won the game!', + type: 'system', + }) + continue + } + + if (line.includes('Client got loseGame message: (action: loseGame)')) { + currentGame.winner = 'opponent' + currentGame.events.push({ + timestamp, + text: 'You lost the game.', + type: 'system', + }) + continue + } + // --- Log Owner Actions/Events (Client sent ...) --- if (lineLower.includes('client sent')) { // Log owner gained/spent money directly @@ -607,10 +630,10 @@ export default function LogParser() { return ( - Game {game.id} vs {opponentLabel} + Game {game.id} vs {game.winner === 'opponent' ? `${opponentLabel} 🏆` : opponentLabel}{game.winner === 'logOwner' ? ' 🏆' : ''} ) })} @@ -631,7 +654,7 @@ export default function LogParser() { return ( @@ -676,6 +699,15 @@ export default function LogParser() { : 'Guest'}{' '} ({ownerLabel})

+ {/* Show Winner */} +

+ Winner:{' '} + {game.winner === null + ? 'Unknown' + : game.winner === 'logOwner' + ? ownerLabel + : opponentLabel} +

Rerolls:{' '} {game.rerolls || 'Unknown'} @@ -728,7 +760,8 @@ export default function LogParser() { {game.events.map((event, index) => { console.log(event.img) return ( - <> + // biome-ignore lint/suspicious/noArrayIndexKey: simple list +

)} - + ) })} @@ -780,7 +813,7 @@ export default function LogParser() {
- {ownerLabel}: + {ownerLabel}{game.winner === 'logOwner' ? ' 🏆' : ''}: {game.logOwnerFinalJokers.length > 0 ? (
    {game.logOwnerFinalJokers.map((joker, i) => { @@ -816,7 +849,7 @@ export default function LogParser() { )}
- {opponentLabel}: + {opponentLabel}{game.winner === 'opponent' ? ' 🏆' : ''}: {game.opponentFinalJokers.length > 0 ? (
    {game.opponentFinalJokers.map((joker, i) => { @@ -866,7 +899,7 @@ export default function LogParser() {
      {game.hostMods.map((mod, i) => ( // biome-ignore lint/suspicious/noArrayIndexKey: Simple list -
    • {mod}
    • +
    • {mod}
    • ))}
    ) : ( @@ -883,7 +916,7 @@ export default function LogParser() {
      {game.guestMods.map((mod, i) => ( // biome-ignore lint/suspicious/noArrayIndexKey: Simple list -
    • {mod}
    • +
    • {mod}
    • ))}
    ) : ( @@ -940,9 +973,11 @@ function ShopSpendingTable({ Shop - {ownerLabel} - {opponentLabel} + {ownerLabel}{game.winner === 'logOwner' ? ' 🏆' : ''} + + + {opponentLabel}{game.winner === 'opponent' ? ' 🏆' : ''}