refactor: improve inventory count calculation for TurtleCard component
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user