Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonkxng crune changes #351

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/commands/commandList/battle/WeaponInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,16 +519,23 @@ module.exports = class WeaponInterface {
}

/* Get lowest wp animal */
static getLowestWp(team) {
static getLowestWp(team, { noBuff } = {}) {
let lowest = undefined;
for (let i = 0; i < team.length; i++)
if (team[i].stats.hp[0] > 0)
if (
!lowest ||
lowest.stats.wp[0] / (lowest.stats.wp[1] + lowest.stats.wp[3]) >
team[i].stats.wp[0] / (team[i].stats.wp[1] + team[i].stats.wp[3])
)
for (let i = 0; i < team.length; i++){
if (team[i].stats.hp[0] > 0){
if (noBuff && WeaponInterface.hasBuff(team[i], noBuff)) {
/* blank */
} else if (!lowest) {
lowest = team[i];
} else {
let lowestWp = lowest.stats.wp[0] / (lowest.stats.wp[1] + lowest.stats.wp[3]);
let animalWp = team[i].stats.wp[0] / (team[i].stats.wp[1] + team[i].stats.wp[3]);
if (lowestWp > animalWp) {
lowest = team[i];
}
}
}
}
return lowest;
}

Expand Down
10 changes: 8 additions & 2 deletions src/commands/commandList/battle/weapons/crune.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ module.exports = class CRune extends WeaponInterface {

let logs = new Logs();

let lowest = undefined;
/* Grab lowest hp without buff*/
let lowest = WeaponInterface.getLowestHp(team, { noBuff: this.buffList[0] });
if (!lowest || WeaponInterface.isMaxHp(lowest)) return this.attackPhysical(me, team, enemy);
let lowestHp = WeaponInterface.getLowestHp(team, { noBuff: this.buffList[0] });
/* Check if lowestHp is at maxHp, if so then grab lowest wp */
if (!lowestHp || WeaponInterface.isMaxHp(lowestHp)) let lowestWp = WeaponInterface.getLowestWp(team, { noBuff: this.buffList[0] });
else lowest = lowestHp;
/* Check if lowestWp is at max Wp, if so then attack*/
if (!lowest || !lowestWp || WeaponInterface.isMaxWp(lowestWp) ) return this.attackPhysical(me, team, enemy);
else lowest = lowestWp;

/* Grab buff and bind it to our animal */
let buff = this.getBuffs(me)[0];
Expand Down