Starts refactor using a PlayerView renderless component for Player logic
This commit is contained in:
32
lootalot_front/src/components/PlayerView.js
Normal file
32
lootalot_front/src/components/PlayerView.js
Normal 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,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user