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 9 commits into
base: master
Choose a base branch
from
Draft

Fix Event Trophies #849

wants to merge 9 commits into from

Conversation

Skaidus
Copy link
Collaborator

@Skaidus Skaidus commented May 15, 2024

Meow (grr)

@Skaidus Skaidus requested a review from Glazelf May 15, 2024 20:50
@Glazelf Glazelf added the bug Something isn't working label May 15, 2024
@Glazelf Glazelf linked an issue May 15, 2024 that may be closed by this pull request
@Glazelf Glazelf self-assigned this May 15, 2024
database/dbServices/shinx.api.js Outdated Show resolved Hide resolved
Comment on lines -58 to +62
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');
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?

@@ -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);
Copy link
Owner

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.

@Glazelf
Copy link
Owner

Glazelf commented Jun 5, 2024

An error currently exists when checking event tropheis. This seems to be because addEventTrophy is circular? Not sure. Could you look into this?

export async function addEventTrophy(user_id, trophy_id) {
const { EventTrophy } = await userdataModel(userdata);
let user = await getUser(user_id, ['user_id']);
let trophy_id_t = trophy_id.toLowerCase();
const trophy = await EventTrophy.findOne(
{ attributes: ['trophy_id'], where: where(fn('lower', col('trophy_id')), trophy_id_t) }
);
if (!(await user.hasEventTrophy(trophy))) await user.addEventTrophy(trophy);
};

mintty_0vNpUkVbxz

@Glazelf Glazelf changed the title Fixed Battle Rewards Fix Event Trophies Jun 5, 2024
@Glazelf Glazelf marked this pull request as draft July 12, 2024 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shiny Charm not granted after reaching level 50
2 participants