makes adding loot working

This commit is contained in:
2019-10-07 15:10:35 +02:00
parent 4f6970c423
commit 70eed30bee
8 changed files with 118 additions and 90 deletions

View File

@@ -56,14 +56,12 @@
</nav>
<main class="section">
<template v-if="isAdding">
<div v-if="playerIsGroup" class="box">
<ItemInput v-if="playerIsGroup"
:source="state.inventory"
@addItem="item => pending_loot.push(item)"
></ItemInput>
<button>Envoyer</button>
</div>
<AddingChest
<Loot v-if="playerIsGroup"
:inventory="state.inventory"
@addItem="item => pending_loot.push(item)"
@confirmAction="addNewLoot"
></Loot>
<AddingChest
:items="playerIsGroup ? pending_loot : state.inventory"
:perms="playerIsGroup ? {} : { canBuy: true }"
@buy="(data) => { switchView('player'); actions.buyItems(data); }">
@@ -89,8 +87,8 @@ import PlayerView from './components/PlayerView.js'
import HeaderBar from './components/HeaderBar.vue'
import Wealth from './components/Wealth.vue'
import Chest from './components/Chest.vue'
import ItemInput from './components/ItemInput.vue'
import { AppStorage } from './AppStorage'
import Loot from './components/Loot.vue'
import { Api, AppStorage } from './AppStorage'
function getCookie(cname) {
var name = cname + "=";
@@ -124,7 +122,7 @@ export default {
'AddingChest': Chest, // Alias to prevent component re-use
Chest,
Wealth,
ItemInput,
Loot,
},
created () {
// Initiate with active player set to value found in cookie
@@ -149,7 +147,16 @@ export default {
}
this.activeView = viewId;
},
switchPlayerChestVisibility () { AppStorage.switchPlayerChestVisibility(); },
switchPlayerChestVisibility () {
AppStorage.switchPlayerChestVisibility();
},
addNewLoot () {
Api.newLoot(this.pending_loot)
.then(_ => {
this.pending_loot = []
this.switchView('group');
});
}
},
computed: {
showPlayerChest () { return this.activeView == 'player' },