0👍
here is a example of the workflow.
new Vue({
el: '#app',
data: {
playerAttackDamage: 0
},
methods: {
statChange(stat, change, statName) {
this[statName] = stat += change // the line to change the state
return 'value to turn order'
},
attackUp() {
const yourTurn = this.statChange(this.playerAttackDamage, 2, 'playerAttackDamage')
this.checkTurnOrder(yourTurn);
},
checkTurnOrder(yourTurn) {
console.log(yourTurn);
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<div id='app'>
<p>player attack: {{ playerAttackDamage }}</p>
<button @click="attackUp">attackUp</button>
</div>
It is not clean, I know, but you can get an idea how to change the state
Source:stackexchange.com