Skip to content
Open
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@sveltejs/adapter-auto": "^3.0.1",
"@sveltejs/adapter-node": "^2.0.2",
"@sveltejs/kit": "2.0.6",
"@types/lodash": "^4.14.202",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"autoprefixer": "^10.4.16",
Expand Down Expand Up @@ -50,6 +51,7 @@
"eslint-plugin-deprecation": "^2.0.0",
"flowbite": "^1.8.1",
"flowbite-svelte": "^0.39.3",
"lodash": "^4.17.21",
"mongodb": "^6.3.0",
"redis": "^4.6.12",
"tailwind-merge": "^1.14.0"
Expand Down
11 changes: 10 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions src/constants/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,43 @@ export const ESSENCE = {
head: '/head/67c41930f8ff0f2b0430e169ae5f38e984df1244215705c6f173862844543e9d'
}
};

export const EXPERIMENTS = {
games: {
simon: {
name: 'Chronomatron'
},
numbers: {
name: 'Ultrasequencer'
},
pairings: {
name: 'Superpairs'
}
},
tiers: [
{
name: 'Beginner',
icon: 'INK_SACK:12'
},
{
name: 'High',
icon: 'INK_SACK:10'
},
{
name: 'Grand',
icon: 'INK_SACK:11'
},
{
name: 'Supreme',
icon: 'INK_SACK:14'
},
{
name: 'Transcendent',
icon: 'INK_SACK:1'
},
{
name: 'Metaphysical',
icon: 'INK_SACK:13'
}
]
};
1 change: 1 addition & 0 deletions src/db/mongo/collections.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface StoredProfileMemberData {
currencies?: SkyblockPlayerCurrencies;
collections?: Record<string, number>;
mining?: SkyBlockMiningData;
enchanting?: SkyblockEnchantingData;
unparsed?: Partial<SkyblockProfileMember>;
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export function getStats(profile: SkyBlockProfile, player: HypixelPlayerData, uu
skills: stats.getSkills(userProfile, player, profile.members),
currencies: stats.getCurrencies(userProfile, profile),
slayers: stats.getSlayers(userProfile),
mining: stats.getMining(userProfile, player)
mining: stats.getMining(userProfile, player),
enchanting: stats.getEnchanting(userProfile)
// unparsed: userProfile
};

Expand Down
55 changes: 55 additions & 0 deletions src/lib/stats/enchanting.ts
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(

Copy link
Copy Markdown
Contributor

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

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
};
}
1 change: 1 addition & 0 deletions src/lib/stats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from '$lib/stats/skills';
export * from '$lib/stats/currencies';
export * from '$lib/stats/slayer';
export * from '$lib/stats/mining';
export * from '$lib/stats/enchanting';
1 change: 1 addition & 0 deletions src/types/processed/stats.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './stats/slayer';
export * from './stats/rank';
export * from './stats/inventory';
export * from './stats/mining';
export * from './stats/enchanting';
23 changes: 23 additions & 0 deletions src/types/processed/stats/enchanting.d.ts
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>;
}
>;
};