import React from 'react'; import { GridCell } from '../types'; import { Zap, Footprints, Flag, BrickWall } from 'lucide-react'; interface CellProps { cell: GridCell; isPlayerHere: boolean; } export const Cell: React.FC = React.memo(({ cell, isPlayerHere }) => { // Base style let bgColor = 'bg-gray-700'; // Default hidden color let borderColor = 'border-gray-800'; let icon = null; if (cell.revealed) { switch (cell.type) { case 'wall': bgColor = 'bg-slate-800 shadow-inner'; borderColor = 'border-slate-900'; icon =
; break; case 'trap': bgColor = 'bg-red-900/80'; borderColor = 'border-red-950'; icon = ; break; case 'start': bgColor = 'bg-emerald-900/50'; borderColor = 'border-emerald-800'; break; case 'end': bgColor = 'bg-yellow-900/50'; borderColor = 'border-yellow-800'; icon = ; break; case 'safe': bgColor = 'bg-gray-600'; borderColor = 'border-gray-500'; if (cell.steppedOn && !isPlayerHere) { bgColor = 'bg-gray-600/80'; icon = ; } break; } } // Visual highlight for the player const playerOverlay = isPlayerHere ? (
) : null; return (
{/* Icon Wrapper to ensure it doesn't shift layout */}
{icon}
{playerOverlay}
); }); Cell.displayName = 'Cell';