moves all api logic inside PlayerView, found weird bug in unpack_gold_value (floating error)

This commit is contained in:
2019-10-18 16:21:00 +02:00
parent 3fce1dc7d0
commit 61c9a4e6d4
7 changed files with 78 additions and 48 deletions

View File

@@ -14,7 +14,7 @@
</span>
</button>
</template>
<button class="button is-primary is-fullwidth"
<button class="button is-primary"
@click="putRequest"
:disabled="isRequested">
<span class="icon is-small">
@@ -27,26 +27,36 @@
<script>
import { AppStorage } from '../AppStorage'
export default {
props: ["item"],
data () {
return AppStorage.state;
props: {
// Id of active player
id: {
type: Number,
required: true,
},
// Map of all claims
claims: {
type: Object,
required: true,
},
// Id of item we are bound to
item: {
type: Number,
required: true,
}
},
computed: {
// Check if item is requested by active player
isRequested () {
const reqs = this.player_claims[this.player_id];
return reqs.includes(this.item);
return this.claims[this.id].includes(this.item);
},
// Check if item is requested by multiple players including active one
isInConflict () {
const reqs = this.player_claims;
const playerId = this.player_id;
var reqByPlayer = false;
var reqByOther = false;
for (var key in reqs) {
const isReq = reqs[key].includes(this.item);
for (var id in this.claims) {
const isReq = this.claims[id].includes(this.item);
if (isReq) {
if (key == playerId) {
if (id == this.id) {
reqByPlayer = true;
} else {
reqByOther = true;