-
Notifications
You must be signed in to change notification settings - Fork 25
Expose a withMacro function that lets you carry out some arbitrary action with the given macro #834
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
base: main
Are you sure you want to change the base?
Conversation
| * Create and set a CCS file from a given Macro | ||
| * @param macro Macro to set as CSS | ||
| */ | ||
| export function makeCcs<M extends StrictMacro>(macro: M) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function makeCcs<M extends StrictMacro>(macro: M) { | |
| export function makeCcs<M extends Macro>(macro: M) { |
While the garbo version extends the hotter and cooler StrictMacro class, which we use exclusively, this should probably use the OG
| export function runCombatBy<T>(initiateCombatAction: () => T) { | ||
| try { | ||
| const result = initiateCombatAction(); | ||
| while (inMultiFight()) runCombat(); | ||
| if (choiceFollowsFight()) visitUrl("choice.php"); | ||
| return result; | ||
| } catch (e) { | ||
| throw `Combat exception! Last macro error: ${get( | ||
| "lastMacroError", | ||
| )}. Exception ${e}.`; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function runCombatBy<T>(initiateCombatAction: () => T) { | |
| try { | |
| const result = initiateCombatAction(); | |
| while (inMultiFight()) runCombat(); | |
| if (choiceFollowsFight()) visitUrl("choice.php"); | |
| return result; | |
| } catch (e) { | |
| throw `Combat exception! Last macro error: ${get( | |
| "lastMacroError", | |
| )}. Exception ${e}.`; | |
| } | |
| } | |
| export function runCombatBy<T>(initiateCombatAction: () => T, ...combatParams: CombatParams) { | |
| try { | |
| const result = initiateCombatAction(); | |
| while (inMultiFight()) runCombat(...combatParams); | |
| if (choiceFollowsFight()) visitUrl("choice.php"); | |
| return result; | |
| } catch (e) { | |
| throw `Combat exception! Last macro error: ${get( | |
| "lastMacroError", | |
| )}. Exception ${e}.`; | |
| } | |
| } |
| if (macroOrAction instanceof Macro || actionOrTryAuto === true) { | ||
| macro.setAutoAttack(); | ||
| } | ||
|
|
||
| // Make a CCS of the macro or, if we have two, the second macro. | ||
| makeCcs(macroOrAction instanceof Macro ? macroOrAction : macro); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overloads bamboozled me a little bit but I trust TS that this is correct
No description provided.