From cc3e0f2c41e34759973b9a67d95635d3e7bb44af Mon Sep 17 00:00:00 2001 From: Ecmelt Date: Tue, 3 Dec 2024 15:53:58 +0000 Subject: [PATCH] Added new items, changed file/variable namings so they make more sense. --- src/helpers/dailyCooldowns.ts | 24 +++++----- src/static/dailyLimitedItems.ts | 7 --- src/static/limitedRecipes.ts | 78 +++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 19 deletions(-) delete mode 100644 src/static/dailyLimitedItems.ts create mode 100644 src/static/limitedRecipes.ts diff --git a/src/helpers/dailyCooldowns.ts b/src/helpers/dailyCooldowns.ts index c630797..28ee614 100755 --- a/src/helpers/dailyCooldowns.ts +++ b/src/helpers/dailyCooldowns.ts @@ -1,12 +1,12 @@ import { DAILY_COOLDOWNS } from '../static/dailyCooldowns' -import { DAILY_LIMITED_ITEMS, DailyLimitedItem } from '../static/dailyLimitedItems' +import { LIMITED_RECIPES, LimitedRecipe } from '../static/limitedRecipes' import { RecipeTreeWithCraftFlags } from '../types' const dailyCooldownIds = DAILY_COOLDOWNS.filter((x) => x.craftInterval === 'daily').map((x) => x.id) -const dailyLimitedItems = DAILY_LIMITED_ITEMS +const limitedRecipes = LIMITED_RECIPES export type DailyCooldownsBreakdown = Record -export type MatchingItemWithoutLimit = Omit +export type MatchingRecipeWithoutLimit = Omit // Get a list of daily cooldowns used in the recipe export function dailyCooldowns( @@ -21,12 +21,12 @@ export function dailyCooldowns( breakdown[tree.id] = (breakdown[tree.id] || 0) + tree.usedQuantity } - const matchingItem = dailyLimitedItems.find((item) => item.id === tree.id) + const matchingRecipe = limitedRecipes.find((recipe) => recipe.id === tree.id) if ( - matchingItem && - matchesItemProperties( + matchingRecipe && + matchesRecipeProperties( tree, - (({ dailyLimit, ...matchingItemWithoutLimit }) => matchingItemWithoutLimit)(matchingItem) + (({ limit, ...matchingRecipeWithoutLimit }) => matchingRecipeWithoutLimit)(matchingRecipe) ) ) { breakdown[tree.id] = (breakdown[tree.id] || 0) + tree.usedQuantity @@ -36,11 +36,11 @@ export function dailyCooldowns( return breakdown } -export function matchesItemProperties( +export function matchesRecipeProperties( tree: RecipeTreeWithCraftFlags, - matchingItemWithoutLimit: MatchingItemWithoutLimit + matchingRecipeWithoutLimit: MatchingRecipeWithoutLimit ): boolean { - return Object.entries(matchingItemWithoutLimit).every(([key, value]) => { + return Object.entries(matchingRecipeWithoutLimit).every(([key, value]) => { if (!(key in tree)) { return false } @@ -48,7 +48,7 @@ export function matchesItemProperties( const treeValue = tree[key as keyof RecipeTreeWithCraftFlags] as unknown if (typeof value === 'object' && !Array.isArray(value) && typeof treeValue === 'object') { - return matchesItemProperties(treeValue as RecipeTreeWithCraftFlags, value) + return matchesRecipeProperties(treeValue as RecipeTreeWithCraftFlags, value) } if (Array.isArray(value)) { @@ -56,7 +56,7 @@ export function matchesItemProperties( return false } return value.every((nestedObject, index) => - matchesItemProperties(treeValue[index], nestedObject as MatchingItemWithoutLimit) + matchesRecipeProperties(treeValue[index], nestedObject as MatchingRecipeWithoutLimit) ) } diff --git a/src/static/dailyLimitedItems.ts b/src/static/dailyLimitedItems.ts deleted file mode 100644 index a6a0808..0000000 --- a/src/static/dailyLimitedItems.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type DailyLimitedItem = { id: number; dailyLimit: number } & Partial<{ - components: { id: number; type: string; quantity: number }[] -}> - -export const DAILY_LIMITED_ITEMS: DailyLimitedItem[] = [ - { id: 92272, components: [{ id: 2, type: 'Currency', quantity: 2668 }], dailyLimit: 10 }, // Eternal Ice Shard -] diff --git a/src/static/limitedRecipes.ts b/src/static/limitedRecipes.ts new file mode 100644 index 0000000..7a4657f --- /dev/null +++ b/src/static/limitedRecipes.ts @@ -0,0 +1,78 @@ +export type LimitedRecipe = { + id: number + limit: { type: string; quantity: number } +} & Partial<{ + components: { id: number; type: string; quantity: number }[] +}> + +export const LIMITED_RECIPES: LimitedRecipe[] = [ + { + id: 92272, + components: [{ id: 2, type: 'Currency', quantity: 2668 }], + limit: { type: 'daily', quantity: 10 }, + }, // Eternal Ice Shard + { + id: 103846, + components: [ + { id: 68063, type: 'Item', quantity: 1 }, + { id: 102494, type: 'Item', quantity: 1 }, + { id: 2, type: 'Currency', quantity: 1050 }, + ], + limit: { type: 'weekly', quantity: 21 }, + }, // Discounted Shard of Janthir Syntri + { + id: 103316, + components: [ + { id: 68063, type: 'Item', quantity: 3 }, + { id: 102494, type: 'Item', quantity: 3 }, + { id: 2, type: 'Currency', quantity: 1750 }, + ], + limit: { type: 'weekly', quantity: 21 }, + }, // Shard of Janthir Syntri + { + id: 103991, + components: [ + { id: 68063, type: 'Item', quantity: 1 }, + { id: 103038, type: 'Item', quantity: 1 }, + { id: 2, type: 'Currency', quantity: 1050 }, + ], + limit: { type: 'weekly', quantity: 21 }, + }, // Discounted Shard of Lowland Shore + { + id: 103991, + components: [ + { id: 68063, type: 'Item', quantity: 3 }, + { id: 103038, type: 'Item', quantity: 3 }, + { id: 2, type: 'Currency', quantity: 1750 }, + ], + limit: { type: 'weekly', quantity: 21 }, + }, // Shard of Lowland Shore + { + id: 102494, + components: [ + { id: 103038, type: 'Item', quantity: 1 }, + { id: 102558, type: 'Item', quantity: 3 }, + { id: 102503, type: 'Item', quantity: 3 }, + ], + limit: { type: 'daily', quantity: 3 }, + }, // Curious Mursaat Currency + { + id: 102494, + components: [{ id: 2, type: 'Currency', quantity: 1050 }], + limit: { type: 'daily', quantity: 3 }, + }, // Curious Mursaat Currency (Karma) + { + id: 103038, + components: [ + { id: 102494, type: 'Item', quantity: 1 }, + { id: 103279, type: 'Item', quantity: 3 }, + { id: 102255, type: 'Item', quantity: 3 }, + ], + limit: { type: 'daily', quantity: 3 }, + }, // Curious Lowland Honeycomb + { + id: 103038, + components: [{ id: 2, type: 'Currency', quantity: 1050 }], + limit: { type: 'daily', quantity: 3 }, + }, // Curious Lowland Honeycomb (Karma) +]