mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 06:37:32 +02:00
Add final move to battle
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { list } = require('../../util/Util');
|
const { list } = require('../../util/Util');
|
||||||
const choices = ['attack', 'defend', 'special', 'cure', 'run'];
|
const choices = ['attack', 'defend', 'special', 'cure', 'final', 'run'];
|
||||||
|
|
||||||
module.exports = class Battler {
|
module.exports = class Battler {
|
||||||
constructor(battle, user) {
|
constructor(battle, user) {
|
||||||
@@ -14,6 +14,7 @@ module.exports = class Battler {
|
|||||||
|
|
||||||
async chooseAction(msg) {
|
async chooseAction(msg) {
|
||||||
if (this.bot) {
|
if (this.bot) {
|
||||||
|
if (this.canFinal) return 'final';
|
||||||
const botChoices = ['attack', 'attack', 'defend'];
|
const botChoices = ['attack', 'attack', 'defend'];
|
||||||
if (this.canSpecial) botChoices.push('special');
|
if (this.canSpecial) botChoices.push('special');
|
||||||
if (this.canHeal && this.hp < 200) botChoices.push('cure');
|
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);
|
msg.say('You don\'t have enough MP for that!').catch(() => null);
|
||||||
return false;
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -57,14 +62,6 @@ module.exports = class Battler {
|
|||||||
return this.hp;
|
return this.hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
get canHeal() {
|
|
||||||
return this.mp > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
get canSpecial() {
|
|
||||||
return this.mp >= 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
useMP(amount) {
|
useMP(amount) {
|
||||||
this.mp -= amount;
|
this.mp -= amount;
|
||||||
return this.mp;
|
return this.mp;
|
||||||
@@ -80,6 +77,18 @@ module.exports = class Battler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get canHeal() {
|
||||||
|
return this.mp > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
get canSpecial() {
|
||||||
|
return this.mp >= 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
get canFinal() {
|
||||||
|
return this.hp < 100 && this.mp >= 100;
|
||||||
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return this.user.toString();
|
return this.user.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user