Spaces:
Runtime error
Runtime error
Commit
·
8b6f89e
1
Parent(s):
940813c
Better win screens
Browse files
src/components/game-component.tsx
CHANGED
|
@@ -526,21 +526,43 @@ export default function GameComponent({
|
|
| 526 |
) : (
|
| 527 |
<div className="flex items-center justify-center h-[calc(100%-2.5rem)]">
|
| 528 |
{gameStatus === "won" ? (
|
| 529 |
-
<div className="bg-green-
|
| 530 |
-
<
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
</div>
|
| 545 |
) : (
|
| 546 |
<div className="bg-red-100 text-red-800 p-4 rounded-md w-full">
|
|
@@ -690,24 +712,48 @@ export default function GameComponent({
|
|
| 690 |
key={`result-${index}`}
|
| 691 |
className={`p-2 rounded-lg text-xs ${
|
| 692 |
isWon
|
| 693 |
-
? "bg-green-50 border border-green-
|
| 694 |
: "bg-red-50 border border-red-100"
|
| 695 |
}`}
|
| 696 |
>
|
| 697 |
-
|
| 698 |
-
<
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 711 |
</div>
|
| 712 |
);
|
| 713 |
} else if (message.role === "error") {
|
|
|
|
| 526 |
) : (
|
| 527 |
<div className="flex items-center justify-center h-[calc(100%-2.5rem)]">
|
| 528 |
{gameStatus === "won" ? (
|
| 529 |
+
<div className="bg-gradient-to-r from-green-50 to-emerald-50 border border-green-200 p-6 rounded-lg w-full shadow-sm">
|
| 530 |
+
<div className="flex flex-col items-center text-center">
|
| 531 |
+
<div className="mb-3 bg-green-100 p-3 rounded-full">
|
| 532 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="text-green-600"><polyline points="20 6 9 17 4 12"></polyline></svg>
|
| 533 |
+
</div>
|
| 534 |
+
<h3 className="font-bold text-xl text-green-800 mb-2">
|
| 535 |
+
You won!
|
| 536 |
+
</h3>
|
| 537 |
+
<p className="text-green-700 mb-4">
|
| 538 |
+
You reached <span className="font-bold">{targetPage}</span> in <span className="font-bold">{hops}</span> {hops === 1 ? 'hop' : 'hops'} in {formatTime(timeElapsed)}
|
| 539 |
+
</p>
|
| 540 |
+
|
| 541 |
+
<div className="bg-white rounded-md p-4 my-3 w-full max-w-md border border-green-100">
|
| 542 |
+
<h4 className="font-medium text-sm text-green-800 mb-2">Your Path:</h4>
|
| 543 |
+
<div className="flex flex-wrap items-center gap-2 justify-center text-sm">
|
| 544 |
+
{visitedNodes.map((node, index) => (
|
| 545 |
+
<div key={`path-${index}`} className="flex items-center">
|
| 546 |
+
<span className="bg-green-50 px-2 py-1 rounded border border-green-100 font-medium">{node}</span>
|
| 547 |
+
{index < visitedNodes.length - 1 && (
|
| 548 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="mx-1 text-green-400"><path d="M5 12h14"></path><path d="m12 5 7 7-7 7"></path></svg>
|
| 549 |
+
)}
|
| 550 |
+
</div>
|
| 551 |
+
))}
|
| 552 |
+
</div>
|
| 553 |
+
</div>
|
| 554 |
+
|
| 555 |
+
<div className="flex gap-2 mt-2">
|
| 556 |
+
<Button
|
| 557 |
+
onClick={onReset}
|
| 558 |
+
variant="outline"
|
| 559 |
+
size="sm"
|
| 560 |
+
className="bg-white"
|
| 561 |
+
>
|
| 562 |
+
New Game
|
| 563 |
+
</Button>
|
| 564 |
+
</div>
|
| 565 |
+
</div>
|
| 566 |
</div>
|
| 567 |
) : (
|
| 568 |
<div className="bg-red-100 text-red-800 p-4 rounded-md w-full">
|
|
|
|
| 712 |
key={`result-${index}`}
|
| 713 |
className={`p-2 rounded-lg text-xs ${
|
| 714 |
isWon
|
| 715 |
+
? "bg-gradient-to-r from-green-50 to-emerald-50 border border-green-200"
|
| 716 |
: "bg-red-50 border border-red-100"
|
| 717 |
}`}
|
| 718 |
>
|
| 719 |
+
{isWon ? (
|
| 720 |
+
<div className="flex flex-col items-center text-center">
|
| 721 |
+
<div className="mb-2 bg-green-100 p-2 rounded-full">
|
| 722 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="text-green-600"><polyline points="20 6 9 17 4 12"></polyline></svg>
|
| 723 |
+
</div>
|
| 724 |
+
<h3 className="font-bold text-sm text-green-800 mb-1">{message.content}</h3>
|
| 725 |
+
|
| 726 |
+
{message.metadata?.path && (
|
| 727 |
+
<div className="bg-white rounded p-2 my-2 w-full border border-green-100">
|
| 728 |
+
<h4 className="font-medium text-xs text-green-800 mb-1">Path:</h4>
|
| 729 |
+
<div className="flex flex-wrap items-center gap-1 justify-center text-xs">
|
| 730 |
+
{message.metadata.path.map((node, index) => (
|
| 731 |
+
<div key={`result-path-${index}`} className="flex items-center">
|
| 732 |
+
<span className="bg-green-50 px-1.5 py-0.5 rounded border border-green-100 font-medium">{node}</span>
|
| 733 |
+
{index < message.metadata.path.length - 1 && (
|
| 734 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="mx-1 text-green-400"><path d="M5 12h14"></path><path d="m12 5 7 7-7 7"></path></svg>
|
| 735 |
+
)}
|
| 736 |
+
</div>
|
| 737 |
+
))}
|
| 738 |
+
</div>
|
| 739 |
+
</div>
|
| 740 |
+
)}
|
| 741 |
+
</div>
|
| 742 |
+
) : (
|
| 743 |
+
<div>
|
| 744 |
+
<div className="flex items-center gap-1 mb-1 text-xs font-medium text-muted-foreground">
|
| 745 |
+
<Flag className="h-3 w-3" />
|
| 746 |
+
<span>Game Over</span>
|
| 747 |
+
</div>
|
| 748 |
+
<p>{message.content}</p>
|
| 749 |
+
|
| 750 |
+
{message.metadata?.path && (
|
| 751 |
+
<p className="mt-1 text-xs text-muted-foreground">
|
| 752 |
+
Path: {message.metadata.path.join(" → ")}
|
| 753 |
+
</p>
|
| 754 |
+
)}
|
| 755 |
+
</div>
|
| 756 |
+
)}
|
| 757 |
</div>
|
| 758 |
);
|
| 759 |
} else if (message.role === "error") {
|