fixes Vue reactivity problems, updates REST Api endpoints
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
const API_BASEURL = "http://localhost:8088/api/"
|
||||
const API_ENDPOINT = function (tailString) {
|
||||
return API_BASEURL + tailString;
|
||||
}
|
||||
|
||||
export const Api = {
|
||||
const Api = {
|
||||
fetchPlayerList () {
|
||||
return fetch("http://localhost:8088/players")
|
||||
return fetch(API_ENDPOINT("players"))
|
||||
.then(r => r.json())
|
||||
.catch(e => console.error("Fetch error ", e));
|
||||
},
|
||||
fetchClaims () {
|
||||
return fetch("http://localhost:8088/claims")
|
||||
return fetch(API_ENDPOINT("claims"))
|
||||
.then(r => r.json())
|
||||
.catch(e => console.error("Fetch error ", e));
|
||||
},
|
||||
fetchLoot (playerId) {
|
||||
const url = "http://localhost:8088/loot/" + playerId;
|
||||
return fetch(url)
|
||||
return fetch(API_ENDPOINT(playerId + "/loot"))
|
||||
.then(r => r.json())
|
||||
.catch(e => console.error("Fetch error", e));
|
||||
},
|
||||
@@ -26,7 +30,7 @@ export const Api = {
|
||||
return Promise.resolve(true);
|
||||
},
|
||||
updateWealth (playerId, goldValue) {
|
||||
return fetch("http://localhost:8088/update-wealth/" + playerId + "/" + goldValue)
|
||||
return fetch(API_ENDPOINT(playerId + "/update-wealth/" + goldValue))
|
||||
.then(r => r.json())
|
||||
.catch(e => console.error("Fetch error", e));
|
||||
}
|
||||
@@ -61,9 +65,9 @@ export const AppStorage = {
|
||||
var playerDesc = data[idx];
|
||||
const playerId = Number(playerDesc.id);
|
||||
if (this.debug) console.log("Creates", playerId, playerDesc.name)
|
||||
this.state.player_list[playerId] = playerDesc;
|
||||
this.state.player_loot[playerId] = [];
|
||||
this.state.requests[playerId] = [];
|
||||
Vue.set(this.state.player_list, playerId, playerDesc);
|
||||
Vue.set(this.state.player_loot, playerId, []);
|
||||
Vue.set(this.state.requests, playerId, []);
|
||||
}
|
||||
// Hack for now !!
|
||||
// Fetch all players loot and wait to set initiated to true
|
||||
@@ -92,6 +96,9 @@ export const AppStorage = {
|
||||
switchPlayerChestVisibility () {
|
||||
if (this.debug) console.log('switchPlayerChestVisibility', !this.state.show_player_chest)
|
||||
this.state.show_player_chest = !this.state.show_player_chest
|
||||
},
|
||||
getPlayerLoot (playerId) {
|
||||
|
||||
},
|
||||
updatePlayerWealth (goldValue) {
|
||||
if (this.debug) console.log('updatePlayerWealth', goldValue, this.state.player_id)
|
||||
|
||||
Reference in New Issue
Block a user