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

Fix Event Trophies #849

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions commands/virtual_simulation/shinx.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ export default async (interaction, messageFlags) => {
text += addLine(`${formatName(nicks[h])} won ${exp[0]} exp. points!`);
if (exp[1] > 0) {
text += addLine(`${formatName(nicks[h])} grew to level ${bold(shinxes[h].level)}!`);
shinxApi.addBattleRewards(trainers[h].id, shinxes[h].level);
};
};
for (let p = 0; p < 2; p++) await 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 @@ -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');
Comment on lines -66 to +70
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the other calls of addExperience() fail now that you deleted the function here or will they automatically use the shinx.model.js one?

Shinx.prototype.addExperience = function (experience) {

Is this accounted for?

Also, should addBattleRewards() not be called inside addExperience() so battle rewards are automatically given when experience is gained from any source, instead of needing to call addBattleRewards() every time exp is added?

};

export async function hasEventTrophy(user_id, trophy_id) {
Expand Down
Loading