dummy impls for requests and conflict resolution

This commit is contained in:
2019-06-14 16:06:03 +02:00
parent dc7a0da95d
commit a058357815

View File

@@ -1,6 +1,6 @@
<template> <template>
<div> <div v-if="!isInConflict">
<button class="button is-primary is-fullwidth" <button class="button is-medium is-primary is-fullwidth"
@click="putRequest" @click="putRequest"
:disabled="isRequested"> :disabled="isRequested">
<span class="icon"> <span class="icon">
@@ -8,6 +8,22 @@
</span> </span>
</button> </button>
</div> </div>
<div class="buttons has-addons is-centered" v-else>
<button class="button is-medium is-success"
@click="cancelRequest"
>
<span class="icon">
<i class="fas fa-hand-peace"></i>
</span>
</button>
<button class="button is-medium is-danger"
@click="hardenRequest"
>
<span class="icon">
<i class="fas fa-dice"></i>
</span>
</button>
</div>
</template> </template>
<script> <script>
@@ -28,13 +44,36 @@
}, },
// Check if item is requested by multiple players including active one // Check if item is requested by multiple players including active one
isInConflict () { isInConflict () {
const reqs = this.state.requests;
const playerId = this.state.player_id;
var reqByPlayer = false;
var reqByOther = false;
for (var key in reqs) {
const isReq = reqs[key].includes(this.item);
if (isReq) {
if (key == playerId) {
reqByPlayer = true;
} else {
reqByOther = true;
}
}
}
return reqByPlayer && reqByOther;
}, },
}, },
methods: { methods: {
// The active player claims the item
putRequest () { putRequest () {
store.putRequest(this.item) store.putRequest(this.item)
}, },
// The active player withdraws his request
cancelRequest () {
},
// The active player insist on his claim
// TODO: Find a simple and fun system to express
// how much each player want an item
hardenRequest () {
}
}, },
} }
</script> </script>