Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parts redux #58

Merged
merged 6 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"scripts": {
"build": "yarn workspace excavator-script run build",
"format": "yarn workspaces run format"
"format": "yarn workspaces run format",
"lint": "yarn workspaces run lint"
}
}
}
3 changes: 2 additions & 1 deletion packages/excavator-prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"prettier-config.js"
],
"scripts": {
"format": "prettier --write ."
"format": "prettier --write .",
"lint": "prettier --check ."
},
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion packages/excavator-script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"scripts": {
"build": "node build.mjs",
"format": "prettier --write .",
"lint": "eslint src && prettier --check .",
"watch": "node build.mjs --watch"
},
"dependencies": {
"kolmafia": "^5.27741.0",
"kolmafia": "^5.27884.0",
"libram": "^0.8.18",
"core-js": "^3.0.0"
},
Expand Down
119 changes: 85 additions & 34 deletions packages/excavator-script/src/projects/monsterParts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
dartPartsToSkills,
Effect,
Familiar,
getRevision,
haveEquipped,
isWearingOutfit,
Item,
Expand All @@ -26,10 +27,11 @@ import {
} from "libram";

import { ExcavatorProject } from "../type";
import { toNormalisedString } from "../utils/game";
import { isAdventureTextAltered, toNormalisedString } from "../utils/game";

// eslint-disable-next-line libram/verify-constants
const MONSTER_BLACKLIST = $monsters`the darkness (blind), Perceiver of Sensations, Performer of Actions, Thinker of Thoughts`;
const MONSTER_DENYLIST = $monsters`the darkness (blind)`;
const MONSTER_SEARCH_DENYLIST = $monsters`Perceiver of Sensations, Performer of Actions, Thinker of Thoughts`;

type Indicator =
| { type: "effect"; prerequisite: Effect; pattern: string }
Expand Down Expand Up @@ -173,32 +175,46 @@ function spadeMonsterParts(
encounter: string,
page: string,
): MonsterPartsData[] | null {
if (MONSTER_BLACKLIST.includes(lastMonster())) return null;
if (getRevision() < 27884 || MONSTER_DENYLIST.includes(lastMonster()))
return null;

const monster = toNormalisedString(lastMonster());
const monsterParts = lastMonster().parts;

const data = [];

// Simple indicators
for (const indicator of INDICATORS) {
if (!checkPrerequisite(indicator)) continue;
const part = page.match(indicator.pattern)?.[1];
if (!part) continue;
data.push({
monster,
part,
confirmation: true,
source: indicator.prerequisite.toString(),
});
}
if (
!isAdventureTextAltered() &&
!MONSTER_SEARCH_DENYLIST.includes(lastMonster())
) {
// Simple indicators
for (const indicator of INDICATORS) {
if (!checkPrerequisite(indicator)) continue;
const part = page.match(indicator.pattern)?.[1];
if (!part) continue;
if (monsterParts.includes(part)) continue;
data.push({
monster,
part,
confirmation: true,
source: indicator.prerequisite.toString(),
});
}

// El Vibrato restraints
if (page.includes("lvcuff.gif")) {
const base = { monster, part: "arm", source: "El Vibrato restraints" };
if (page.includes("This foe doesn't have any arms that you can find")) {
data.push({ ...base, confirmation: false });
} else if (page.includes("You push the button on top of the restraints")) {
data.push({ ...base, confirmation: true });
// El Vibrato restraints
if (have($item`El Vibrato restraints`) && page.includes("lvcuff.gif")) {
const base = { monster, part: "arm", source: "El Vibrato restraints" };
if (
monsterParts.includes("arm") &&
page.includes("This foe doesn't have any arms that you can find")
) {
data.push({ ...base, confirmation: false });
} else if (
!monsterParts.includes("arm") &&
page.includes("You push the button on top of the restraints")
) {
data.push({ ...base, confirmation: true });
}
}
}

Expand All @@ -209,12 +225,33 @@ function spadeMonsterParts(
page.includes("<select name=whichskill>")
) {
data.push(
...Object.entries(MUTANT_COUTURE_SKILLS).map(([part, skill]) => ({
monster,
part,
confirmation: page.includes(`<option value="${skill.id}"`),
source: "Mutant Couture",
})),
...Object.entries(MUTANT_COUTURE_SKILLS)
.filter(
([part, skill]) =>
!monsterParts.includes(part) &&
page.includes(`<option value="${skill.id}"`),
)
.map(([part, _]) => ({
monster,
part,
confirmation: true,
source: "Mutant Couture",
})),
);

data.push(
...Object.entries(MUTANT_COUTURE_SKILLS)
.filter(
([part, skill]) =>
monsterParts.includes(part) &&
!page.includes(`<option value="${skill.id}"`),
)
.map(([part, _]) => ({
monster,
part,
confirmation: true,
source: "Mutant Couture",
})),
);
}

Expand All @@ -224,13 +261,27 @@ function spadeMonsterParts(
// eslint-disable-next-line libram/verify-constants
haveEquipped($item`Everfull Dart Holster`)
) {
const dartParts = Object.keys(dartPartsToSkills());
data.push(
...Object.keys(dartPartsToSkills()).map((part) => ({
monster,
part,
confirmation: true,
source: "Everfull Dart Holster",
})),
...monsterParts
.filter((part) => !dartParts.includes(part))
.map((part) => ({
monster,
part,
confirmation: false,
source: "Everfull Dart Holster",
})),
);

data.push(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a bug in the original too, but if you have the perk for detecting butts, excavator shouldn't send data for butts

...dartParts
.filter((part) => !monsterParts.includes(part))
.map((part) => ({
monster: monster,
part,
confirmation: true,
source: "Everfull Dart Holster",
})),
);
}

Expand Down
15 changes: 15 additions & 0 deletions packages/excavator-script/src/utils/game.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import {
canInteract,
gamedayToInt,
haveEquipped,
inHardcore,
Item,
Monster,
moonLight,
moonPhase,
myClass,
myDaycount,
myLocation,
myPath,
Path,
} from "kolmafia";
import { $effects, $items, $locations, have } from "libram";

const ALTERING_EFFECTS = $effects`Can Has Cyborger, Dis Abled, Haiku State of Mind, Just the Best Anapests, O Hai!, Robocamo, Temporary Blindness`;
const ALTERING_EQUIPMENT = $items`makeshift turban, staph of homophones, sword behind inappropriate prepositions`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also papier-mâchine gun and papier-mâchéte, I think

const ALTERING_LOCATIONS = $locations`The Haiku Dungeon`;

export function isAdventureTextAltered(): boolean {
return (
ALTERING_EFFECTS.some((effect) => have(effect)) ||
ALTERING_EQUIPMENT.some((item) => haveEquipped(item)) ||
ALTERING_LOCATIONS.includes(myLocation())
);
}

export function getDaySeed() {
return {
Expand Down
3 changes: 2 additions & 1 deletion packages/excavator-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dev": "node --loader tsm ./server.ts",
"start": "NODE_ENV=production node --loader tsm ./server.ts",
"etl": "node --loader tsm ./etl.ts",
"format": "prettier --write ."
"format": "prettier --write .",
"lint": "prettier --check ."
},
"dependencies": {
"@chakra-ui/react": "^2.8.2",
Expand Down
Loading
Loading