add img support

This commit is contained in:
2025-05-20 06:58:42 +02:00
parent 3d47d931ee
commit 518b1fe178

View File

@@ -42,6 +42,7 @@ type LogEvent = {
timestamp: Date timestamp: Date
text: string text: string
type: 'event' | 'status' | 'system' | 'shop' | 'action' | 'error' | 'info' type: 'event' | 'status' | 'system' | 'shop' | 'action' | 'error' | 'info'
img?: string
} }
// Define the structure for game options parsed from lobbyOptions // Define the structure for game options parsed from lobbyOptions
@@ -454,8 +455,10 @@ export default function LogParser() {
const cardRaw = cardMatch?.[1]?.trim() ?? 'Unknown Card' const cardRaw = cardMatch?.[1]?.trim() ?? 'Unknown Card'
const cardClean = cardRaw.replace(/^(c_mp_|j_mp_)/, '') const cardClean = cardRaw.replace(/^(c_mp_|j_mp_)/, '')
const cost = costMatch?.[1] ? Number.parseInt(costMatch[1], 10) : 0 const cost = costMatch?.[1] ? Number.parseInt(costMatch[1], 10) : 0
console.log(cardRaw)
currentGame.events.push({ currentGame.events.push({
timestamp, timestamp,
img: jokers[cardRaw]?.file,
text: `Bought ${cardClean}${cost > 0 ? ` for $${cost}` : ''}`, text: `Bought ${cardClean}${cost > 0 ? ` for $${cost}` : ''}`,
type: 'shop', type: 'shop',
}) })
@@ -713,20 +716,30 @@ export default function LogParser() {
<CardContent> <CardContent>
<ScrollArea className='h-[90vh]'> <ScrollArea className='h-[90vh]'>
<div className='space-y-2 pr-4'> <div className='space-y-2 pr-4'>
{game.events.map((event, index) => ( {game.events.map((event, index) => {
<div console.log(event.img)
// biome-ignore lint/suspicious/noArrayIndexKey: Simple list rendering return (
key={index} <>
className={`text-base ${getEventColor(event.type)}`} <div
> // biome-ignore lint/suspicious/noArrayIndexKey: Simple list rendering
<span className='mr-2 font-mono'> key={index}
{formatter.dateTime(event.timestamp, { className={`text-base ${getEventColor(event.type)}`}
timeStyle: 'medium', >
})} <span className='mr-2 font-mono'>
</span> {formatter.dateTime(event.timestamp, {
<span>{event.text}</span> timeStyle: 'medium',
</div> })}
))} </span>
<span>{event.text}</span>
</div>
{event.img && (
<div>
<OptimizedImage src={event.img} />
</div>
)}
</>
)
})}
</div> </div>
</ScrollArea> </ScrollArea>
</CardContent> </CardContent>