johnreaver commited on
Commit
ae9b447
Β·
verified Β·
1 Parent(s): c65cae0

Upload components/CapturedPieces.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/CapturedPieces.js +31 -0
components/CapturedPieces.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default function CapturedPieces({ pieces, label }) {
2
+ return (
3
+ <div className="comic-card py-3 px-4 min-w-[140px]">
4
+ <h4 className="text-xs font-bold uppercase text-gray-500 mb-2 text-center">{label}</h4>
5
+ <div className="flex flex-wrap gap-1 justify-center min-h-[30px]">
6
+ {pieces.map((p, i) => (
7
+ <span key={i} className="text-2xl piece-3d opacity-80 hover:opacity-100 hover:scale-125 transition-transform cursor-help" title={getPieceName(p)}>
8
+ {getPieceSymbol(p)}
9
+ </span>
10
+ ))}
11
+ {pieces.length === 0 && <span className="text-xs text-gray-400 italic">None</span>}
12
+ </div>
13
+ </div>
14
+ );
15
+ }
16
+
17
+ const getPieceSymbol = (p) => {
18
+ const map = {
19
+ 'K': 'β™”', 'Q': 'β™•', 'R': 'β™–', 'B': 'β™—', 'N': 'β™˜', 'P': 'β™™',
20
+ 'k': 'β™š', 'q': 'β™›', 'r': 'β™œ', 'b': '♝', 'n': 'β™ž', 'p': 'β™Ÿ',
21
+ };
22
+ return map[p] || '';
23
+ };
24
+
25
+ const getPieceName = (p) => {
26
+ const names = {
27
+ 'P': 'Pawn', 'N': 'Knight', 'B': 'Bishop', 'R': 'Rook', 'Q': 'Queen', 'K': 'King',
28
+ 'p': 'Pawn', 'n': 'Knight', 'b': 'Bishop', 'r': 'Rook', 'q': 'Queen', 'k': 'King',
29
+ };
30
+ return names[p] || p;
31
+ };