diff --git a/commands/virtual_simulation/shinx.js b/commands/virtual_simulation/shinx.js index b6503a7d..6219105d 100644 --- a/commands/virtual_simulation/shinx.js +++ b/commands/virtual_simulation/shinx.js @@ -459,6 +459,7 @@ export default async (interaction, ephemeral) => { 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 saveBattle(shinxes[p], p === i); diff --git a/database/dbServices/shinx.api.js b/database/dbServices/shinx.api.js index 9587f31b..cb731ccd 100644 --- a/database/dbServices/shinx.api.js +++ b/database/dbServices/shinx.api.js @@ -63,15 +63,11 @@ export async function changeAutoFeed(id, mode) { return shinx.setAutoFeed(mode); }; -export async function addExperience(id, experience) { - let shinx = await getShinx(id, ['user_id', 'experience']); - const res = await shinx.addExperienceAndLevelUp(experience); - if (res.pre != res.post) { - if (hasPassedLevel(res.pre, res.post, 5)) await addEventTrophy(id, 'Bronze Trophy'); - if (hasPassedLevel(res.pre, res.post, 15)) await addEventTrophy(id, 'Silver Trophy'); - if (hasPassedLevel(res.pre, res.post, 30)) await addEventTrophy(id, 'Gold Trophy'); - if (hasPassedLevel(res.pre, res.post, 50)) await addEventTrophy(id, 'Shiny Charm'); - }; +export async function 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'); }; export async function hasEventTrophy(user_id, trophy_id) {