From 5aec3df3b30e80153c26e54bd6e1a4130517555e Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Fri, 20 Feb 2026 04:05:06 -0500 Subject: [PATCH] refactor: improve inventory count calculation for TurtleCard component --- client/src/components/ControlPanel.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/components/ControlPanel.jsx b/client/src/components/ControlPanel.jsx index 9745799..30c8327 100644 --- a/client/src/components/ControlPanel.jsx +++ b/client/src/components/ControlPanel.jsx @@ -5,7 +5,9 @@ import './ControlPanel.css'; function TurtleCard({ turtle, isSelected, onSelect }) { const activeState = turtle.state || turtle.mode || 'idle'; const fuel = turtle.fuel === 'unlimited' ? '∞' : (turtle.fuel || '?'); - const inventoryCount = turtle.inventory?.length || 0; + const inventoryCount = Array.isArray(turtle.inventory) + ? turtle.inventory.length + : (turtle.inventory ? Object.keys(turtle.inventory).length : 0); const displayName = turtle.label || `Turtle ${turtle.turtleID}`; const modeColors = {