diff --git a/src/lib/data/Collections.ts b/src/lib/data/Collections.ts index 9fa73a29f0..a36f8e4f75 100644 --- a/src/lib/data/Collections.ts +++ b/src/lib/data/Collections.ts @@ -1100,7 +1100,7 @@ export const allCollectionLogs: ICollection = { ...Monsters.Vardorvis.allItems, ...Monsters.DukeSucellus.allItems ], - items: [...theLeviathanCL, ...theWhispererCL, ...vardorvisCL, ...dukeSucellusCL] + items: [...theLeviathanCL, ...theWhispererCL, ...vardorvisCL, ...dukeSucellusCL] }, Creatables: { counts: false, diff --git a/src/lib/data/creatables/dt.ts b/src/lib/data/creatables/dt.ts index f5cf6a989a..ada8fe6b00 100644 --- a/src/lib/data/creatables/dt.ts +++ b/src/lib/data/creatables/dt.ts @@ -116,7 +116,7 @@ export const dtCreatables: Createable[] = [ .add("Executioner's axe head") .add('Eye of the duke') .add('Blood rune', 2000), - outputItems: new Bank().add(25484) //use id to prevent beta id usage + outputItems: new Bank().add(25484) //use id to prevent beta id usage //TODO: 28338 is the proper id but OSJS is missing this item?? } ]; diff --git a/src/lib/util/parseStringBank.ts b/src/lib/util/parseStringBank.ts index 75f9632e4f..f9b05421aa 100644 --- a/src/lib/util/parseStringBank.ts +++ b/src/lib/util/parseStringBank.ts @@ -6,9 +6,9 @@ import { itemNameMap } from 'oldschooljs/dist/structures/Items'; import { ONE_TRILLION } from '../constants'; import { filterableTypes } from '../data/filterables'; +import { setItemAlias } from '../data/itemAliases'; import { cleanString, getItem, stringMatches } from '../util'; import itemIsTradeable from './itemIsTradeable'; -import { setItemAlias } from '../data/itemAliases'; const { floor, max, min } = Math; @@ -57,7 +57,12 @@ export function parseQuantityAndItem(str = '', inputBank?: Bank): [Item[], numbe return [osItems, quantity]; } -export function parseStringBank(str = '', inputBank?: Bank, noDuplicateItems?: true, itemAliases?: true): [Item, number | undefined][] { +export function parseStringBank( + str = '', + inputBank?: Bank, + noDuplicateItems?: true, + itemAliases?: true +): [Item, number | undefined][] { const split = str .trim() .replace(/\s\s+/g, ' ') @@ -71,19 +76,19 @@ export function parseStringBank(str = '', inputBank?: Bank, noDuplicateItems?: t if (resItems !== undefined) { for (const item of noDuplicateItems ? resItems.slice(0, 1) : resItems) { if (currentIDs.has(item.id)) continue; - let resolvedItem: Item | null = item; - if (itemAliases) { - resolvedItem = getItem(item.name); - } - if (resolvedItem) { - items.push([resolvedItem, quantity]); - currentIDs.add(resolvedItem.id); - } - } - } - } - - return items; + let resolvedItem: Item | null = item; + if (itemAliases) { + resolvedItem = getItem(item.name); + } + if (resolvedItem) { + items.push([resolvedItem, quantity]); + currentIDs.add(resolvedItem.id); + } + } + } + } + + return items; } function parseBankFromFlags({ diff --git a/src/lib/util/repairBrokenItems.ts b/src/lib/util/repairBrokenItems.ts index 070617bcad..945ec301b5 100644 --- a/src/lib/util/repairBrokenItems.ts +++ b/src/lib/util/repairBrokenItems.ts @@ -3,44 +3,44 @@ import { notEmpty } from 'e'; import { Items } from 'oldschooljs'; import { userStatsUpdate } from '../../mahoji/mahojiSettings'; -import type { ItemBank } from '../types'; import { type GearSetup, GearSetupTypes } from '../gear/types'; +import type { ItemBank } from '../types'; interface ItemSwaps { - item: string; - wrongID: number; - correctID: number; + item: string; + wrongID: number; + correctID: number; } const itemswaps: ItemSwaps[] = [ - { - item: 'Bellator ring', - wrongID: 25488, - correctID: 28316 - }, - { - item: 'Ultor ring', - wrongID: 25485, - correctID: 28307 - }, - { - item: 'Magus ring', - wrongID: 25486, - correctID: 28313 - }, - { - item: 'Venator ring', - wrongID: 25487, - correctID: 28310 - } - /* TODO: id 28338 is missing from OSJS in item_data.json + { + item: 'Bellator ring', + wrongID: 25488, + correctID: 28316 + }, + { + item: 'Ultor ring', + wrongID: 25485, + correctID: 28307 + }, + { + item: 'Magus ring', + wrongID: 25486, + correctID: 28313 + }, + { + item: 'Venator ring', + wrongID: 25487, + correctID: 28310 + } + /* TODO: id 28338 is missing from OSJS in item_data.json { item: 'Soulreaper axe', wrongID: 25484, correctID: 28338 } */ -] +]; export async function repairBrokenItemsFromUser(mUser: MUser): Promise<[string] | [string, any[]]> { const { user } = mUser; @@ -74,19 +74,19 @@ export async function repairBrokenItemsFromUser(mUser: MUser): Promise<[string] ['gear', allGearItemIDs] ]; - for (const [, ids] of allItemsToCheck) { - for (const id of ids.map(i => Number(i))) { - const item = Items.get(id); - if (!item) { - brokenBank.push(id); - } else { - const swap = itemswaps.find(s => s.wrongID === id); - if (swap) { - brokenBank.push(id); - } - } - } - } + for (const [, ids] of allItemsToCheck) { + for (const id of ids.map(i => Number(i))) { + const item = Items.get(id); + if (!item) { + brokenBank.push(id); + } else { + const swap = itemswaps.find(s => s.wrongID === id); + if (swap) { + brokenBank.push(id); + } + } + } + } const newFavs = favorites.filter(i => !brokenBank.includes(i)); const newBank = { ...rawBank }; @@ -94,41 +94,41 @@ export async function repairBrokenItemsFromUser(mUser: MUser): Promise<[string] const newTempCL = { ...rawTempCL }; const newSacLog = { ...rawSacLog }; - for (const id of brokenBank) { - const swap = itemswaps.find(s => s.wrongID === id); - if (swap) { - if (newBank[id]) { - newBank[swap.correctID] = (newBank[swap.correctID] || 0) + newBank[id]; - } - if (newCL[id]) { - newCL[swap.correctID] = (newCL[swap.correctID] || 0) + newCL[id]; - } - if (newTempCL[id]) { - newTempCL[swap.correctID] = (newTempCL[swap.correctID] || 0) + newTempCL[id]; - } - if (newSacLog[id]) { - newSacLog[swap.correctID] = (newSacLog[swap.correctID] || 0) + newSacLog[id]; - } - } - delete newBank[id]; - delete newCL[id]; - delete newTempCL[id]; - delete newSacLog[id]; - } - + for (const id of brokenBank) { + const swap = itemswaps.find(s => s.wrongID === id); + if (swap) { + if (newBank[id]) { + newBank[swap.correctID] = (newBank[swap.correctID] || 0) + newBank[id]; + } + if (newCL[id]) { + newCL[swap.correctID] = (newCL[swap.correctID] || 0) + newCL[id]; + } + if (newTempCL[id]) { + newTempCL[swap.correctID] = (newTempCL[swap.correctID] || 0) + newTempCL[id]; + } + if (newSacLog[id]) { + newSacLog[swap.correctID] = (newSacLog[swap.correctID] || 0) + newSacLog[id]; + } + } + delete newBank[id]; + delete newCL[id]; + delete newTempCL[id]; + delete newSacLog[id]; + } + for (const setupType of GearSetupTypes) { const _gear = user[`gear_${setupType}`] as GearSetup | null; if (_gear === null) continue; const gear = { ..._gear }; for (const [key, value] of Object.entries(gear)) { if (value === null) continue; - const swap = itemswaps.find(s => s.wrongID === value.item); - if (brokenBank.includes(value.item)) { - delete gear[key as keyof GearSetup]; - } - if (swap) { - gear[key as keyof GearSetup] = { ...value, item: swap.correctID }; - } + const swap = itemswaps.find(s => s.wrongID === value.item); + if (brokenBank.includes(value.item)) { + delete gear[key as keyof GearSetup]; + } + if (swap) { + gear[key as keyof GearSetup] = { ...value, item: swap.correctID }; + } } // @ts-ignore ??? changes[`gear_${setupType}`] = gear; @@ -156,9 +156,7 @@ export async function repairBrokenItemsFromUser(mUser: MUser): Promise<[string] return [ `You had ${ brokenBank.length - } broken items in your bank/collection log/favorites/gear, they were removed. ${ - brokenBank - .slice(0, 500)}`, + } broken items in your bank/collection log/favorites/gear, they were removed. ${brokenBank.slice(0, 500)}`, Object.keys(brokenBank) ]; } diff --git a/src/mahoji/commands/tools.ts b/src/mahoji/commands/tools.ts index cda83b8361..0aead122f3 100644 --- a/src/mahoji/commands/tools.ts +++ b/src/mahoji/commands/tools.ts @@ -41,6 +41,7 @@ import { getItem } from '../../lib/util/getOSItem'; import { handleMahojiConfirmation } from '../../lib/util/handleMahojiConfirmation'; import { deferInteraction } from '../../lib/util/interactionReply'; import { makeBankImage } from '../../lib/util/makeBankImage'; +import { repairBrokenItemsFromUser } from '../../lib/util/repairBrokenItems'; import { getParsedStashUnits, stashUnitBuildAllCommand, @@ -51,7 +52,6 @@ import { import { itemOption, monsterOption, skillOption } from '../lib/mahojiCommandOptions'; import type { OSBMahojiCommand } from '../lib/util'; import { patronMsg } from '../mahojiSettings'; -import { repairBrokenItemsFromUser } from '../../lib/util/repairBrokenItems'; const INTERVAL_DAY = 'day'; const INTERVAL_WEEK = 'week';