Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Farming weight #50

Merged
merged 4 commits into from
Aug 28, 2024
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"packageManager": "[email protected]",
"author": "Kathund",
"dependencies": {
"farming-weight": "^0.4.12",
"axios": "^1.7.5",
"node-cache": "^5.1.2",
"prismarine-nbt": "^2.5.0",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

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

7 changes: 6 additions & 1 deletion src/API/getSkyblockMember.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ test('getSkyblockMember', async () => {
expectTypeOf(member.dungeons).toEqualTypeOf<SkyblockMemberDungeons | null>();

expect(member.collections).toBeDefined();
expectTypeOf(member.collections).toEqualTypeOf<object>();
expectTypeOf(member.collections).toEqualTypeOf<Record<string, number>>();

expect(member.purse).toBeDefined();
expectTypeOf(member.purse).toEqualTypeOf<number>();
Expand Down Expand Up @@ -294,6 +294,11 @@ test('getSkyblockMember', async () => {
expectTypeOf(member.getNetworth).toEqualTypeOf<() => Promise<NetworthResult | null>>();
expectTypeOf(member.getNetworth()).toEqualTypeOf<Promise<NetworthResult | null>>();

expect(member.getFarmingWeight()).toBeDefined();
expectTypeOf(member.getFarmingWeight).toEqualTypeOf<() => number>();
expectTypeOf(member.getFarmingWeight()).toEqualTypeOf<number>();
expect(member.getFarmingWeight()).greaterThanOrEqual(0);

expect(member.toString()).toBeDefined();
expect(member.toString()).toBe(member.uuid);
expectTypeOf(member.toString()).toEqualTypeOf<string>();
Expand Down
19 changes: 18 additions & 1 deletion src/structures/SkyBlock/SkyblockMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Constants from '../../utils/Constants';
import SkyblockGarden from './SkyblockGarden';
import SkyblockMuseum from './SkyblockMuseum';
import SkyblockPet from './SkyblockPet';
import { createFarmingWeightCalculator } from 'farming-weight';

export interface SkyblockMemberEquipment {
gauntlet: SkyblockInventoryItem | null;
Expand Down Expand Up @@ -61,7 +62,7 @@ class SkyblockMember {
bestiary: number;
slayer: SkyblockMemberSlayer | null;
dungeons: SkyblockMemberDungeons | null;
collections: object;
collections: Record<string, number>;
purse: number;
stats: SkyblockMemberStats | null;
pets: SkyblockPet[];
Expand All @@ -75,6 +76,7 @@ class SkyblockMember {
getEquipment: () => Promise<SkyblockMemberEquipment>;
getPersonalVault: () => Promise<SkyblockInventoryItem[]>;
getNetworth: () => Promise<NetworthResult | null>;
getFarmingWeight: () => number;
constructor(data: Record<string, any>) {
this.uuid = data.uuid;
this.gameMode = data.gameMode;
Expand Down Expand Up @@ -229,6 +231,21 @@ class SkyblockMember {
return null;
}
};
this.getFarmingWeight = () => {
try {
return createFarmingWeightCalculator({
collection: this.collections,
farmingXp: this.skills.farming.xp,
levelCapUpgrade: this.jacob.perks.farmingLevelCap,
anitaBonusFarmingFortuneLevel: this.jacob.perks.doubleDrops,
minions: data.m.player_data.crafted_generators,
contests: Object.values(this.jacob.contests),
pests: data.m.bestiary.kills
}).getWeightInfo().totalWeight;
} catch {
return 0;
}
};
}

toString(): string {
Expand Down
Loading