diff --git a/client/src/store/turtleStore.js b/client/src/store/turtleStore.js index 8c04173..c430b45 100644 --- a/client/src/store/turtleStore.js +++ b/client/src/store/turtleStore.js @@ -337,6 +337,165 @@ export const useTurtleStore = create((set, get) => ({ return []; }, + // Rename a turtle + renameTurtle: async (turtleId, name) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/rename`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ name }) + }); + return await response.json(); + } catch (error) { + console.error(' ❌ Error renaming turtle:', error); + return { success: false, error: error.message }; + } + }, + + // Equip left + equipLeft: async (turtleId) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/equip-left`, { method: 'POST' }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Equip right + equipRight: async (turtleId) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/equip-right`, { method: 'POST' }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Select inventory slot + selectSlot: async (turtleId, slot) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/select`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ slot }) + }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Transfer items between slots + transferItems: async (turtleId, fromSlot, toSlot, count) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/transfer`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ fromSlot, toSlot, count }) + }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Sort/compact inventory + sortInventory: async (turtleId) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/sort`, { method: 'POST' }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Connect to adjacent inventory + connectToInventory: async (turtleId, side) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/connect-inventory`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ side }) + }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Drop items + dropItems: async (turtleId, direction = 'front', count) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/drop`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ direction, count }) + }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Suck items + suckItems: async (turtleId, direction = 'front', count) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/suck`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ direction, count }) + }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Update turtle config + updateTurtleConfig: async (turtleId, config) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/config`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(config) + }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Get turtle config + getTurtleConfig: async (turtleId) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/config`); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // Explore (batched 3-direction inspect) + exploreTurtle: async (turtleId) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/explore`, { method: 'POST' }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + + // GPS locate + gpsLocateTurtle: async (turtleId) => { + try { + const response = await fetch(`${API_URL}/turtle/${turtleId}/gps`, { method: 'POST' }); + return await response.json(); + } catch (error) { + return { success: false, error: error.message }; + } + }, + // Helper getters getTurtleArray: () => { return Object.values(get().turtles);