Starts refactor using a PlayerView renderless component for Player logic

This commit is contained in:
2019-07-31 15:11:51 +02:00
parent 2991a88a30
commit fccd9b999b
8 changed files with 139 additions and 143 deletions

View File

@@ -0,0 +1,32 @@
import { AppStorage } from '../AppStorage'
export default {
props: ["id"],
data () { return {}},
methods: {
updateWealth (value) {
AppStorage.updatePlayerWealth(value)
.then(_ => {if (AppStorage.debug) console.log("Wealth updated")})
.catch(e => {if (AppStorage.debug) console.error("wealthUpdate Error", e)})
}
},
computed: {
player () {
if (!AppStorage.state.initiated) {
return { name: "Loading",
id: 0,
cp: '-', sp: '-', gp: '-', pp: '-',
debt: 0 };
} else {
console.log("Update player");
return AppStorage.state.player_list[this.id];
}
}
},
render () {
return this.$scopedSlots.default({
player: this.player,
updateWealth: this.updateWealth,
})
}
}