aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cleaners/skyblock/experimentation.ts70
-rw-r--r--src/cleaners/skyblock/member.ts9
2 files changed, 77 insertions, 2 deletions
diff --git a/src/cleaners/skyblock/experimentation.ts b/src/cleaners/skyblock/experimentation.ts
new file mode 100644
index 0000000..d81fb3d
--- /dev/null
+++ b/src/cleaners/skyblock/experimentation.ts
@@ -0,0 +1,70 @@
+import typedHypixelApi from 'typed-hypixel-api'
+import { ExperimentationGame as ApiExperimentationGame } from 'typed-hypixel-api/build/responses/skyblock/_profile_member'
+import * as constants from '../../constants.js'
+
+export interface ExperimentationGame {
+ /** `superpairs`, `chronomatron` or `ultrasequencer`. */
+ id: string
+ last_attempt: number | undefined
+ last_claimed: number | undefined
+ types: {
+ attempts: number
+ claims: number
+ best_score: number
+ }[]
+}
+
+const EXPERIMENTATION_GAME_IDS = {
+ pairings: 'superpairs',
+ simon: 'chronomatron',
+ numbers: 'ultrasequencer'
+} as const
+
+// this should be in skyblock-constants, but i don't expect hypixel to add new experimentation games
+const EXPERIMENTATION_GAME_TYPES_COUNT: Record<typeof EXPERIMENTATION_GAME_IDS[keyof typeof EXPERIMENTATION_GAME_IDS], number> = {
+ superpairs: 6,
+ chronomatron: 5,
+ ultrasequencer: 3
+}
+
+export interface Experimentation {
+ games: ExperimentationGame[]
+}
+
+function cleanGame(apiId: string, game: ApiExperimentationGame | undefined): ExperimentationGame {
+ const gameId = EXPERIMENTATION_GAME_IDS[apiId]
+
+ if (!game)
+ game = {}
+
+ const types: ExperimentationGame['types'] = []
+
+ for (let i = 0; i < EXPERIMENTATION_GAME_TYPES_COUNT[gameId]; i++) {
+ const type_attempts = game[`attempts_${i}`] ?? 0
+ const type_claims = game[`claims_${i}`] ?? 0
+ const type_best_score = game[`best_score_${i}`] ?? 0
+
+ types.push({
+ attempts: type_attempts,
+ claims: type_claims,
+ best_score: type_best_score
+ })
+ }
+
+ return {
+ id: gameId,
+ last_attempt: game.last_attempt || undefined,
+ last_claimed: game.last_claimed || undefined,
+ types
+ }
+}
+
+export async function cleanExperimentation(data: typedHypixelApi.SkyBlockProfileMember): Promise<Experimentation> {
+ return {
+ games: [
+ cleanGame('pairings', data.experimentation?.pairings),
+ cleanGame('simon', data.experimentation?.simon),
+ cleanGame('numbers', data.experimentation?.numbers)
+ ]
+ }
+}
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index d69295e..9d68796 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -1,3 +1,5 @@
+import { AccessoryBagUpgrades, cleanAccessoryBagUpgrades } from './accessoryBagUpgrades.js'
+import { cleanExperimentation, Experimentation } from './experimentation.js'
import { cleanFarmingContests, FarmingContests } from './farmingContents.js'
import { cleanCoopInvitation, CoopInvitation } from './coopInvitation.js'
import { cleanCollections, Collection } from './collections.js'
@@ -9,6 +11,7 @@ import { cleanProfileStats, StatItem } from './stats.js'
import { CleanMinion, cleanMinions } from './minions.js'
import { cleanSlayers, SlayerData } from './slayers.js'
import { AccountCustomization } from '../../database.js'
+import { cleanEssence, Essence } from './essence.js'
import { cleanVisitedZones, Zone } from './zones.js'
import { cleanSkills, Skills } from './skills.js'
import * as cached from '../../hypixelCached.js'
@@ -19,8 +22,6 @@ import * as constants from '../../constants.js'
import { Included } from '../../hypixel.js'
import { CleanPlayer } from '../player.js'
import { CleanRank } from '../rank.js'
-import { AccessoryBagUpgrades, cleanAccessoryBagUpgrades } from './accessoryBagUpgrades.js'
-import { cleanEssence, Essence } from './essence.js'
export interface CleanBasicMember {
uuid: string
@@ -48,6 +49,8 @@ interface ExtraCleanMemberFields {
coopInvitation: CoopInvitation | null
farmingContests: FarmingContests
accessoryBagUpgrades: AccessoryBagUpgrades
+ experimentation: Experimentation
+ /** Whether the user left the coop */
essence: Essence
/** Whether the member left the coop. */
left: boolean
@@ -87,6 +90,7 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi
const harpPromise = cleanHarp(member)
const inventoriesPromise = inventoriesIncluded ? cleanInventories(member) : Promise.resolve(undefined)
const farmingContestsPromise = cleanFarmingContests(member)
+ const experimentationTablePromise = cleanExperimentation(member)
return {
uuid: member.uuid,
@@ -118,6 +122,7 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi
coopInvitation: await coopInvitationPromise,
farmingContests: await farmingContestsPromise,
accessoryBagUpgrades: cleanAccessoryBagUpgrades(member),
+ experimentation: await experimentationTablePromise,
essence: cleanEssence(member),
left: (player.profiles?.find(profile => profile.uuid === profileId) === undefined) ?? false