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

Use a regex to get dart parts #64

Merged
merged 2 commits into from
Apr 7, 2024
Merged
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
34 changes: 28 additions & 6 deletions packages/excavator-script/src/projects/monsterParts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
import {
currentRound,
dartPartsToSkills,
Effect,
Familiar,
haveEquipped,
Expand Down Expand Up @@ -143,6 +142,9 @@ const MUTANT_COUTURE_SKILLS = {
leg: $skill`Entangle`,
};

const DART_REGEX =
/<div class="ed_part.*?name="whichskill" value="\d+".*?<button>([^<]+?)<\/button>/g;

function checkPrerequisite({
type,
prerequisite,
Expand Down Expand Up @@ -261,19 +263,39 @@ function spadeMonsterParts(
haveEquipped($item`Everfull Dart Holster`)
) {
const buttAwareness = get("everfullDartPerks").includes("Butt awareness");
const allDartParts = [...page.matchAll(DART_REGEX)].map(
(match) => match[1],
);

const dartParts = [
...new Set(
allDartParts.filter((part) => !buttAwareness || part !== "butt"),
),
];

data.push(
...Object.keys(dartPartsToSkills())
.filter(
(part) =>
!monsterParts.includes(part) && (!buttAwareness || part !== "butt"),
)
...dartParts
.filter((part) => !monsterParts.includes(part))
.map((part) => ({
monster: monster,
part,
confirmation: true,
source: "Everfull Dart Holster",
})),
);

if (allDartParts.length <= 4) {
data.push(
...monsterParts
.filter((part) => !dartParts.includes(part))
.map((part) => ({
monster: monster,
part,
confirmation: false,
source: "Everfull Dart Holster",
})),
);
}
}

return data;
Expand Down