Add final move to battle

This commit is contained in:
Daniel Odendahl Jr
2018-10-10 15:16:03 +00:00
parent 1201f2e1b6
commit b455469b36
+18 -9
View File
@@ -1,6 +1,6 @@
const { stripIndents } = require('common-tags');
const { list } = require('../../util/Util');
const choices = ['attack', 'defend', 'special', 'cure', 'run'];
const choices = ['attack', 'defend', 'special', 'cure', 'final', 'run'];
module.exports = class Battler {
constructor(battle, user) {
@@ -14,6 +14,7 @@ module.exports = class Battler {
async chooseAction(msg) {
if (this.bot) {
if (this.canFinal) return 'final';
const botChoices = ['attack', 'attack', 'defend'];
if (this.canSpecial) botChoices.push('special');
if (this.canHeal && this.hp < 200) botChoices.push('cure');
@@ -35,6 +36,10 @@ module.exports = class Battler {
msg.say('You don\'t have enough MP for that!').catch(() => null);
return false;
}
if (choice === 'final' && !this.canFinal) {
msg.say('To use your final attack, you must have under 100 HP and over 100 MP.').catch(() => null);
return false;
}
return true;
}
return false;
@@ -57,14 +62,6 @@ module.exports = class Battler {
return this.hp;
}
get canHeal() {
return this.mp > 0;
}
get canSpecial() {
return this.mp >= 50;
}
useMP(amount) {
this.mp -= amount;
return this.mp;
@@ -80,6 +77,18 @@ module.exports = class Battler {
return null;
}
get canHeal() {
return this.mp > 0;
}
get canSpecial() {
return this.mp >= 50;
}
get canFinal() {
return this.hp < 100 && this.mp >= 100;
}
toString() {
return this.user.toString();
}