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 item distribution on level tresholds #848

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 8 additions & 2 deletions database/dbServices/shinx.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ module.exports = {
},
async switchShininessAndGet(id) {
let shinx = await this.getShinx(id, ['user_id', 'shiny']);
return shinx.switchShininessAndGet();
let user = await this.getUser(id, ['user_id']);
let hasShinyCharm = await this.hasEventTrophy(user.user_id, 'Shiny Charm');
if (hasShinyCharm) {
return shinx.switchShininessAndGet();
} else {
throw new Error('User does not have the Shiny Charm');
}
Comment on lines -43 to +49
Copy link
Owner

Choose a reason for hiding this comment

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

From what I've gathered this bug is not in the functionality for switching between shiny and non-shiny.
This seems to work correctly already.
The bug seems to be in users not receiving a shiny charm, or any level-up rewards, when reaching the required level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will look into it tomorrow if i remember

},
async changeAutoFeed(id, mode) {
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']);
let shinx = await this.getShinx(id, ['user_id', 'experience', 'level']);
Copy link
Owner

@Glazelf Glazelf May 14, 2024

Choose a reason for hiding this comment

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

Level is determined from the EXP count instead of being stored seperately so it doesn't really make sense to pass that in the arguments.
Level is calculated here: https://github.com/Glazelf/NinigiBot/blob/4b1e535883475dbf3293e34b36c4e2660619d76c/util/shinx/getExpFromLevel.js

Also doesn't look like you're using the level anyways so idk.

const res = await shinx.addExperienceAndLevelUp(experience);
if (res.pre != res.post) {
if (hasPassedLevel(res.pre, res.post, 5)) await this.addEventTrophy(id, 'Bronze Trophy');
Expand Down
Loading