refactor: enhance player data handling to include label and default timestamp for improved tracking

This commit is contained in:
MayaTheShy
2026-02-20 04:29:23 -05:00
parent 460352ec26
commit ddc1b03506

View File

@@ -35,8 +35,15 @@ export const useTurtleStore = create((set, get) => ({
data.turtles.forEach(turtle => {
turtlesMap[turtle.turtleID] = turtle;
});
const playersMap = {};
if (data.players && Array.isArray(data.players)) {
data.players.forEach(player => {
playersMap[player.playerID] = player;
});
}
set({
turtles: turtlesMap,
players: playersMap,
worldBlocks: data.blocks || []
});
} else if (data.type === 'turtle_update') {
@@ -74,7 +81,8 @@ export const useTurtleStore = create((set, get) => ({
[data.playerID]: {
playerID: data.playerID,
position: data.position,
timestamp: data.timestamp
label: data.label || null,
timestamp: data.timestamp || Date.now()
}
}
}));