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,7 +716,10 @@ 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) => {
console.log(event.img)
return (
<>
<div <div
// biome-ignore lint/suspicious/noArrayIndexKey: Simple list rendering // biome-ignore lint/suspicious/noArrayIndexKey: Simple list rendering
key={index} key={index}
@@ -726,7 +732,14 @@ export default function LogParser() {
</span> </span>
<span>{event.text}</span> <span>{event.text}</span>
</div> </div>
))} {event.img && (
<div>
<OptimizedImage src={event.img} />
</div>
)}
</>
)
})}
</div> </div>
</ScrollArea> </ScrollArea>
</CardContent> </CardContent>