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 |
- $emit('claim', data)"
@unclaim="(data) => $emit('unclaim', data)">
-
+
@@ -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 @@
- |