Disable decline button if not enough money

This commit is contained in:
Lucas Mello 2021-06-28 00:21:54 -03:00
commit df0bf571d0
3 changed files with 16 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"name": "container-viewer",
"version": "1.0.13",
"version": "1.0.14",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",

View file

@ -1,5 +1,5 @@
<template>
<g class="button enabled" @click="$emit('click')">
<g :class="['button', { enabled }]" @click="enabled && $emit('click')">
<rect :width="width" height="30" fill="gainsboro" stroke="black" rx="2" />
<text text-anchor="middle" fill="black" :x="width / 2" y="16">{{ getText() }}</text>
<title>{{ text }}</title>
@ -16,6 +16,9 @@ export default class Button extends Vue {
@Prop()
width?: number;
@Prop({ default: true })
enabled!: boolean;
getText() {
return this.text!.length > 15 ? this.text?.substring(0, 12).concat('...') : this.text;
}

View file

@ -99,7 +99,7 @@
<template v-for="(bidder, i) in G.highestBidders">
<Button :key="bidder" :transform="`translate(140, ${450 + 40 * i})`" :width="130" :text="'Accept ' + getName(bidder)" @click="accept(bidder)" />
</template>
<Button :transform="`translate(140, ${450 + 40 * G.highestBidders.length})`" :width="130" :text="'Decline'" @click="decline()" />
<Button :transform="`translate(140, ${450 + 40 * G.highestBidders.length})`" :width="130" :text="'Decline'" :enabled="canDecline()" @click="decline()" />
</template>
</template>
@ -698,6 +698,16 @@ export default class Game extends Vue {
return !!availableMoves[MoveName.Undo];
}
canDecline() {
if (!this.canMove())
return false;
const currentPlayer = this.G!.players[this.G!.currentPlayer!];
const availableMoves = currentPlayer.availableMoves!;
return !!availableMoves[MoveName.Decline];
}
toggleSound() {
this.soundOn = !this.soundOn;
}