basic impl of players list and loot api in frontend
This commit is contained in:
@@ -6,14 +6,9 @@ const PLAYER_LIST = [
|
||||
{id: 3, name: "Fefi", wealth: [0,0,0,0], debt: 0},
|
||||
];
|
||||
|
||||
const fetchPlayerList = function () {
|
||||
fetch("http://localhost:8088/players")
|
||||
.then(r => r.json())
|
||||
.then(r => console.log(r));
|
||||
};
|
||||
|
||||
const fetchRequests = function () {
|
||||
|
||||
const __fetchPlayerList = function() {
|
||||
return fetch("http://localhost:8088/players")
|
||||
.then(r => r.json())
|
||||
};
|
||||
|
||||
export const AppStorage = {
|
||||
@@ -27,12 +22,23 @@ export const AppStorage = {
|
||||
// Initiate the state
|
||||
initStorage (playerId) {
|
||||
if (this.debug) console.log('Initiate with player : ', playerId)
|
||||
fetchPlayerList();
|
||||
this.state.player_id = playerId;
|
||||
for (var idx in PLAYER_LIST) {
|
||||
var player = PLAYER_LIST[idx];
|
||||
this.state.player_list.push(player);
|
||||
this.state.requests[player.id] = [];
|
||||
return Promise.all([
|
||||
fetch("http://localhost:8088/players")
|
||||
.then(r => r.json()),
|
||||
])
|
||||
.then(data => {
|
||||
console.log("initiate ", data);
|
||||
this.initPlayerList(data[0]);
|
||||
})
|
||||
.catch(e => console.log("Fetch error ", e));
|
||||
|
||||
},
|
||||
initPlayerList(data) {
|
||||
for (var idx in data) {
|
||||
var p = data[idx];
|
||||
this.state.player_list.push(p);
|
||||
this.state.requests[p.id] = [5,];
|
||||
}
|
||||
},
|
||||
// Player actions
|
||||
|
||||
Reference in New Issue
Block a user