diff --git a/packages/excavator-projects/projects/designerSweatpants.ts b/packages/excavator-projects/projects/designerSweatpants.ts index 8f18ecd..bebc00b 100644 --- a/packages/excavator-projects/projects/designerSweatpants.ts +++ b/packages/excavator-projects/projects/designerSweatpants.ts @@ -1,15 +1,7 @@ -import { - currentRound, - Item, - equippedItem, - Slot, - myLocation, - getProperty, - setProperty, -} from "kolmafia"; +import { currentRound, Item, equippedItem, Slot, myLocation } from "kolmafia"; import { ExcavatorProject } from "../type"; -import { toNormalisedString } from "../utils"; +import { shouldDiscardData, toNormalisedString } from "../utils"; function spadeSweatpants(encounter: string, page: string) { if (currentRound() !== 0) return null; @@ -25,15 +17,7 @@ function spadeSweatpants(encounter: string, page: string) { if (!sweat) return null; const location = toNormalisedString(myLocation()); - const reportedLocations = getProperty("excavatorSweatpantsLocations").split( - "|", - ); - if (reportedLocations.includes(location)) return null; - - setProperty( - "excavatorSweatpantsLocations", - [...reportedLocations, location].join("|"), - ); + if (shouldDiscardData("_excavatorSweatpantsLocations", location)) return null; return { location, diff --git a/packages/excavator-projects/projects/mummingTrunk.ts b/packages/excavator-projects/projects/mummingTrunk.ts index 28ce06f..6e835ef 100644 --- a/packages/excavator-projects/projects/mummingTrunk.ts +++ b/packages/excavator-projects/projects/mummingTrunk.ts @@ -1,7 +1,7 @@ import { Item, availableAmount, getProperty, myFamiliar } from "kolmafia"; import { ExcavatorProject } from "../type"; -import { notNull } from "../utils"; +import { notNull, shouldDiscardData } from "../utils"; export const MUMMING_TRUNK: ExcavatorProject = { name: "Mumming Trunk", @@ -135,6 +135,8 @@ function spadeMummingTrunk(encounter: string, page: string) { ); if (!match) return null; + if (shouldDiscardData("_excavatorMummingTrunk", `${fam.id}:${match[0]}`)) + return null; return { attribute: match[0], diff --git a/packages/excavator-projects/utils.ts b/packages/excavator-projects/utils.ts index 9fc6fd3..273ce5d 100644 --- a/packages/excavator-projects/utils.ts +++ b/packages/excavator-projects/utils.ts @@ -2,6 +2,7 @@ import { canInteract, Effect, gamedayToInt, + getProperty, haveEffect, haveEquipped, inHardcore, @@ -15,6 +16,7 @@ import { myLocation, myPath, Path, + setProperty, } from "kolmafia"; const ALTERING_EFFECTS = Effect.get([ @@ -86,3 +88,11 @@ export function toNormalisedString(thing: Item | Monster | Location) { export function notNull(value: T | null): value is T { return value !== null; } + +export function shouldDiscardData(property: string, data: string) { + const sentData = getProperty(property).split("|"); + if (sentData.includes(data)) return true; + + setProperty(property, [...sentData, data].join("|")); + return false; +}