|
|
@ -16,8 +16,9 @@ export default createStore({ |
|
|
|
axios.get( |
|
|
|
axios.get( |
|
|
|
'http://api.luna-development.net/api/player/fetch/'+existingUserUuid |
|
|
|
'http://api.luna-development.net/api/player/fetch/'+existingUserUuid |
|
|
|
).then((response) => { |
|
|
|
).then((response) => { |
|
|
|
if (response.data && response.data.uuid) { |
|
|
|
if (response.data.success) { |
|
|
|
state.player = response.data; |
|
|
|
state.player = response.data.player; |
|
|
|
|
|
|
|
state.inventory = response.data.player.inventory; |
|
|
|
vuex.commit('fetchInventory'); |
|
|
|
vuex.commit('fetchInventory'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
alert('User not found'); |
|
|
|
alert('User not found'); |
|
|
@ -28,15 +29,6 @@ export default createStore({ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
fetchInventory(state) { |
|
|
|
|
|
|
|
axios.get( |
|
|
|
|
|
|
|
'http://api.luna-development.net/api/inventory/fetch/'+state.player.uuid |
|
|
|
|
|
|
|
).then((response) => { |
|
|
|
|
|
|
|
if (response.data.success) { |
|
|
|
|
|
|
|
state.inventory = response.data.inventory; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
createNewPlayer(state, userName) { |
|
|
|
createNewPlayer(state, userName) { |
|
|
|
axios.post('http://api.luna-development.net/api/player/create', { |
|
|
|
axios.post('http://api.luna-development.net/api/player/create', { |
|
|
|
name: userName.trim(), |
|
|
|
name: userName.trim(), |
|
|
@ -44,6 +36,7 @@ export default createStore({ |
|
|
|
}).then((response) => { |
|
|
|
}).then((response) => { |
|
|
|
if (response.data.success) { |
|
|
|
if (response.data.success) { |
|
|
|
state.player = response.data.player; |
|
|
|
state.player = response.data.player; |
|
|
|
|
|
|
|
state.inventory = response.data.player.inventory; |
|
|
|
localStorage.setItem('farmfresh_uuid', response.data.player.uuid); |
|
|
|
localStorage.setItem('farmfresh_uuid', response.data.player.uuid); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|