adds a working inventory

This commit is contained in:
2019-08-05 15:41:41 +02:00
parent 894f5f8200
commit 10d157a9af
6 changed files with 2273 additions and 4 deletions

View File

@@ -48,7 +48,7 @@
<template v-if="isAdding">
<h2 v-show="playerIsGroup">ItemInput</h2>
<AddingChest
:items="playerIsGroup ? [] : shopInventory"
:items="playerIsGroup ? [] : state.inventory"
:perms="playerIsGroup ? {} : { canBuy: true }"
@buy="(data) => { switchView('player'); actions.buyItems(data); }">
</AddingChest>

View File

@@ -21,6 +21,10 @@ export const Api = {
return fetch(API_ENDPOINT("players/all"))
.then(r => r.json())
},
fetchInventory () {
return fetch(API_ENDPOINT("items"))
.then(r => r.json())
},
fetchClaims () {
return fetch(API_ENDPOINT("claims"))
.then(r => r.json())
@@ -51,6 +55,7 @@ export const AppStorage = {
player_list: {},
group_loot: [],
player_claims: {},
inventory: [],
initiated: false,
show_player_chest: false,
},
@@ -63,13 +68,15 @@ export const AppStorage = {
.all([
Api.fetchPlayerList(),
Api.fetchClaims(),
Api.fetchInventory(),
Api.fetchLoot(0)
])
.then(data => {
const [players, claims, group_loot] = data;
const [players, claims, inventory, group_loot] = data;
this.__initPlayerList(players);
this.__initClaimsStore(claims);
Vue.set(this.state, 'group_loot', group_loot);
Vue.set(this.state, 'inventory', inventory);
})
.then(_ => this.state.initiated = true)
.catch(e => { alert(e); this.state.initiated = false });

View File

@@ -15,7 +15,9 @@
<PercentInput v-show="is_selling"></PercentInput>
</div>
<div v-else-if="perms.canBuy">
<button class="button is-danger is-fullwidth" @click="buySelectedItems">Acheter</button>
<button class="button is-danger is-fullwidth"
:disabled="selected_items.length == 0"
@click="buySelectedItems">Acheter</button>
</div>
<div v-else-if="perms.canGrab">
<button class="button is-static is-fullwidth">Demander</button>