import React from 'react'; import type { BoardState, Player } from '../types'; import { PixelAvatar, getPlayerPieceType } from '../utils/pixelAvatars'; interface PlayerListProps { boardState: BoardState; selectedPlayer: Player | null; onSelectPlayer: (player: Player) => void; onRemovePlayer: (id: string) => void; onOpenPartyModal?: () => void; onDefeatParty?: (partyId: string) => void; onFightBattle?: (challengerId: string, defenderId: string) => void; } export const PlayerList: React.FC = ({ boardState, selectedPlayer, onSelectPlayer, onRemovePlayer, onOpenPartyModal, onDefeatParty, }) => { const { players, parties = [], turn } = boardState; const currentTurnId = turn.current_player_id; const partyMap = new Map(); parties.forEach((p) => { p.member_ids.forEach((mid) => partyMap.set(mid, p.name)); }); return (
{/* Header */}

Active Bots & Parties

{players.length} Bots
{/* Turn & Round Banner */} {players.length > 0 && (
Round {turn.round_number} Turn #{turn.turn_number}
)} {/* Parties Section */} {parties.length > 0 && (
🛡️ Active Parties ({parties.length})
{parties.map((party) => (
👑 {party.name}
Leader: {party.leader_name} •{' '} {party.member_ids.length} bots • ⚡{party.total_strength}
{onDefeatParty && ( )}
))}
)} {/* Action to form party */} {players.length >= 2 && onOpenPartyModal && (
)} {/* Players List */}
{players.length === 0 ? (
🤖
No players registered yet.
Register a player or spawn a random bot to start taking turns!
) : ( players.map((player) => { const isSelected = selectedPlayer?.id === player.id; const isCurrentTurn = currentTurnId === player.id; const isLeader = player.is_party_leader; const partyName = partyMap.get(player.id); return (
onSelectPlayer(player)} className={`group flex items-center justify-between p-2.5 rounded-xl border transition-all cursor-pointer ${ isCurrentTurn ? 'bg-amber-950/25 border-amber-500/70 shadow-md shadow-amber-500/10' : isSelected ? 'bg-sky-950/40 border-sky-500 shadow-md shadow-sky-500/10' : 'bg-slate-950/60 border-slate-800 hover:border-slate-700 hover:bg-slate-800/40' }`} >
{isLeader && ( 👑 )}
{player.name} 0 ? 'bg-emerald-950 text-emerald-300 border border-emerald-800' : 'bg-slate-800 text-slate-400' }`} > {player.score >= 0 ? `+${player.score}` : player.score} pts
pos: ({player.x}, {player.y}) • Str: ⚡{player.strength || 1} {partyName && ( • {isLeader ? 'Leader' : 'Squad'} )}
); }) )}
{/* Footer Info */}
Coordinate range: [0,0] → [64,64]
); };