moves logic to PlayerView, adds simple notifications when debugging

This commit is contained in:
2019-07-31 15:37:35 +02:00
parent e07b236313
commit dae7633c11
5 changed files with 35 additions and 12 deletions

View File

@@ -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,
}
})
}
}