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

create MacroPredicate and CompoundMacroPredicate types #468

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
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
54 changes: 54 additions & 0 deletions src/combat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
setAutoAttack,
Skill,
Stat,
StatType,
toInt,
urlEncode,
visitUrl,
Expand Down Expand Up @@ -98,6 +99,59 @@ function itemOrItemsBallsMacroPredicate(
}
}

type RawNumberMacroPredicate =
| "times"
| "hpbelow"
| "hppercentbelow"
| "mpbelow"
| "mppercentbelow"
| "didcritical"
| "beenhit"
| "missed"
| "familiarattacked"
| "gotjump"
| "pastround"
| "monsterhpabove"
| "monsterhpbelow"
| "snarfblat";
type RawStringMacroPredicate = "match" | "monstername" | "happymediumglow";
type RawNumberOrStringMacroPredicate =
| "haseffect"
| "hascombatitem"
| "monsterid"
| "hasskill";
type NudeMacroPredicate =
| "sealclubber"
| "turtletamer"
| "pastamancer"
| "sauceror"
| "discobandit"
| "accordionthief"
| `${Lowercase<StatType>}class`;
export type MacroPredicate =
| `${RawNumberMacroPredicate} ${number}`
| `${RawStringMacroPredicate} ${string}`
| `${RawNumberOrStringMacroPredicate} ${number | string}`
| NudeMacroPredicate;

type Predicate<
T extends string,
N extends number,
R extends unknown[]
> = R["length"] extends N
? T
: Predicate<
T | `!(${T})` | `(${T})` | `${T} || ${T}` | `${T} && ${T}`,
N,
[unknown, ...R]
>;

export type CompoundMacroPredicate<Depth extends number> = Predicate<
MacroPredicate,
Depth,
[]
>;

type PreBALLSPredicate =
| string
| Monster
Expand Down