/** * @file Type definitions for KoLmafia's standard (runtime) library. * * Note: This module contains uncategorized library functions. * See modules named `kolmafia-*.d.ts` for categorized functions. */ import './global'; // These type definitions are derived from kolmafia-js v1.0.4, written by Samuel // Gaus (@gausie). kolmafia-js provides type definitions generated from // KoLmafia's source code. kolmafia-js is released under the MIT license: /* Copyright (c) 2020 Samuel Gaus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * Immediately halts the current script and all queued functions. */ export function abort(): never; /** * Immediately halts the current script and all queued functions. * @param message Message to print */ export function abort(message: string): never; /** * Adds `qty` of `item` to your current adventuring conditions. Auto-adventuring * through KoLmafia or the `adventure()` function will stop if your current * conditions are met. * * Note that this function adds items in "+ mode" rather than the standard * "total mode" done via the Adventuring pane of KoLmafia; i.e. it will add a * condition to get `qty` additional items, rather than a condition to have * `qty` total items in inventory. * @param qty Desired quantity * @param item Desired item */ export function addItemCondition(qty: number, item: Item): void; /** * Adds `qty` of `item` to your current adventuring conditions. Auto-adventuring * through KoLmafia or the `adventure()` function will stop if your current * conditions are met. * * Note that this function adds items in "+ mode" rather than the standard * "total mode" done via the Adventuring pane of KoLmafia; i.e. it will add a * condition to get `qty` additional items, rather than a condition to have * `qty` total items in inventory. * @param item Desired item * @param qty Desired quantity */ export function addItemCondition(item: Item, qty: number): void; type CombatFilterCallback = ( round: number, enemy: Monster, page: string ) => string; /** * Adventure exactly once in the specified `place` (even if it takes no turns), * although it will follow chained choice adventures for as long as you have * preset options. * @version r20740 * @param place Adventuring location * @return `true` if all adventures were used, or `false` otherwise (e.g. not * enough adventures, location unavailable). Also returns `false` if you * successfully adventured in a zone, but KoLmafia was put into a "PENDING" * state, which indicates that we might be done adventuring in this location * (usually because we finished the quest-related action in that zone). */ export function adv1(place: Location): boolean; /** * Adventure exactly once in the specified `place` (even if it takes no turns), * although it will follow chained choice adventures for as long as you have * preset options. * @version r20740 * @param place Adventuring location * @param turnsUsed Overrides the normal number of adventures that are expected * to be consumed at this location, or -1 can be passed to use the default. * Specifically, 0 will prevent any counters from triggering - of course, if * an adventure actually is consumed, any counters that you kept from * triggering will be lost. * @return `true` if all adventures were used, or `false` otherwise (e.g. not * enough adventures, location unavailable). Also returns `false` if you * successfully adventured in a zone, but KoLmafia was put into a "PENDING" * state, which indicates that we might be done adventuring in this location * (usually because we finished the quest-related action in that zone). */ export function adv1(place: Location, turnsUsed: number): boolean; /** * Adventure exactly once in the specified `place` (even if it takes no turns), * although it will follow chained choice adventures for as long as you have * preset options. * @param place Adventuring location * @param turnsUsed Overrides the normal number of adventures that are expected * to be consumed at this location, or -1 can be passed to use the default. * Specifically, 0 will prevent any counters from triggering - of course, if * an adventure actually is consumed, any counters that you kept from * triggering will be lost. * @param filter Combat filter string. * If this is an empty string, KoLmafia will use your normal combat settings. * Otherwise, this is treated as a combat macro string, and _must_ contain at * least one semicolon (`;`). * * Note: Unlike the ASH version, you cannot pass the name of a function as * the argument! * @return `true` if all adventures were used, or `false` otherwise (e.g. not * enough adventures, location unavailable). Also returns `false` if you * successfully adventured in a zone, but KoLmafia was put into a "PENDING" * state, which indicates that we might be done adventuring in this location * (usually because we finished the quest-related action in that zone). */ export function adv1( place: Location, turnsUsed: number, filter: string ): boolean; /** * Adventure exactly once in the specified `place` (even if it takes no turns), * although it will follow chained choice adventures for as long as you have * preset options. * @version r20738 * @param place Adventuring location * @param turnsUsed Overrides the normal number of adventures that are expected * to be consumed at this location, or -1 can be passed to use the default. * Specifically, 0 will prevent any counters from triggering - of course, if * an adventure actually is consumed, any counters that you kept from * triggering will be lost. * @param filterCallback Combat filter function. * A combat filter function takes three arguments: the current round number * (integer), the enemy monster, and the HTML source of the current fight * page (string). It must return a string containing combat macro(s). * KoLmafia will call this function (possibly multiple times) to obtain the * next combat action. * @return `true` if all adventures were used, or `false` otherwise (e.g. not * enough adventures, location unavailable). Also returns `false` if you * successfully adventured in a zone, but KoLmafia was put into a "PENDING" * state, which indicates that we might be done adventuring in this location * (usually because we finished the quest-related action in that zone). */ export function adv1( place: Location, turnsUsed: number, filterCallback: CombatFilterCallback ): boolean; /** * Returns the adventure cost for the next cast of the given skill. * @param skill Skill to check the cost of * @return Adventure cost of the skill */ export function advCost(skill: Skill): number; /** * Spends `adventures` at the `place`, keeping up your current mood & obeying * restore settings. This uses your current CSS / battle action script. * @param place Adventuring location * @param adventures Number of adventures to spend. Any "free" turns (e.g choice * adventures that don't consume an adventure) or adventures spent in other * locations (e.g. by a `counterScript` or a `betweenBattleScript`) do not * count towards this total. * @return `true` if the specified number of adventures were used, or `false` * otherwise (e.g. not enough adventures, location unavailable, all goals * satisfied while adventuring, or auto-stop triggered). */ export function adventure(place: Location, adventures: number): boolean; /** * Spends `adventures` at the `place`, keeping up your current mood & obeying * restore settings. This uses your current CSS / battle action script. * @param adventures Number of adventures to spend. Any "free" turns (e.g choice * adventures that don't consume an adventure) or adventures spent in other * locations (e.g. by a `counterScript` or a `betweenBattleScript`) do not * count towards this total. * @param place Adventuring location * @return `true` if the specified number of adventures were used, or `false` * otherwise (e.g. not enough adventures, location unavailable, all goals * satisfied while adventuring, or auto-stop triggered). */ export function adventure(adventures: number, place: Location): boolean; /** * Spends `adventures` at the `place`, keeping up your current mood & obeying * restore settings. * @param place Adventuring location * @param adventures Number of adventures to spend. Any "free" turns (e.g choice * adventures that don't consume an adventure) or adventures spent in other * locations (e.g. by a `counterScript` or a `betweenBattleScript`) do not * count towards this total. * @param filter Combat filter string. * If this is an empty string, KoLmafia will use your normal combat settings. * Otherwise, this is treated as a combat macro string, and _must_ contain at * least one semicolon (`;`). * * Note: Unlike the ASH version, you cannot pass the name of a function as * the argument! * @return `true` if the specified number of adventures were used, or `false` * otherwise (e.g. not enough adventures, location unavailable, all goals * satisfied while adventuring, or auto-stop triggered). */ export function adventure( place: Location, adventures: number, filter: string ): boolean; /** * Spends `adventures` at the `place`, keeping up your current mood & obeying * restore settings. * @version r20738 * @param place Adventuring location * @param adventures Number of adventures to spend. Any "free" turns (e.g choice * adventures that don't consume an adventure) or adventures spent in other * locations (e.g. by a `counterScript` or a `betweenBattleScript`) do not * count towards this total. * @param filterCallback Combat filter function. * A combat filter function takes three arguments: the current round number * (integer), the enemy monster, and the HTML source of the current fight * page (string). It must return a string containing combat macro(s). * KoLmafia will call this function (possibly multiple times) to obtain the * next combat action. * @return `true` if the specified number of adventures were used, or `false` * otherwise (e.g. not enough adventures, location unavailable, all goals * satisfied while adventuring, or auto-stop triggered). */ export function adventure( place: Location, adventures: number, filterCallback: CombatFilterCallback ): boolean; /** * Spends `adventures` at the `place`, keeping up your current mood & obeying * restore settings. * @param adventures Number of adventures to spend. Any "free" turns (e.g choice * adventures that don't consume an adventure) or adventures spent in other * locations (e.g. by a `counterScript` or a `betweenBattleScript`) do not * count towards this total. * @param place Adventuring location * @param filter Combat filter string. * If this is an empty string, KoLmafia will use your normal combat settings. * Otherwise, this is treated as a combat macro string, and _must_ contain at * least one semicolon (`;`). * * Note: Unlike the ASH version, you cannot pass the name of a function as * the argument! * @return `true` if the specified number of adventures were used, or `false` * otherwise (e.g. not enough adventures, location unavailable, all goals * satisfied while adventuring, or auto-stop triggered). */ export function adventure( adventures: number, place: Location, filter: string ): boolean; /** * Spends `adventures` at the `place`, keeping up your current mood & obeying * restore settings. * @version r20738 * @param adventures Number of adventures to spend. Any "free" turns (e.g choice * adventures that don't consume an adventure) or adventures spent in other * locations (e.g. by a `counterScript` or a `betweenBattleScript`) do not * count towards this total. * @param place Adventuring location * @param filterCallback Combat filter function. * A combat filter function takes three arguments: the current round number * (integer), the enemy monster, and the HTML source of the current fight * page (string). It must return a string containing combat macro(s). * KoLmafia will call this function (possibly multiple times) to obtain the * next combat action. * @return `true` if the specified number of adventures were used, or `false` * otherwise (e.g. not enough adventures, location unavailable, all goals * satisfied while adventuring, or auto-stop triggered). */ export function adventure( adventures: number, place: Location, filterCallback: CombatFilterCallback ): boolean; /** * Retrieves the up-to-date internal list of known monsters. * * This function is needed because `$monsters[]` contains a list of monsters * that is fixed when an ASH script begins execution, and does not change while * the script is running. * (*NOTE: It is unclear whether this function is redundant in JavaScript.*) * @return Collection of all monsters that have a non-zero monster ID */ export function allMonstersWithId(): {[monster: string]: boolean}; /** * Returns a list of all available in-game outfits. */ export function allNormalOutfits(): string[]; /** * Returns a collection, keyed by monster, with the appearance rate percentages * as decimal values (i.e. a 30%-rate monster has a value of 30.0). This * accounts for combat rate modifiers, olfaction, etc. as best as it can. * * - Bosses, semirare encounters, and other one-time-only monsters have a value * of 0.0. Ultra-Rare monsters have a value of -1.0. * - Impossible monsters (mostly just monsters that only appear on odd/even * ascensions) have a value of -2.0. (Properly, as in not-also-olfacted) * - Banished monsters have a value of -3.0. * - Monsters banished by in-game mechanics (such as pygmy janitors in the * Hidden City) have a value of -4.0 (is often mixed up with 0.0 values). * * If there is a chance of non-combat encounters, that will be listed as the * chance of encountering `none`. * @param place Adventuring location * @return Mapping of monster names to appearance rates as percentages */ export function appearanceRates(place: Location): {[monster: string]: number}; /** * Returns a collection, keyed by monster, with the appearance rate percentages * as decimal values (i.e. a 30%-rate monster has a value of 30.0). This * accounts for combat rate modifiers, olfaction, etc. as best as it can. * * - Bosses, semirare encounters, and other one-time-only monsters have a value * of 0.0. Ultra-Rare monsters have a value of -1.0. * - Impossible monsters (mostly just monsters that only appear on odd/even * ascensions) have a value of -2.0. (Properly, as in not-also-olfacted) * - Banished monsters have a value of -3.0. * - Monsters banished by in-game mechanics (such as pygmy janitors in the * Hidden City) have a value of -4.0 (is often mixed up with 0.0 values). * * If there is a chance of non-combat encounters, that will be listed as the * chance of encountering `none`. * @param place Adventuring location * @param includeQueue If true, this considers monsters in the adventuring queue * when determining the likelihood of future encounters. This is better for a * real prediction of what monster will actually occur. For modeling * theoretical situations, it is better to not consider the queue. * @return Mapping of monster names to appearance rates as percentages */ export function appearanceRates( place: Location, includeQueue: boolean ): {[monster: string]: number}; /** * Attacks with your weapon inside a consult script. * @return HTML response from the attack attempt */ export function attack(): string; /** * Autosells up to `qty` of `item`. * @param item Item to sell * @param qty Quantity to sell * @return `true` if the item(s) were sold, or `false` on failure. * Note that specifying a higher `qty` than you have of an item, or an item * that cannot be autosold, will still return `true` as the function has done * as much as it could. */ export function autosell(item: Item, qty: number): boolean; /** * Autosells up to `qty` of `item`. * @param item Item to sell * @param qty Quantity to sell * @return `true` if the item(s) were sold, or `false` on failure. * Note that specifying a higher `qty` than you have of an item, or an item * that cannot be autosold, will still return `true` as the function has done * as much as it could. */ export function autosell(qty: number, item: Item): boolean; /** * Returns the autosell price of an item, or a value <= 0 if the item cannot be * autosold. * * For most items that cannot be autosold, such as common Quest Items, this will * return 0. In a few unusual cases where an item can't be autosold, but does * have a defined value detectable by other means (e.g. a mall minimum price * other than 100, or a price in one of the sign restaurants), this will return * a negative value. For example, the laser-broiled pear is an example of a * non-autosellable item with a value detectable both ways. * @param item Item to check the price of * @return Autosell price, or a value <= 0 if the item cannot be autosold. */ export function autosellPrice(item: Item): number; /** * Returns the total number available of a given item in all inventory sections * accessible to your character based on current restrictions, including * equipped items (for equipment). In Ronin, this includes free pulls, but does * not include any other items in Hangk's Storage. Once out of Ronin/Hardcore, * if `autoSatisfyWithStorage` is set to true, this includes items in Hangk's * Storage. If `autoSatisfyWithCloset` is set to true, this includes the closet. * If `autoSatisfyWithStash` is set to true, this includes clan stash. * @param item Item to check * @return Available amount, based on current restrictions */ export function availableAmount(item: Item): number; /** * Returns all available choice options in the current (or last) choice * adventure the player encountered. * @return Mapping of choice number to choice button text */ export function availableChoiceOptions(): {[key: number]: string}; /** * Returns all available choice options in the current (or last) choice * adventure the player encountered. * @param spoilers If `true`, also adds KoLmafia-generated spoiler text to each * choice button text * @return Mapping of choice number to choice button text */ export function availableChoiceOptions(spoilers: boolean): { [key: number]: string; }; /** * For the `decision` choice in the current (or last) choice adventure, returns * all selectable items in the dropdown(s) for the choice. * @param decision Choice number * @return Object that represents all `` tag, and each * value is an object that contains the `value` attribute and text of all * `