Skip to content

Commit

Permalink
11.3.5 (#64)
Browse files Browse the repository at this point in the history
* Feat/dungeons completions (Hypixel-API-Reborn/Hypixel-API-Reborn/#590)

* Feat/kuudra (Hypixel-API-Reborn/Hypixel-API-reborn/#589)

* add garden to SkyblockProfile (Hypixel-API-Reborn/Hypixel-API-Reborn/#591)

* Government Minister Info

* Relase 11.3.3

* Fix spelling (Hypixel-API-Reborn/Hypixel-API-Reborn/#596)

* Fix build

* Update dungeons

* Update Crimson Isle

* fix total (Hypixel-API-Reborn/Hypixel-API-Reborn/#599)

* fix for when no garden is available for this profile (fix crash) (Hypixel-API-Reborn/Hypixel-API-Reborn/#600)

* SkyblockMember HOTM Updatew

* Release 11.3.4

* popper -> pooper

* feat(WoolGames): Move WoolWars into WoolGames

* Release 11.3.5
  • Loading branch information
Kathund authored Sep 5, 2024
1 parent c2d09e7 commit f8ecb41
Show file tree
Hide file tree
Showing 13 changed files with 585 additions and 209 deletions.
10 changes: 5 additions & 5 deletions src/API/getPlayer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import UHC from '../structures/MiniGames/UHC';
import VampireZ from '../structures/MiniGames/VampireZ';
import Walls from '../structures/MiniGames/Walls';
import Warlords from '../structures/MiniGames/Warlords';
import WoolWars from '../structures/MiniGames/WoolWars';
import WoolGames from '../structures/MiniGames/WoolGames';
import { expect, expectTypeOf, test } from 'vitest';

test('No Player Input', () => {
Expand Down Expand Up @@ -476,10 +476,10 @@ test('getPlayer', async () => {
if (null !== data.stats.warlords) {
expect(data.stats.warlords).toBeInstanceOf(Warlords);
}
expect(data.stats.woolwars).toBeDefined();
expectTypeOf(data.stats.woolwars).toEqualTypeOf<WoolWars | null>();
if (null !== data.stats.woolwars) {
expect(data.stats.woolwars).toBeInstanceOf(WoolWars);
expect(data.stats.woolgames).toBeDefined();
expectTypeOf(data.stats.woolgames).toEqualTypeOf<WoolGames | null>();
if (null !== data.stats.woolgames) {
expect(data.stats.woolgames).toBeInstanceOf(WoolGames);
}
}
expect(data.userLanguage).toBeDefined();
Expand Down
2 changes: 1 addition & 1 deletion src/API/getSkyblockGovernment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('getSkyblockGovernment', async () => {
expectTypeOf(candidate.keyBenefit).toEqualTypeOf<string>();

expect(candidate.perks).toBeDefined();
expectTypeOf(candidate.perks).toEqualTypeOf<Perk[]>();
expectTypeOf(candidate.perks).toEqualTypeOf<Perk[] | null>();

expect(candidate.isMayor).toBeDefined();
expectTypeOf(candidate.isMayor).toEqualTypeOf<boolean>();
Expand Down
8 changes: 4 additions & 4 deletions src/API/getSkyblockMember.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { NetworthResult } from 'skyhelper-networth';
import {
SkyblockMemberChocolateFactoryData,
SkyblockMemberDungeons,
SkyblockMemberHOTM,
SkyblockMemberJacobData,
SkyblockMemberSkills,
SkyblockMemberSlayer,
SkyblockMemberStats,
SkyblockMemberTrophyFishRank,
SkyblockRarity,
SkyblockSkillLevel
SkyblockRarity
} from '../utils/SkyblockUtils';
import { expect, expectTypeOf, test } from 'vitest';

Expand Down Expand Up @@ -94,7 +94,7 @@ test('getSkyblockMember', async () => {
expectTypeOf(member.level).toEqualTypeOf<number>();

expect(member.hotm).toBeDefined();
expectTypeOf(member.hotm).toEqualTypeOf<SkyblockSkillLevel>();
expectTypeOf(member.hotm).toEqualTypeOf<SkyblockMemberHOTM>();

expect(member.trophyFish).toBeDefined();
expectTypeOf(member.trophyFish).toEqualTypeOf<SkyblockMemberTrophyFishRank>();
Expand All @@ -118,7 +118,7 @@ test('getSkyblockMember', async () => {
expectTypeOf(member.slayer).toEqualTypeOf<SkyblockMemberSlayer | null>();

expect(member.dungeons).toBeDefined();
expectTypeOf(member.dungeons).toEqualTypeOf<SkyblockMemberDungeons | null>();
expectTypeOf(member.dungeons).toEqualTypeOf<SkyblockMemberDungeons>();

expect(member.collections).toBeDefined();
expectTypeOf(member.collections).toEqualTypeOf<Record<string, number>>();
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export * from './structures/MiniGames/UHC';
export * from './structures/MiniGames/VampireZ';
export * from './structures/MiniGames/Walls';
export * from './structures/MiniGames/Warlords';
export * from './structures/MiniGames/WoolWars';
export * from './structures/MiniGames/WoolGames';
export * from './structures/Pet';
export * from './structures/Pets';
export * from './structures/Player';
Expand Down
37 changes: 3 additions & 34 deletions src/structures/MiniGames/Arcade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,6 @@ export class BountyHunters {
}
}

export class CaptureTheWool {
wins: number;
losses: number;
WLR: number;
draws: number;
kills: number;
deaths: number;
KDR: number;
assists: number;
woolPickedUp: number;
woolCaptured: number;
fastestWin: number;
longestGame: number;
constructor(data: Record<string, any>) {
this.wins = data.woolhunt_participated_wins || 0;
this.losses = data.woolhunt_participated_losses || 0;
this.WLR = divide(this.wins, this.losses);
this.draws = data.woolhunt_participated_draws || 0;
this.kills = data.woolhunt_kills || 0;
this.deaths = data.woolhunt_deaths || 0;
this.KDR = divide(this.kills, this.deaths);
this.assists = data.woolhunt_assists || 0;
this.woolPickedUp = data.woolhunt_wools_stolen || 0;
this.woolCaptured = data.woolhunt_wools_captured || 0;
this.fastestWin = data.woolhunt_fastest_win || 0;
this.longestGame = data.woolhunt_longest_game || 0;
}
}

export class DragonWars {
wins: number;
kills: number;
Expand Down Expand Up @@ -250,7 +221,7 @@ export class GalaxyWars {
}
}

export class PartyPopper {
export class PartyPooper {
winsAsSeeker: number;
winsAsHider: number;
wins: number;
Expand All @@ -273,12 +244,12 @@ export class PropHunt {
}

export class HideAndSeek {
partyPopper: PartyPopper;
partyPooper: PartyPooper;
propHunt: PropHunt;
winsAsSeeker: number;
winsAsHider: number;
constructor(data: Record<string, any>) {
this.partyPopper = new PartyPopper(data);
this.partyPooper = new PartyPooper(data);
this.propHunt = new PropHunt(data);
this.winsAsSeeker = data.seeker_wins_hide_and_seek || 0;
this.winsAsHider = data.hider_wins_hide_and_seek || 0;
Expand Down Expand Up @@ -416,7 +387,6 @@ class Arcade {
flashDisabled: boolean;
blockingDead: BlockingDead;
bountyHunters: BountyHunters;
captureTheWool: CaptureTheWool;
dragonWars: DragonWars;
dropper: Dropper;
enderSpleef: EnderSpleef;
Expand All @@ -439,7 +409,6 @@ class Arcade {
this.flashDisabled = !data.flash;
this.blockingDead = new BlockingDead(data);
this.bountyHunters = new BountyHunters(data);
this.captureTheWool = new CaptureTheWool(data);
this.dragonWars = new DragonWars(data);
this.dropper = new Dropper(data.dropper);
this.enderSpleef = new EnderSpleef(data);
Expand Down
177 changes: 177 additions & 0 deletions src/structures/MiniGames/WoolGames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import divide from '../../utils/divide';

export interface WoolGamesPrivateGameConfig {
one_hit_one_kill: boolean;
rainbow_wool: 'Enabled' | 'Disabled';
health_buff: string;
game_speed: string;
speed: string;
no_class: 'Enabled' | 'Disabled';
respawn_enable: boolean;
}

class WoolWarsClass {
wins: number;
kills: number;
assists: number;
deaths: number;
KDRatio: number;
gamesPlayed: number;
woolsPlaced: number;
blocksBroken: number;
placeBreakRatio: number;
powerups: number;
constructor(data: Record<string, any>, className: string) {
this.wins = data?.[className]?.wins || 0;
this.kills = data?.[className]?.kills || 0;
this.assists = data?.[className]?.assists || 0;
this.deaths = data?.[className]?.deaths || 0;
this.KDRatio = divide(this.kills, this.deaths);
this.gamesPlayed = data?.[className]?.games_played || 0;
this.woolsPlaced = data?.[className]?.wool_placed || 0;
this.blocksBroken = data?.[className]?.blocks_broken || 0;
this.placeBreakRatio = divide(this.woolsPlaced, this.blocksBroken);
this.powerups = data?.[className]?.powerups_gotten || 0;
}
}

class WoolWars {
selectedClass: 'ASSAULT' | 'TANK' | 'GOLEM' | 'SWORDSMAN' | 'ENGINEER' | 'ARCHER' | 'NONE';
wins: number;
kills: number;
assists: number;
deaths: number;
KDRatio: number;
gamesPlayed: number;
woolsPlaced: number;
blocksBroken: number;
placeBreakRatio: number;
powerups: number;
assault: WoolWarsClass;
tank: WoolWarsClass;
golem: WoolWarsClass;
swordsman: WoolWarsClass;
engineer: WoolWarsClass;
archer: WoolWarsClass;
constructor(data: Record<string, any>) {
this.selectedClass = data?.selected_class || 'NONE';
this.wins = data?.stats?.wins || 0;
this.kills = data?.stats?.kills || 0;
this.assists = data?.stats?.assists || 0;
this.deaths = data?.stats?.deaths || 0;
this.KDRatio = divide(this.kills, this.deaths);
this.gamesPlayed = data?.stats?.games_played || 0;
this.woolsPlaced = data?.stats?.wool_placed || 0;
this.blocksBroken = data?.stats?.blocks_broken || 0;
this.placeBreakRatio = divide(this.woolsPlaced, this.blocksBroken);
this.powerups = data?.powerups_gotten || 0;
this.assault = new WoolWarsClass(data?.stats?.classes, 'assault');
this.tank = new WoolWarsClass(data?.stats?.classes, 'tank');
this.golem = new WoolWarsClass(data?.stats?.classes, 'golem');
this.swordsman = new WoolWarsClass(data?.stats?.classes, 'swordsman');
this.engineer = new WoolWarsClass(data?.stats?.classes, 'engineer');
this.archer = new WoolWarsClass(data?.stats?.classes, 'archer');
}
}

class CaptureTheWool {
kills: number;
assists: number;
deaths: number;
KDRatio: number;
killsWithWool: number;
deathsWithWool: number;
KDRatioWithWool: number;
woolCaptured: number;
woolStolen: number;
woolCaptureStolenRatio: number;
constructor(data: Record<string, any>) {
this.kills = data?.stats?.kills || 0;
this.assists = data?.stats?.assists || 0;
this.deaths = data?.stats?.deaths || 0;
this.KDRatio = divide(this.kills, this.deaths);
this.killsWithWool = data?.stats?.kills_with_wool || 0;
this.deathsWithWool = data?.stats?.deaths_with_wool || 0;
this.KDRatioWithWool = divide(this.killsWithWool, this.deathsWithWool);
this.woolCaptured = data?.stats?.wools_captured || 0;
this.woolStolen = data?.stats?.wools_stolen || 0;
this.woolCaptureStolenRatio = divide(this.woolCaptured, this.woolStolen);
}
}

class SheepWars {
wins: number;
kills: number;
killsVoid: number;
killsBow: number;
killsExplosive: number;
deaths: number;
deathsVoid: number;
deathsMelee: number;
deathsExplosive: number;
KDRatio: number;
losses: number;
WLRatio: number;
gamesPlayed: number;
damageDealt: number;
sheepThrown: number;
magicWoolHit: number;
constructor(data: Record<string, any>) {
this.wins = data?.stats?.wins || 0;
this.kills = data?.stats?.kills || 0;
this.killsVoid = data?.stats?.kills_void || 0;
this.killsBow = data?.stats?.kills_bow || 0;
this.killsExplosive = data?.stats?.kills_explosive || 0;
this.deaths = data?.stats?.deaths || 0;
this.deathsVoid = data?.stats?.deaths_void || 0;
this.deathsMelee = data?.stats?.deaths_melee || 0;
this.deathsExplosive = data?.stats?.deaths_explosive || 0;
this.KDRatio = divide(this.wins, this.deaths);
this.losses = data?.stats?.losses || 0;
this.WLRatio = divide(this.wins, this.losses);
this.gamesPlayed = data?.stats?.games_played || 0;
this.damageDealt = data?.stats?.damage_dealt || 0;
this.sheepThrown = data?.stats?.sheep_thrown || 0;
this.magicWoolHit = data?.stats?.magic_wool_hit || 0;
}
}

class WoolGames {
layers: number;
xp: number;
exactLevel: number;
level: number;
coins: number;
ownedCosmetics: string[];
privateGamesConfig: WoolGamesPrivateGameConfig;
playtime: number;
woolWars: WoolWars;
captureTheWool: CaptureTheWool;
sheepWars: SheepWars;
constructor(data: Record<string, any>) {
this.layers = data?.progression?.available_layers || 0;
this.xp = data?.progression?.experience || 0;
this.exactLevel = this.convertXPToLevel(this.xp);
this.level = Math?.floor(this.exactLevel);
this.coins = data?.coins || 0;
this.ownedCosmetics = data?.packages || [];
this.privateGamesConfig = data?.privategames || {};
this.playtime = data?.playtime || 0;
this.woolWars = new WoolWars(data?.wool_wars);
this.captureTheWool = new CaptureTheWool(data?.capture_the_wool);
this.sheepWars = new SheepWars(data?.sheep_wars);
}

convertXPToLevel(exp: number): number {
const minimalExp = [0, 1e3, 3e3, 6e3, 1e4, 15e3];
const baseLevel = minimalExp?.length;
const baseExp = minimalExp[minimalExp?.length - 1];
const expToLevel100 = 49e4;
if (exp < baseExp) return minimalExp?.findIndex((x) => exp < x);
const theoreticalLevel = (exp - baseExp) / 5e3 + baseLevel;
if (100 < theoreticalLevel) return 100 + this.convertXPToLevel(exp - expToLevel100);
return theoreticalLevel;
}
}

export default WoolGames;
Loading

0 comments on commit f8ecb41

Please sign in to comment.