import { useGame } from '../../contexts/game-context' import Grid from '../board/grid' import Space from '../space/space' import type { GameEntity } from '../../types' export default function Entity ({ entity }: { entity: GameEntity }) { const { clickTarget, allClickable } = useGame() const isClickable = allClickable.has(entity) const attributes = entity.attributes const entityType = attributes.entityType ?? attributes.type switch (entityType) { case 'Grid': return case 'Space': return default: return (
{ if (isClickable) { e.stopPropagation() clickTarget(entity) } }} className={[ 'entity', attributes.player !== undefined && `player-${String(attributes.player)}`, isClickable && 'entity--clickable', ].filter(Boolean).join(' ')} > {entity.rule.displayProperties?.map((property, i) => (
{property}: {String((attributes[property] as string | number | boolean | undefined) ?? '')}
))}
) } }