Skip to content
Draft
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
151 changes: 151 additions & 0 deletions src/actions/Sniff.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import {
canEquip,

Check warning on line 2 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

'canEquip' is defined but never used. Allowed unused vars must match /^_/u
cliExecute,

Check warning on line 3 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

'cliExecute' is defined but never used. Allowed unused vars must match /^_/u
myTurncount,

Check warning on line 4 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

'myTurncount' is defined but never used. Allowed unused vars must match /^_/u
restoreMp,
retrieveItem,

Check warning on line 6 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

'retrieveItem' is defined but never used. Allowed unused vars must match /^_/u
useSkill,
visitUrl,
} from "kolmafia";

import { Macro } from "../combat.js";
import { getFoldGroup, have } from "../lib.js";

Check warning on line 12 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

'getFoldGroup' is defined but never used. Allowed unused vars must match /^_/u
import { Requirement } from "../maximize.js";
import { get } from "../property.js";
import { $familiar, $item, $items, $skill } from "../template-string.js";
import {
ActionSource,
findActionSource,
FindActionSourceConstraints,
} from "./ActionSource.js";
import { AugustScepter } from "../index.js";

const sniffSources: ActionSource[] = [
new ActionSource(
$skill`Transcendant Olfaction`,

Check failure on line 25 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

Unrecognized enumerated value name "Transcendant Olfaction"
() =>
have($skill`Transcendant Olfaction`) ? 3 - get("_olfactionsUsed") : 0,

Check failure on line 27 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

Unrecognized enumerated value name "Transcendant Olfaction"
Macro.skill($skill`Transcendant Olfaction`),

Check failure on line 28 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

Unrecognized enumerated value name "Transcendant Olfaction"
{
preparation: () => restoreMp(50),
},
),

new ActionSource(
$skill`Gallapagosian Mating Call`,
() => (have($skill`Gallapagosian Mating Call`) ? 1 : 0),
Macro.skill($skill`Gallapagosian Mating Call`),
{
preparation: () => restoreMp(30),
},
),

new ActionSource(
$item`latte lovers member's mug`,
() =>
have($item`latte lovers member's mug`) && !get("_latteCopyUsed") ? 1 : 0,
Macro.skill($skill`Offer Latte to Opponent`),
{
equipmentRequirements: () =>
new Requirement([], {
forceEquip: $items`latte lovers member's mug`,
}),
},
),

new ActionSource(
$familiar`Nosy Nose`,
() => (have($familiar`Nosy Nose`) ? 1 : 0),
Macro.skill($skill`Get a Good Whiff of This Guy`),
{
familiar: () => $familiar`Nosy Nose`,
},
),

new ActionSource(
$item`August Scepter`,

Check failure on line 66 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

Enumerated value name "August Scepter" should be capitalized "august scepter"
() => (AugustScepter.have() && AugustScepter.canCast(9) ? 1 : 0),
Macro.skill($skill`Hold Hands`),
{
preparation: () => {
useSkill($skill`Aug. 9th: Hand Holding Day!`);
return true;
},
},
),

new ActionSource(
$item`Daily Affirmation: Be Superficially interested`,
() => (have($item`Daily Affirmation: Be Superficially interested`) ? 1 : 0),
Macro.tryItem($item`Daily Affirmation: Be Superficially interested`),
),

new ActionSource(
$item`cursed monkey's paw`,
() =>
have($item`cursedy monkey's paw`) && get("_monkeyPawWishesUsed") === 4

Check failure on line 86 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

Unrecognized enumerated value name "cursedy monkey's paw"
? 1
: 0,
Macro.skill($skill`Monkey Point`),
{
equipmentRequirements: () =>
new Requirement([], { forceEquip: $items`cursed monkey's paw` }),
},
),

new ActionSource(
$item`McHugeLarge left pole`,
() =>
have($item`McHugeLarge left pole`) || have($item`McHugeLarge duffel bag`)
? 1
: 0,

Macro.skill($skill`McHugeLarge Slash`),
{
equipmentRequirements: () =>
new Requirement([], { forceEquip: $items`McHugeLarge left pole` }),
preparation: () => {
if (
!have($item`McHugeLarge left pole`) &&
have($item`McHugeLarge duffel bag`)
) {
visitUrl("inventory.php?action=skiduffel&pwd");
}
return have($item`McHugeLarge left pole`);
},
},
),
];

/**
* Find an available banish source subject to constraints.
*
* @param constraints Preexisting constraints that restrict possible sources.
* @returns Banish source satisfying constraints, or null.
*/
export function tryFindSniff(
constraints?: FindActionSourceConstraints,
): ActionSource | null {
let source = findActionSource(sniffSources, constraints);

Check failure on line 129 in src/actions/Sniff.ts

View workflow job for this annotation

GitHub Actions / lint

'source' is never reassigned. Use 'const' instead

return source;
}

/**
* Ensure an available banish source subject to constraints.
* Throws an error if no source can be found.
*
* @param constraints Preexisting constraints that restrict possible sources.
* @returns Banish source satisfying constraints.
*/
export function ensureBanish(
constraints?: FindActionSourceConstraints,
): ActionSource {
const source = tryFindSniff(constraints);

if (!source) {
throw new Error("Failed to ensure Sniff source");
}

return source;
}
Loading