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

Add Stillsuit features #679

Merged
merged 5 commits into from
Nov 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
58 changes: 58 additions & 0 deletions src/resources/2022/Stillsuit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { cliExecute, visitUrl } from "kolmafia";
import { have as haveItem } from "../../lib.js";
import { get } from "../../property.js";
import { $item } from "../../template-string.js";
import { NumericModifier } from "../../modifierTypes.js";

/**
* Do you own a still-suit?
* @returns Whether you have the tiny stillsuit
*/
export function have(): boolean {
return haveItem($item`tiny stillsuit`);
}

/**
* @returns the expected adventures from drinking stillsuit distillate
*/
export function distillateAdventures(): number {
if (!have()) return 0;
const sweat = get("familiarSweat");
return Math.round(sweat ** 0.4);
}

/**
* Drinks stillsuit distillate
* @returns whether distillate was successfully drunk
*/
export function drinkDistillate(): boolean {
if (!have() || get("familiarSweat") <= 0) return false;
return cliExecute("drink stillsuit distillate");
}

/**
* Checks distillate for specific modifiers
* @param modifier determines what modifier to check stillsuit buffs against
* @returns the modifier value for the given modifier
*/
export function distillateModifier(modifier: NumericModifier): number {
visitUrl("inventory.php?action=distill&pwd");
// Retrieve the current distillate modifiers as a string
const distillateMods = get("currentDistillateMods");

const experienceMap: Record<string, string> = {
"Muscle Experience": "Experience (Muscle)",
"Mysticality Experience": "Experience (Mysticality)",
"Moxie Experience": "Experience (Moxie)",
};

// Adjust the modifier if it is one of the special cases
const adjustedModifier = experienceMap[modifier] ?? modifier;

// Construct a regex pattern to match the modifier and capture the numeric value
const regex = new RegExp(`${adjustedModifier}: \\+?(-?\\d+)`);
const match = distillateMods.match(regex);

// If a match is found, parse and return the captured number; otherwise, return 0
return match ? Number(match[1]) : 0;
}
2 changes: 2 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import * as MayamCalendar from "./2024/MayamCalendar.js";
import * as TearawayPants from "./2024/TearawayPants.js";
import * as BatWings from "./2024/BatWings.js";
import * as EverfullDarts from "./2024/EverfullDarts.js";
import * as StillSuit from "./2022/Stillsuit.js";

export {
AprilingBandHelmet,
Expand Down Expand Up @@ -108,6 +109,7 @@ export {
Spacegate,
SpookyPutty,
Stickers,
StillSuit,
StompingBoots,
TearawayPants,
TrainSet,
Expand Down
Loading