diff --git a/lootalot_front/src/App.vue b/lootalot_front/src/App.vue index 1ddfba8..1b31c83 100644 --- a/lootalot_front/src/App.vue +++ b/lootalot_front/src/App.vue @@ -37,7 +37,7 @@ v-show="!playerIsGroup"> Mon coffre
  • - + + {{ playerIsGroup ? 'Nouveau Loot' : 'Acheter' }}
  • @@ -49,7 +49,8 @@

    ItemInput

    + :perms="playerIsGroup ? {} : { canBuy: true }" + @buy="(data) => { switchView('player'); actions.buyItems(data); }"> diff --git a/lootalot_front/src/components/Chest.vue b/lootalot_front/src/components/Chest.vue index 75bfdce..57910d5 100644 --- a/lootalot_front/src/components/Chest.vue +++ b/lootalot_front/src/components/Chest.vue @@ -5,17 +5,20 @@ Objets Valeur -
    -
    -
    - +
    + +
    +
    +
    @@ -26,18 +29,18 @@ {{item.name}} {{ item.base_price }}po - -
    +
    +
    @@ -79,15 +82,39 @@ data () { return { is_selling: false, - is_adding: false, selected_items: [], }; }, + methods: { + buySelectedItems () { + const items = this.items.filter(i => this.selected_items.includes(i.id)); + this.$emit("buy", items); + this.selected_items.length = 0; + }, + sellSelectedItems () { + if (!this.is_selling) { + this.is_selling = true; + } else { + this.is_selling = false; + if (this.selected_items.length > 0) { + const items = this.items.filter(i => this.selected_items.includes(i.id)); + this.$emit("sell", items); + this.selected_items = []; + } + } + }, + }, computed: { - totalSellValue () { + showSelectors () { return !this.perms.canGrab && (this.is_selling || this.perms.canBuy); }, + totalSelectedValue () { return this.items .filter(item => this.selected_items.includes(item.id)) - .map(item => item.base_price / 2) + .map(item => { + if (this.is_selling) { + return item.base_price / 2; + } else { + return item.base_price; + }}) .reduce((total,value) => total + value, 0); }, }, @@ -97,4 +124,7 @@ diff --git a/lootalot_front/src/components/PercentInput.vue b/lootalot_front/src/components/PercentInput.vue index 0900076..83b997f 100644 --- a/lootalot_front/src/components/PercentInput.vue +++ b/lootalot_front/src/components/PercentInput.vue @@ -7,7 +7,7 @@
    - diff --git a/lootalot_front/src/components/PlayerView.js b/lootalot_front/src/components/PlayerView.js index 44de4f7..e36fdf8 100644 --- a/lootalot_front/src/components/PlayerView.js +++ b/lootalot_front/src/components/PlayerView.js @@ -21,6 +21,12 @@ export default { .then(_ => { if (AppStorage.debug) this.notifications.push("Claim withdrawn")}) }, + buyItems(items) { + this.notifications.push(`Would buy ${items.length} items`); + }, + sellItems (items) { + this.notifications.push(`Would sell ${items.length} items`); + }, parseLoot (items) { this.loot = []; items.map(item => { @@ -57,6 +63,8 @@ export default { updateWealth: this.updateWealth, putClaim: this.putClaim, withdrawClaim: this.withdrawClaim, + buyItems: this.buyItems, + sellItems: this.sellItems, } }) } diff --git a/lootalot_front/src/components/Request.vue b/lootalot_front/src/components/Request.vue index f056310..f29cb6c 100644 --- a/lootalot_front/src/components/Request.vue +++ b/lootalot_front/src/components/Request.vue @@ -1,5 +1,5 @@