-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add enchanting/experimentation data #61
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
Open
tonydawhale
wants to merge
1
commit into
main
Choose a base branch
from
feat/enchanting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import type { Experimentation, SkyBlockProfileMember, SkyblockExperimentTier } from '$types/hypixel'; | ||
| import { EXPERIMENTS } from '$constants'; | ||
| import _ from 'lodash'; | ||
|
|
||
| export function getEnchanting(userProfile: Partial<SkyBlockProfileMember>) { | ||
| if (!userProfile.experimentation) return; | ||
|
|
||
| return { | ||
| unlocked: !!userProfile.experimentation, | ||
| experiments: userProfile.experimentation | ||
| ? Object.fromEntries( | ||
| Object.keys(EXPERIMENTS.games) | ||
| .filter((game) => game in (userProfile.experimentation as Experimentation)) | ||
| .map((game) => { | ||
| const gameConstants = EXPERIMENTS.games[game as keyof typeof EXPERIMENTS.games]; | ||
| const gameData = (userProfile.experimentation as Experimentation)[ | ||
| game as keyof typeof userProfile.experimentation | ||
| ] as Record<string, number>; | ||
|
|
||
| const output = { | ||
| name: gameConstants.name, | ||
| stats: {} as Record<string, number>, | ||
| tiers: {} as Record<number, SkyblockExperimentTier> | ||
| }; | ||
|
|
||
| for (const key in gameData) { | ||
| if (key.startsWith('attempts') || key.startsWith('claims') || key.startsWith('best_score')) { | ||
| const statArray = key.split('_'); | ||
| const tierValue = parseInt(statArray.pop() as string); | ||
| const tier = | ||
| game === 'numbers' ? tierValue + 2 : game === 'simon' ? Math.min(tierValue + 1, 5) : tierValue; | ||
|
|
||
| const tierInfo = _.cloneDeep(EXPERIMENTS.tiers[tier]); | ||
| if (output.tiers[tier as keyof typeof output.tiers] === undefined) output.tiers[tier] = tierInfo; | ||
|
|
||
| const stat = statArray.join('_'); | ||
| Object.assign(output.tiers[tier], { | ||
| [stat]: gameData[key] | ||
| }); | ||
| continue; | ||
| } | ||
| if (key == 'last_attempt' || key == 'last_claimed') { | ||
| if (gameData[key] <= 0) continue; | ||
| output.stats[key] = gameData[key]; | ||
| continue; | ||
| } | ||
| output.stats[key] = gameData[key]; | ||
| } | ||
|
|
||
| return [game, output]; | ||
| }) | ||
| ) | ||
| : undefined | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| export type SkyblockExperimentTier = { | ||
| name: string; | ||
| icon: string; | ||
| attempts?: number; | ||
| claims?: number; | ||
| best_score?: number; | ||
| }; | ||
|
|
||
| export type SkyblockEnchantingData = { | ||
| unlocked: boolean; | ||
| experiments?: Record< | ||
| string, | ||
| { | ||
| name: string; | ||
| stats: { | ||
| last_claimed?: number; | ||
| last_attempt?: number; | ||
| bonus_clicks?: number; | ||
| }; | ||
| tiers: Record<number, SkyblockExperimentTier>; | ||
| } | ||
| >; | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This whole
Object.fromEntries(...)call should be separated into a new function, it's doing way too much to be inlined like this. I know we're kinda doing the same thing elsewhere already, but we should probably be more strict with things like this