Skip to content

Commit

Permalink
Added Foul Fish and Knowledge
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBThai committed Sep 25, 2023
1 parent 4a3ad3a commit 97f2c37
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 30 deletions.
24 changes: 6 additions & 18 deletions src/commands/commandList/admin/addAllWeapons.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

const CommandInterface = require('../../CommandInterface.js');
const WeaponInterface = require('../battle/WeaponInterface.js');
const weaponUtil = require('../battle/util/weaponUtil.js');

module.exports = new CommandInterface({
alias: ['addallweapons', 'aaw'],
Expand Down Expand Up @@ -60,7 +59,7 @@ module.exports = new CommandInterface({

const allWeapons = getAllWeapons();

addMissingWeapons.bind(this)(formattedWeapons, allWeapons, stat, uid);
addMissingWeapons.bind(this)(formattedWeapons, allWeapons, stat);
},
});

Expand Down Expand Up @@ -96,12 +95,12 @@ function getAllPassives(count, passives) {
return result;
}

async function addMissingWeapons(existingWeapons, allWeapons, stat, uid) {
async function addMissingWeapons(existingWeapons, allWeapons, stat) {
for (let allWid in allWeapons) {
let allPassives = allWeapons[allWid];
if (allPassives.length === 0) {
if (!existingWeapons[allWid]) {
await addWeapon.bind(this)(allWid, [], stat, uid);
await addWeapon.bind(this)(allWid, [], stat);
}
} else {
let existingPassives =
Expand All @@ -121,31 +120,20 @@ async function addMissingWeapons(existingWeapons, allWeapons, stat, uid) {
passives = passives.map((passive) => {
return parseInt(passive);
});
await addWeapon.bind(this)(allWid, passives, stat, uid);
await addWeapon.bind(this)(allWid, passives, stat);
}
}
}
}
}

async function addWeapon(wid, passives, stat, uid) {
async function addWeapon(wid, passives, stat) {
console.log(`Adding weapon ${wid}: ${passives}`);
const weapon = new WeaponInterface.weapons[wid](null, null, null, {
passives,
statOverride: stat,
});
const sql = weaponUtil.toSql(uid, weapon);

let result = await this.query(sql.weapon);
let uwid = result.insertId;
if (!uwid) {
this.errorMsg(', Uh oh. Something went wrong! The weapon passive could not be applied');
console.error('Unable to add weapon passive to: ' + uwid);
} else if (passives.length) {
let uwidList = [];
for (let i = 0; i < passives.length; i++) uwidList.push(uwid);
await this.query(sql.passive, uwidList);
}
await weapon.save(this.msg.author.id);
await delay(500);
}

Expand Down
31 changes: 31 additions & 0 deletions src/commands/commandList/battle/BuffInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
/* eslint-disable no-unused-vars */
const Tags = require('./util/tags.js');
const Logs = require('./util/logUtil.js');
const WeaponInterface = require('./WeaponInterface.js');

module.exports = class BuffInterface {
Expand Down Expand Up @@ -69,6 +70,36 @@ module.exports = class BuffInterface {
return stats;
}

attemptBind(animal, duration, tags) {
if (!(tags instanceof Tags)) {
tags = new Tags({
me: tags.me,
allies: tags.allies,
enemies: tags.enemies,
});
}

let logs = new Logs();
let preLogs = new Logs();
let dontBind = false;

for (let i in animal.buffs) {
const preBindResult = animal.buffs[i].preBind(animal, duration, tags, this) || {};
dontBind = dontBind || preBindResult.dontBind;
preLogs.push(preBindResult.logs);
}

if (!dontBind) {
logs.push(this.bind(animal, duration, tags));
}

logs.push(preLogs);
return logs;
}

/* before buff is binded */
preBind(animal, duration, tags) {}

/* Bind this buff to an animal */
bind(animal, duration, tags) {
if (!(tags instanceof Tags)) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/PassiveInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = class PassiveInterface {
count += ranks[i];
if (quality <= count) return this.emojis[i];
}
return this.emojis[0];
return this.emojis[6];
}

toStats(qualities) {
Expand Down
12 changes: 12 additions & 0 deletions src/commands/commandList/battle/WeaponInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,18 @@ module.exports = class WeaponInterface {
static setWeaponUtil(util) {
weaponUtil = util;
}

getBonusXPPassive() {
let bonus = 0;
for (let i in this.passives) {
const passive = this.passives[i];
// Knowledge passive
if (passive.id === 21) {
bonus += passive.stats[0] / 100;
}
}
return bonus;
}
};

const passiveDir = requireDir('./passives');
Expand Down
4 changes: 2 additions & 2 deletions src/commands/commandList/battle/buffs/Flame.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ module.exports = class Flame extends BuffInterface {
if (animal.buffs[i].id == this.id && !animal.buffs[i].markedForDeath) {
animal.buffs[i].markedForDeath = true;
let damage = WeaponInterface.getDamage(this.from.stats.mag, this.stats[1] / 100);
tags.add('flame', animal);
const tagsCopy = tags.copyAdd('flame', animal);
damage = WeaponInterface.inflictDamage(
this.from,
animal,
damage,
WeaponInterface.MAGICAL,
tags
tagsCopy
);
logs.push(
`[FLAME] Exploded and damaged ${animal.nickname} for ${damage.amount} HP`,
Expand Down
49 changes: 49 additions & 0 deletions src/commands/commandList/battle/buffs/Stinky.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* OwO Bot for Discord
* Copyright (C) 2023 Christopher Thai
* This software is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
* For more information, see README.md and LICENSE
*/

const BuffInterface = require('../BuffInterface.js');
const WeaponInterface = require('../WeaponInterface.js');
const Logs = require('../util/logUtil.js');

module.exports = class Stinky extends BuffInterface {
init() {
this.id = 12;
this.name = 'Stinky';
this.debuff = true;
this.emoji = '<:stinky:1154636430937698364>';
this.statDesc = `Prevents any future buffs *AND* debuffs to be applied to this animal. On success, deal **?%** ${WeaponInterface.magEmoji}MAG to the animal.`;
this.qualityList = [[20, 50]];
}

// Override
preBind(animal, duration, tags, buffToAdd) {
if (tags.has('stinky', this.from)) return;

let logs = new Logs();

let damage = WeaponInterface.getDamage(this.from.stats.mag, this.stats[0] / 100);
const tagsCopy = tags.copyAdd('stinky', this.from);
damage = WeaponInterface.inflictDamage(
this.from,
animal,
damage,
WeaponInterface.MAGICAL,
tagsCopy
);
logs.push(
`[STINK] Prevented ${buffToAdd.name} ${buffToAdd.debuff ? 'de' : ''}buff and damaged ${
animal.nickname
} for ${damage.amount} HP`,
damage.logs
);

return {
logs: logs,
dontBind: true,
};
}
};
28 changes: 28 additions & 0 deletions src/commands/commandList/battle/passives/Knowledge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* OwO Bot for Discord
* Copyright (C) 2023 Christopher Thai
* This software is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
* For more information, see README.md and LICENSE
*/

const PassiveInterface = require('../PassiveInterface.js');

module.exports = class Snail extends PassiveInterface {
init() {
this.id = 21;
this.name = 'Knowledge';
this.basicDesc = '';
this.emojis = [
'<:ckno:1155427304663691294>',
'<:ukno:1155427316000886794>',
'<:rkno:1155427313857605652>',
'<:ekno:1155427306437873848>',
'<:mkno:1155427312234418236>',
'<:lkno:1155427310355353610>',
'<:fkno:1155427308480503808>',
];
this.statDesc =
'This passive does not do anything in battle. However, it will give this animal **?%** extra xp after each battle.';
this.qualityList = [[5, 15]];
}
};
1 change: 1 addition & 0 deletions src/commands/commandList/battle/util/teamUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ exports.giveXP = async function (p, team, xp) {
let lvl = team.team[i].stats.lvl;
if (lvl < highestLvl) mult = 2 + (highestLvl - lvl) / 10;
if (mult > 10) mult = 10;
mult += team.team[i].weapon?.getBonusXPPassive() || 0;
cases += ` WHEN animal.pid = ${team.team[i].pid} THEN ${Math.round(total * mult)}`;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/weapons/CelebrationRune.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = class CRune extends WeaponInterface {

/* Grab buff and bind it to our animal */
let buff = this.getBuffs(me)[0];
let buffLogs = buff.bind(lowest, 3, {
let buffLogs = buff.attemptBind(lowest, 3, {
me: me,
allies: team,
enemies: enemy,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/weapons/CullingScythe.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = class CullingScythe extends WeaponInterface {
enemies: enemy,
});
let buff = this.getBuffs(me)[0];
let buffLogs = buff.bind(attacking, 2, {
let buffLogs = buff.attemptBind(attacking, 2, {
me,
allies: team,
enemies: enemy,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/weapons/FlameStaff.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = class FStaff extends WeaponInterface {
enemies: enemy,
});
let buff = this.getBuffs(me)[0];
let buffLogs = buff.bind(attacking, 3, {
let buffLogs = buff.attemptBind(attacking, 3, {
me,
allies: team,
enemies: enemy,
Expand Down
89 changes: 89 additions & 0 deletions src/commands/commandList/battle/weapons/FoulFish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* OwO Bot for Discord
* Copyright (C) 2023 Christopher Thai
* This software is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
* For more information, see README.md and LICENSE
*/

const WeaponInterface = require('../WeaponInterface.js');
const Logs = require('../util/logUtil.js');

module.exports = class FoulFish extends WeaponInterface {
init() {
this.id = 21;
this.name = 'Foul Fish';
this.basicDesc = '';
this.emojis = [
'<:cffish:1154635938270564403>',
'<:uffish:1154635970637987841>',
'<:rffish:1154635969518129172>',
'<:effish:1154635940535472198>',
'<:mffish:1154635947984552076>',
'<:lffish:1154635946571079770>',
'<:fffish:1154635942397747211>',
];
this.pristineEmojis = [
'<:pcffish:1154635949305778196>',
'<:puffish:1154635967907495946>',
'<:prffish:1154635966007496784>',
'<:peffish:1154635951386153040>',
'<:pmffish:1154635964577234974>',
'<:plffish:1154635961284710410>',
'<:pfffish:1154635953051287642>',
];
this.defaultEmoji = '<:ffish:1154635943685394433>';
this.statDesc = `Deal **?%** of your ${WeaponInterface.strEmoji}STR to a random enemy and apply **Stinky** for 2 turns.`;
this.availablePassives = 'all';
this.passiveCount = 1;
this.qualityList = [[50, 80]];
this.manaRange = [280, 180];
this.buffList = [12];
}

attackWeapon(me, team, enemy) {
if (me.stats.hp[0] <= 0) return;
/* No mana */
if (me.stats.wp[0] < this.manaCost) return this.attackPhysical(me, team, enemy);

let logs = new Logs();

/* Grab an enemy that I'm attacking */
let attacking = WeaponInterface.getAttacking(me, team, enemy);
if (!attacking) return;

/* deplete weapon points*/
let mana = WeaponInterface.useMana(me, this.manaCost, me, {
me,
allies: team,
enemies: enemy,
});
let manaLogs = new Logs();
manaLogs.push(`[FFISH] ${me.nickname} used ${mana.amount} WP`, mana.logs);

/* Calculate damage */
let damage = WeaponInterface.getDamage(me.stats.att, this.stats[0] / 100);

/* Deal damage */
damage = WeaponInterface.inflictDamage(me, attacking, damage, WeaponInterface.PHYSICAL, {
me,
allies: team,
enemies: enemy,
});
let buff = this.getBuffs(me)[0];
let buffLogs = buff.attemptBind(attacking, 2, {
me,
allies: team,
enemies: enemy,
});

logs.push(
`[FFISH] ${me.nickname} damaged ${attacking.nickname} for ${damage.amount} HP and applied Stinky`,
damage.logs
);
logs.addSubLogs(buffLogs);

logs.addSubLogs(manaLogs);

return logs;
}
};
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/weapons/GlacialAxe.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = class GlacialAxe extends WeaponInterface {
enemies: enemy,
});
let buff = this.getBuffs(me)[0];
let buffLogs = buff.bind(attacking, 2, {
let buffLogs = buff.attemptBind(attacking, 2, {
me,
allies: team,
enemies: enemy,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/weapons/LeechScythe.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = class LeechingScythe extends WeaponInterface {
if (attacking.buffs.findIndex((buff) => buff.id === this.buffList[0]) < 0) {
appliedLeech = true;
let buff = this.getBuffs(me)[0];
buffLogs = buff.bind(attacking, 3, {
buffLogs = buff.attemptBind(attacking, 3, {
me,
allies: team,
enemies: enemy,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/weapons/PoisonDagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = class PDagger extends WeaponInterface {
enemies: enemy,
});
let buff = this.getBuffs(me)[0];
buff.bind(attacking, 3, { me, allies: team, enemies: enemy });
buff.attemptBind(attacking, 3, { me, allies: team, enemies: enemy });
logs.push(
`[PDAG] ${me.nickname} damaged ${attacking.nickname} for ${damage.amount} HP and applied poison`,
damage.logs
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/weapons/Shield.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = class Shield extends WeaponInterface {

/* Grab buff and bind it to our animal */
let buff = this.getBuffs(animal)[0];
let buffLogs = buff.bind(animal, 2, {
let buffLogs = buff.attemptBind(animal, 2, {
me: animal,
allies: ally,
enemies: enemy,
Expand Down
Loading

0 comments on commit 97f2c37

Please sign in to comment.