commit | author | age
|
4a01d9
|
1 |
function getRandomValue(min, max){ |
CM |
2 |
return Math.floor(Math.random() * (max - min)) + min; |
|
3 |
} |
|
4 |
|
|
5 |
|
14370b
|
6 |
const app = Vue.createApp({ |
4a01d9
|
7 |
data() { |
CM |
8 |
return { |
|
9 |
playerHealth: 100, |
|
10 |
monsterHealth: 100, |
|
11 |
}; |
|
12 |
}, |
|
13 |
computed: {}, |
|
14 |
watch: {}, |
|
15 |
methods: { |
|
16 |
attackMonster() { |
|
17 |
const attackValue = getRandomValue(5,12); |
|
18 |
this.monsterHealth -= attackValue; |
|
19 |
this.attackPlayer(); |
14370b
|
20 |
}, |
4a01d9
|
21 |
attackPlayer(){ |
CM |
22 |
const attackValue = getRandomValue(8,15); |
|
23 |
this.playerHealth -= attackValue; |
|
24 |
}, |
|
25 |
}, |
|
26 |
}); |
|
27 |
|
|
28 |
app.mount("#game"); |