moves logic to PlayerView, adds simple notifications when debugging
This commit is contained in:
@@ -24,7 +24,10 @@
|
||||
<strong>{{item.name}}</strong>
|
||||
</td>
|
||||
<td v-if="canGrab">
|
||||
<Request :item="item.id"></Request>
|
||||
<Request :item="item.id"
|
||||
@claim="(data) => $emit('claim', data)"
|
||||
@unclaim="(data) => $emit('unclaim', data)"
|
||||
></Request>
|
||||
</td>
|
||||
<td v-if="canSell">
|
||||
<div class="field is-grouped is-pulled-right" v-show="is_selling">
|
||||
|
||||
@@ -2,13 +2,24 @@ import { AppStorage } from '../AppStorage'
|
||||
|
||||
export default {
|
||||
props: ["id"],
|
||||
data () { return {}},
|
||||
data () { return {
|
||||
notifications: [],
|
||||
}},
|
||||
methods: {
|
||||
updateWealth (value) {
|
||||
AppStorage.updatePlayerWealth(value)
|
||||
.then(_ => {if (AppStorage.debug) console.log("Wealth updated")})
|
||||
.then(_ => {if (AppStorage.debug) this.notifications.push("Wealth updated")})
|
||||
.catch(e => {if (AppStorage.debug) console.error("wealthUpdate Error", e)})
|
||||
}
|
||||
},
|
||||
putClaim (itemId) {
|
||||
AppStorage.putRequest(itemId)
|
||||
.then(_ => { if (AppStorage.debug) this.notifications.push("Claim put")})
|
||||
},
|
||||
withdrawClaim (itemId) {
|
||||
AppStorage.cancelRequest(itemId)
|
||||
.then(_ => { if (AppStorage.debug) this.notifications.push("Claim withdrawn")})
|
||||
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
player () {
|
||||
@@ -26,7 +37,12 @@ export default {
|
||||
render () {
|
||||
return this.$scopedSlots.default({
|
||||
player: this.player,
|
||||
updateWealth: this.updateWealth,
|
||||
notifications: this.notifications,
|
||||
actions: {
|
||||
updateWealth: this.updateWealth,
|
||||
putClaim: this.putClaim,
|
||||
withdrawClaim: this.withdrawClaim,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@
|
||||
methods: {
|
||||
// The active player claims the item
|
||||
putRequest () {
|
||||
AppStorage.putRequest(this.item)
|
||||
this.$emit("claim", this.item);
|
||||
},
|
||||
// The active player withdraws his request
|
||||
cancelRequest () {
|
||||
AppStorage.cancelRequest(this.item)
|
||||
this.$emit("unclaim", this.item);
|
||||
},
|
||||
// The active player insist on his claim
|
||||
// TODO: Find a simple and fun system to express
|
||||
|
||||
Reference in New Issue
Block a user