cleanup refactor a bit
This commit is contained in:
parent
1605e37c6d
commit
c4d5b97bb1
@ -32,24 +32,24 @@ var app = new Vue({
|
||||
},
|
||||
playerAttack(){
|
||||
console.log("player Attack");
|
||||
var dmg = this.getRandomInt(1, 10);
|
||||
var log = {attacker: 'player', dmg: dmg}
|
||||
var dmg = this.getRandomInt(3, 10);
|
||||
this.mHP -= dmg;
|
||||
this.logs.unshift(log);
|
||||
this.logs.unshift({isPlayer: true, text: 'Player hits monster for ' + dmg});
|
||||
this.monsterAttack();
|
||||
},
|
||||
specialAttack(){
|
||||
console.log("special Attack");
|
||||
var dmg = this.getRandomInt(1, 20);
|
||||
var log = {attacker: 'player', dmg: dmg}
|
||||
var dmg = this.getRandomInt(10, 20);
|
||||
this.mHP -= dmg;
|
||||
this.logs.unshift(log);
|
||||
this.logs.unshift({isPlayer: true, text: 'Player hits monster hard for ' + dmg});
|
||||
this.monsterAttack();
|
||||
},
|
||||
heal(){
|
||||
console.log("heal");
|
||||
var hp = this.getRandomInt(1, 10);
|
||||
this.pHP += hp;
|
||||
var hp = 10
|
||||
this.pHP = Math.min(100, this.pHP + 10 );
|
||||
var log =
|
||||
this.logs.unshift({isPlayer: true, text: 'Player heals for 10'});
|
||||
this.monsterAttack();
|
||||
},
|
||||
giveUp(){
|
||||
@ -58,8 +58,8 @@ var app = new Vue({
|
||||
},
|
||||
monsterAttack(){
|
||||
console.log("attacked");
|
||||
var dmg = this.getRandomInt(1, 10);
|
||||
var log = { attacker: 'monster', dmg: dmg}
|
||||
var dmg = this.getRandomInt(5, 12);
|
||||
var log = { isPlayer: false, text: 'monster hits player for ' + dmg}
|
||||
this.pHP -= dmg;
|
||||
this.logs.unshift(log);
|
||||
},
|
||||
|
@ -42,18 +42,9 @@
|
||||
<section class="row log">
|
||||
<div class="small-12 columns">
|
||||
<ul>
|
||||
<template v-for="log in logs">
|
||||
<template v-if="log.attacker == 'player'">
|
||||
<li class="player-turn">
|
||||
player hits monster for {{log.dmg}} damage.
|
||||
<li v-for="log in logs" :class="[{'player-turn': log.isPlayer, 'monster-turn': !log.isPlayer}]">
|
||||
{{log.text}}
|
||||
</li>
|
||||
</template>
|
||||
<template v-else>
|
||||
<li class="monster-turn">
|
||||
monster hits player for {{log.dmg}} damage.
|
||||
</li>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user