-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: master
Are you sure you want to change the base?
Fix Event Trophies #849
Conversation
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'); |
There was a problem hiding this comment.
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?
@@ -130,6 +130,7 @@ export default async (client, interaction) => { | |||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should battle rewards not be checked on every exp gain instead of every battle?
Unless battling is the only way to get exp forever.
An error currently exists when checking event tropheis. This seems to be because addEventTrophy is circular? Not sure. Could you look into this? NinigiBot/database/dbServices/shinx.api.js Lines 80 to 88 in e338e9c
|
Meow (grr)