Skip to content

Commit

Permalink
meow (grr)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaidus committed May 15, 2024
1 parent a21c43f commit af2f6ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions commands/virtual_simulation/battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 5 additions & 9 deletions database/dbServices/shinx.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down

0 comments on commit af2f6ce

Please sign in to comment.