diff --git a/commands/virtual_simulation/battle.js b/commands/virtual_simulation/battle.js index 660fe47cb..d203da6da 100644 --- a/commands/virtual_simulation/battle.js +++ b/commands/virtual_simulation/battle.js @@ -135,6 +135,7 @@ exports.run = async (client, interaction, logger) => { text += addLine(`**${nicks[h]}** won ${exp[0]} exp. points!`); if (exp[1] > 0) { text += addLine(`**${nicks[h]}** grew to level **${shinxes[h].level}**!`); + shinxApi.addBattleRewards(trainers[h].id, shinxes[h].level); }; }; for (let p = 0; p < 2; p++) await shinxApi.saveBattle(shinxes[p], p === i); diff --git a/database/dbServices/shinx.api.js b/database/dbServices/shinx.api.js index 7491965d4..15e67f2d0 100644 --- a/database/dbServices/shinx.api.js +++ b/database/dbServices/shinx.api.js @@ -46,15 +46,11 @@ module.exports = { let shinx = await this.getShinx(id, ['user_id', 'auto_feed']); return shinx.setAutoFeed(mode); }, - async addExperience(id, experience) { - let shinx = await this.getShinx(id, ['user_id', 'experience']); - const res = await shinx.addExperienceAndLevelUp(experience); - if (res.pre != res.post) { - if (hasPassedLevel(res.pre, res.post, 5)) await this.addEventTrophy(id, 'Bronze Trophy'); - if (hasPassedLevel(res.pre, res.post, 15)) await this.addEventTrophy(id, 'Silver Trophy'); - if (hasPassedLevel(res.pre, res.post, 30)) await this.addEventTrophy(id, 'Gold Trophy'); - if (hasPassedLevel(res.pre, res.post, 50)) await this.addEventTrophy(id, 'Shiny Charm'); - }; + async addBattleRewards(id, level) { + if (level > 5) await this.addEventTrophy(id, 'Bronze Trophy'); + if (level > 15) await this.addEventTrophy(id, 'Silver Trophy'); + if (level > 30) await this.addEventTrophy(id, 'Gold Trophy'); + if (level > 50) await this.addEventTrophy(id, 'Shiny Charm'); }, async hasEventTrophy(user_id, trophy_id) { let user = await this.getUser(user_id, ['user_id']);