libram 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.d.ts +21 -5
- package/dist/lib.js +43 -6
- package/dist/modifier.d.ts +11 -0
- package/dist/modifier.js +25 -9
- package/dist/modifierTypes.d.ts +1 -1
- package/dist/overlappingNames.js +2 -0
- package/dist/property.js +18 -9
- package/dist/propertyTypes.d.ts +10 -4
- package/dist/propertyTypes.js +7 -4
- package/dist/resources/2006/CommaChameleon.js +1 -1
- package/dist/resources/2018/BoxingDaycare.d.ts +71 -0
- package/dist/resources/2018/BoxingDaycare.js +150 -0
- package/dist/resources/2022/Stillsuit.d.ts +2 -4
- package/dist/resources/2022/Stillsuit.js +3 -6
- package/dist/resources/index.d.ts +2 -1
- package/dist/resources/index.js +2 -1
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
package/dist/lib.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @module GeneralLibrary */
|
|
2
2
|
import { Effect, Element, Familiar, Item, Location, Monster, runCombat, Servant, Skill, Slot, Stat, Thrall, Coinmaster, MafiaClass } from "kolmafia";
|
|
3
|
+
import { ValueOf } from "./utils.js";
|
|
3
4
|
import { StringProperty } from "./propertyTypes.js";
|
|
4
5
|
/**
|
|
5
6
|
* Determines the current maximum Accordion Thief songs the player can have in their head
|
|
@@ -344,7 +345,7 @@ export declare const Environment: {
|
|
|
344
345
|
readonly Underground: "underground";
|
|
345
346
|
readonly Underwater: "underwater";
|
|
346
347
|
};
|
|
347
|
-
export type EnvironmentType =
|
|
348
|
+
export type EnvironmentType = ValueOf<typeof Environment>;
|
|
348
349
|
/**
|
|
349
350
|
* Determines the weight-coefficient of any leprechaunning that this familiar may find itself doing
|
|
350
351
|
* Assumes the familiar is nude and thus fails for hatrack & pantsrack
|
|
@@ -572,14 +573,29 @@ export declare const bulkRepriceShop: (items: Map<Item, {
|
|
|
572
573
|
* @returns The total weight of the given familiar
|
|
573
574
|
*/
|
|
574
575
|
export declare function totalFamiliarWeight(familiar?: Familiar, considerAdjustment?: boolean): number;
|
|
575
|
-
export declare const
|
|
576
|
-
export
|
|
576
|
+
export declare const regularFamiliarTags: readonly ["animal", "insect", "haseyes", "haswings", "fast", "bite", "flies", "hashands", "wearsclothes", "organic", "vegetable", "hovers", "edible", "food", "sentient", "cute", "mineral", "polygonal", "object", "undead", "cantalk", "evil", "orb", "spooky", "sleaze", "aquatic", "swims", "isclothes", "phallic", "stench", "hot", "hasbeak", "haslegs", "robot", "technological", "hard", "cold", "hasbones", "hasclaws", "reallyevil", "good", "person", "humanoid", "animatedart", "software", "hasshell", "hasstinger"];
|
|
577
|
+
export declare const pokefamUltTags: readonly ["ult_bearhug", "ult_sticktreats", "ult_owlstare", "ult_bloodbath", "ult_pepperscorn", "ult_rainbowstorm"];
|
|
578
|
+
export type PokefamUltTag = (typeof pokefamUltTags)[number];
|
|
579
|
+
export type RegularFamiliarTag = (typeof regularFamiliarTags)[number];
|
|
580
|
+
export type FamiliarTag = RegularFamiliarTag | PokefamUltTag;
|
|
577
581
|
/**
|
|
578
|
-
*
|
|
582
|
+
* Type guard function to determine if a tag is a regular familiar tag or a pokefam ult
|
|
583
|
+
* @param tag The familiar tag to check
|
|
584
|
+
* @returns Asserts that `tag` is a `RegularFamiliarTag`
|
|
585
|
+
*/
|
|
586
|
+
export declare function isRegularFamiliarTag(tag: string): tag is RegularFamiliarTag;
|
|
587
|
+
/**
|
|
588
|
+
* Find the tags (used in mumming trunk, stillsuit, etc) for a given familiar, EXCLUDING special tags used for pokefam ults
|
|
589
|
+
* @param familiar The familiar in question
|
|
590
|
+
* @returns An array of the familiar's tags
|
|
591
|
+
*/
|
|
592
|
+
export declare function getRegularFamiliarTags(familiar: Familiar): RegularFamiliarTag[];
|
|
593
|
+
/**
|
|
594
|
+
* Find the tags (used in mumming trunk, stillsuit, etc) for a given familiar, INCLUDING special tags used for pokefam ults
|
|
579
595
|
* @param familiar The familiar in question
|
|
580
596
|
* @returns An array of the familiar's tags
|
|
581
597
|
*/
|
|
582
|
-
export declare function
|
|
598
|
+
export declare function getAllFamiliarTags(familiar: Familiar): FamiliarTag[];
|
|
583
599
|
/**
|
|
584
600
|
* Determines the cost of acquiring an item taking into account your valueOfInventory preference
|
|
585
601
|
*
|
package/dist/lib.js
CHANGED
|
@@ -3,7 +3,7 @@ import { appearanceRates, autosellPrice, availableAmount, booleanModifier, choic
|
|
|
3
3
|
import logger from "./logger.js";
|
|
4
4
|
import { get } from "./property.js";
|
|
5
5
|
import { $class, $effect, $element, $familiar, $item, $items, $monsters, $skill, $stat, } from "./template-string.js";
|
|
6
|
-
import { makeByXFunction, notNull, clamp, chunk } from "./utils.js";
|
|
6
|
+
import { makeByXFunction, notNull, clamp, chunk, } from "./utils.js";
|
|
7
7
|
/**
|
|
8
8
|
* Determines the current maximum Accordion Thief songs the player can have in their head
|
|
9
9
|
*
|
|
@@ -1126,7 +1126,7 @@ export function totalFamiliarWeight(familiar = myFamiliar(), considerAdjustment
|
|
|
1126
1126
|
(considerAdjustment ? weightAdjustment() : 0) +
|
|
1127
1127
|
(familiar.feasted ? 10 : 0));
|
|
1128
1128
|
}
|
|
1129
|
-
export const
|
|
1129
|
+
export const regularFamiliarTags = Object.freeze([
|
|
1130
1130
|
"animal",
|
|
1131
1131
|
"insect",
|
|
1132
1132
|
"haseyes",
|
|
@@ -1172,17 +1172,54 @@ export const familiarTags = Object.freeze([
|
|
|
1172
1172
|
"humanoid",
|
|
1173
1173
|
"animatedart",
|
|
1174
1174
|
"software",
|
|
1175
|
-
"pokefam",
|
|
1176
1175
|
"hasshell",
|
|
1177
1176
|
"hasstinger",
|
|
1178
1177
|
]);
|
|
1178
|
+
const regularFamiliarTagSet = new Set(regularFamiliarTags);
|
|
1179
|
+
export const pokefamUltTags = Object.freeze([
|
|
1180
|
+
"ult_bearhug",
|
|
1181
|
+
"ult_sticktreats",
|
|
1182
|
+
"ult_owlstare",
|
|
1183
|
+
"ult_bloodbath",
|
|
1184
|
+
"ult_pepperscorn",
|
|
1185
|
+
"ult_rainbowstorm",
|
|
1186
|
+
]);
|
|
1187
|
+
const SPECIAL_ULTS = new Map([
|
|
1188
|
+
[$familiar `Nursine`, ["ult_bearhug"]],
|
|
1189
|
+
[$familiar `Caramel`, ["ult_sticktreats"]],
|
|
1190
|
+
[$familiar `Smashmoth`, ["ult_owlstare"]],
|
|
1191
|
+
[$familiar `Slotter`, ["ult_bloodbath"]],
|
|
1192
|
+
[$familiar `Cornbeefadon`, ["ult_pepperscorn"]],
|
|
1193
|
+
[$familiar `Mu`, ["ult_rainbowstorm"]],
|
|
1194
|
+
]);
|
|
1195
|
+
/**
|
|
1196
|
+
* Type guard function to determine if a tag is a regular familiar tag or a pokefam ult
|
|
1197
|
+
* @param tag The familiar tag to check
|
|
1198
|
+
* @returns Asserts that `tag` is a `RegularFamiliarTag`
|
|
1199
|
+
*/
|
|
1200
|
+
export function isRegularFamiliarTag(tag) {
|
|
1201
|
+
return regularFamiliarTagSet.has(tag);
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Find the tags (used in mumming trunk, stillsuit, etc) for a given familiar, EXCLUDING special tags used for pokefam ults
|
|
1205
|
+
* @param familiar The familiar in question
|
|
1206
|
+
* @returns An array of the familiar's tags
|
|
1207
|
+
*/
|
|
1208
|
+
export function getRegularFamiliarTags(familiar) {
|
|
1209
|
+
return familiar.attributes
|
|
1210
|
+
.split("; ")
|
|
1211
|
+
.filter(isRegularFamiliarTag);
|
|
1212
|
+
}
|
|
1179
1213
|
/**
|
|
1180
|
-
* Find the tags (used in mumming trunk, stillsuit, etc) for a given familiar
|
|
1214
|
+
* Find the tags (used in mumming trunk, stillsuit, etc) for a given familiar, INCLUDING special tags used for pokefam ults
|
|
1181
1215
|
* @param familiar The familiar in question
|
|
1182
1216
|
* @returns An array of the familiar's tags
|
|
1183
1217
|
*/
|
|
1184
|
-
export function
|
|
1185
|
-
return
|
|
1218
|
+
export function getAllFamiliarTags(familiar) {
|
|
1219
|
+
return [
|
|
1220
|
+
...getRegularFamiliarTags(familiar),
|
|
1221
|
+
...(SPECIAL_ULTS.get(familiar) ?? []),
|
|
1222
|
+
];
|
|
1186
1223
|
}
|
|
1187
1224
|
/**
|
|
1188
1225
|
* Determines the cost of acquiring an item taking into account your valueOfInventory preference
|
package/dist/modifier.d.ts
CHANGED
|
@@ -59,6 +59,11 @@ baseModifier?: string, componentColor?: string, totalColor?: string): void;
|
|
|
59
59
|
* @returns The sum of the appropriate modifier for all of the subjects
|
|
60
60
|
*/
|
|
61
61
|
export declare function getTotalModifier(modifier: NumericModifier, ...subjects: (Skill | Effect | Item)[]): number;
|
|
62
|
+
export type ModifierParser = {
|
|
63
|
+
numeric: (value: string) => number;
|
|
64
|
+
str: (value: string) => string;
|
|
65
|
+
bool: (value: string) => boolean;
|
|
66
|
+
};
|
|
62
67
|
/**
|
|
63
68
|
* Translate a pref into a `Modifiers` object by wrapping mafia's `splitModifiers`
|
|
64
69
|
* @param pref The name of the mafia preference in question
|
|
@@ -73,3 +78,9 @@ export declare function parseModifiers(pref: StringProperty, { numeric, str, boo
|
|
|
73
78
|
str: (value: string) => string;
|
|
74
79
|
bool: (value: string) => boolean;
|
|
75
80
|
}>): Modifiers;
|
|
81
|
+
/**
|
|
82
|
+
* Compile together all `Modifiers` something has
|
|
83
|
+
* @param thing An Item, Effect, or string to check all modifiers of
|
|
84
|
+
* @returns A `Modifiers` object corresponding to the givem Effect, Item, or string
|
|
85
|
+
*/
|
|
86
|
+
export declare function allModifiers(thing: Effect | Item | string): Modifiers;
|
package/dist/modifier.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { booleanModifier, cliExecuteOutput, familiarWeight, getProperty, myFamiliar, numericModifier, print, splitModifiers, stringModifier, } from "kolmafia";
|
|
1
|
+
import { booleanModifier, cliExecuteOutput, Effect, familiarWeight, getProperty, Item, myFamiliar, numericModifier, print, splitModifiers, stringModifier, } from "kolmafia";
|
|
2
2
|
import { have } from "./lib.js";
|
|
3
3
|
import { booleanModifiersSet, numericModifiersSet, stringModifiersSet, } from "./modifierTypes.js";
|
|
4
4
|
import { $effect } from "./template-string.js";
|
|
@@ -177,6 +177,16 @@ baseModifier, componentColor = "purple", totalColor = "blue") {
|
|
|
177
177
|
export function getTotalModifier(modifier, ...subjects) {
|
|
178
178
|
return sum(subjects, (subject) => get(modifier, subject));
|
|
179
179
|
}
|
|
180
|
+
function parseModifierString(modifiers, { numeric = Number, str = String, bool = (val) => val === "true", } = {}) {
|
|
181
|
+
return Object.entries(splitModifiers(modifiers)).reduce((acc, [key, value]) => ({
|
|
182
|
+
...acc,
|
|
183
|
+
[key]: isBooleanModifier(key)
|
|
184
|
+
? bool(value)
|
|
185
|
+
: isNumericModifier(key)
|
|
186
|
+
? numeric(value)
|
|
187
|
+
: str(value),
|
|
188
|
+
}), {});
|
|
189
|
+
}
|
|
180
190
|
/**
|
|
181
191
|
* Translate a pref into a `Modifiers` object by wrapping mafia's `splitModifiers`
|
|
182
192
|
* @param pref The name of the mafia preference in question
|
|
@@ -187,12 +197,18 @@ export function getTotalModifier(modifier, ...subjects) {
|
|
|
187
197
|
* @returns A `Modifiers` object corresponding to the given preference.
|
|
188
198
|
*/
|
|
189
199
|
export function parseModifiers(pref, { numeric = Number, str = String, bool = (val) => val === "true", } = {}) {
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
return parseModifierString(getProperty(pref), { numeric, str, bool });
|
|
201
|
+
}
|
|
202
|
+
const overloadedStringModifier = (thing, modifier) => thing instanceof Effect
|
|
203
|
+
? stringModifier(thing, modifier)
|
|
204
|
+
: thing instanceof Item
|
|
205
|
+
? stringModifier(thing, modifier)
|
|
206
|
+
: stringModifier(thing, modifier);
|
|
207
|
+
/**
|
|
208
|
+
* Compile together all `Modifiers` something has
|
|
209
|
+
* @param thing An Item, Effect, or string to check all modifiers of
|
|
210
|
+
* @returns A `Modifiers` object corresponding to the givem Effect, Item, or string
|
|
211
|
+
*/
|
|
212
|
+
export function allModifiers(thing) {
|
|
213
|
+
return parseModifierString(overloadedStringModifier(thing, "Modifiers"));
|
|
198
214
|
}
|
package/dist/modifierTypes.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export declare const booleanModifiers: readonly ["Softcore Only", "Single Equip"
|
|
|
5
5
|
export declare const booleanModifiersSet: Set<"Four Songs" | "Softcore Only" | "Single Equip" | "Always Fumble" | "Never Fumble" | "Weakens Monster" | "Free Pull" | "Variable" | "Nonstackable Watch" | "Cold Immunity" | "Hot Immunity" | "Sleaze Immunity" | "Spooky Immunity" | "Stench Immunity" | "Cold Vulnerability" | "Hot Vulnerability" | "Sleaze Vulnerability" | "Spooky Vulnerability" | "Stench Vulnerability" | "Moxie Controls MP" | "Moxie May Control MP" | "Adventure Randomly" | "Adventure Underwater" | "Underwater Familiar" | "Generic" | "Unarmed" | "No Pull" | "Lasts Until Rollover" | "Alters Page Text" | "Attacks Can't Miss" | "Pirate" | "Blind" | "Breakable" | "Drops Items" | "Drops Meat" | "Volleyball or Sombrero" | "Extra Pickpocket" | "Negative Status Resist">;
|
|
6
6
|
export type BooleanModifier = typeof booleanModifiers[number];
|
|
7
7
|
export declare const numericModifiers: readonly ["Familiar Weight", "Monster Level", "Combat Rate", "Initiative", "Experience", "Item Drop", "Meat Drop", "Damage Absorption", "Damage Reduction", "Cold Resistance", "Hot Resistance", "Sleaze Resistance", "Spooky Resistance", "Stench Resistance", "Mana Cost", "Moxie", "Moxie Percent", "Muscle", "Muscle Percent", "Mysticality", "Mysticality Percent", "Maximum HP", "Maximum HP Percent", "Maximum MP", "Maximum MP Percent", "Weapon Damage", "Ranged Damage", "Spell Damage", "Spell Damage Percent", "Cold Damage", "Hot Damage", "Sleaze Damage", "Spooky Damage", "Stench Damage", "Cold Spell Damage", "Hot Spell Damage", "Sleaze Spell Damage", "Spooky Spell Damage", "Stench Spell Damage", "Underwater Combat Rate", "Fumble", "HP Regen Min", "HP Regen Max", "MP Regen Min", "MP Regen Max", "Adventures", "Familiar Weight Percent", "Weapon Damage Percent", "Ranged Damage Percent", "Stackable Mana Cost", "Hobo Power", "Base Resting HP", "Resting HP Percent", "Bonus Resting HP", "Base Resting MP", "Resting MP Percent", "Bonus Resting MP", "Critical Hit Percent", "PvP Fights", "Volleyball", "Sombrero", "Leprechaun", "Fairy", "Meat Drop Penalty", "Hidden Familiar Weight", "Item Drop Penalty", "Initiative Penalty", "Food Drop", "Booze Drop", "Hat Drop", "Weapon Drop", "Offhand Drop", "Shirt Drop", "Pants Drop", "Accessory Drop", "Volleyball Effectiveness", "Sombrero Effectiveness", "Leprechaun Effectiveness", "Fairy Effectiveness", "Familiar Weight Cap", "Slime Resistance", "Slime Hates It", "Spell Critical Percent", "Muscle Experience", "Mysticality Experience", "Moxie Experience", "Effect Duration", "Candy Drop", "DB Combat Damage", "Sombrero Bonus", "Familiar Experience", "Sporadic Meat Drop", "Sporadic Item Drop", "Meat Bonus", "Pickpocket Chance", "Combat Mana Cost", "Muscle Experience Percent", "Mysticality Experience Percent", "Moxie Experience Percent", "Minstrel Level", "Muscle Limit", "Mysticality Limit", "Moxie Limit", "Song Duration", "Prismatic Damage", "Smithsness", "Supercold Resistance", "Reduce Enemy Defense", "Pool Skill", "Familiar Damage", "Gear Drop", "Maximum Hooch", "Water Level", "Crimbot Outfit Power", "Familiar Tuning Muscle", "Familiar Tuning Mysticality", "Familiar Tuning Moxie", "Random Monster Modifiers", "Luck", "Othello Skill", "Disco Style", "Rollover Effect Duration", "Sixgun Damage", "Fishing Skill", "Additional Song", "Sprinkle Drop", "Absorb Adventures", "Absorb Stats", "Rubee Drop", "Kruegerand Drop", "WarBear Armor Penetration", "Maximum PP", "Plumber Power", "Drippy Damage", "Drippy Resistance", "Energy", "Scrap", "Familiar Action Bonus", "Water", "Spleen Drop", "Potion Drop", "Sauce Spell Damage", "Monster Level Percent", "Food Fairy", "Booze Fairy", "Candy Fairy", "Food Fairy Effectiveness", "Booze Fairy Effectiveness", "Candy Fairy Effectiveness", "Damage Aura", "Sporadic Damage Aura", "Thorns", "Sporadic Thorns", "Stomach Capacity", "Liver Capacity", "Spleen Capacity", "Free Rests", "Leaves", "Elf Warfare Effectiveness", "Pirate Warfare Effectiveness", "MPC Drop", "Piece of Twelve Drop", "Combat Item Damage Percent", "Avoid Attack", "Damage vs. Bugbears", "Damage vs. Werewolves", "Damage vs. Zombies", "Damage vs. Ghosts", "Damage vs. Vampires", "Damage vs. Skeletons", "Damage vs. Undead"];
|
|
8
|
-
export declare const numericModifiersSet: Set<"Additional Song" | "Leprechaun Effectiveness" | "Meat Drop" | "Fairy Effectiveness" | "Item Drop" | "Moxie" | "Muscle" | "Mysticality" | "Familiar Weight" | "
|
|
8
|
+
export declare const numericModifiersSet: Set<"Additional Song" | "Leprechaun Effectiveness" | "Meat Drop" | "Fairy Effectiveness" | "Item Drop" | "Moxie" | "Muscle" | "Mysticality" | "Familiar Weight" | "Monster Level" | "Combat Rate" | "Initiative" | "Experience" | "Damage Absorption" | "Damage Reduction" | "Cold Resistance" | "Hot Resistance" | "Sleaze Resistance" | "Spooky Resistance" | "Stench Resistance" | "Mana Cost" | "Moxie Percent" | "Muscle Percent" | "Mysticality Percent" | "Maximum HP" | "Maximum HP Percent" | "Maximum MP" | "Maximum MP Percent" | "Weapon Damage" | "Ranged Damage" | "Spell Damage" | "Spell Damage Percent" | "Cold Damage" | "Hot Damage" | "Sleaze Damage" | "Spooky Damage" | "Stench Damage" | "Cold Spell Damage" | "Hot Spell Damage" | "Sleaze Spell Damage" | "Spooky Spell Damage" | "Stench Spell Damage" | "Underwater Combat Rate" | "Fumble" | "HP Regen Min" | "HP Regen Max" | "MP Regen Min" | "MP Regen Max" | "Adventures" | "Familiar Weight Percent" | "Weapon Damage Percent" | "Ranged Damage Percent" | "Stackable Mana Cost" | "Hobo Power" | "Base Resting HP" | "Resting HP Percent" | "Bonus Resting HP" | "Base Resting MP" | "Resting MP Percent" | "Bonus Resting MP" | "Critical Hit Percent" | "PvP Fights" | "Volleyball" | "Sombrero" | "Leprechaun" | "Fairy" | "Meat Drop Penalty" | "Hidden Familiar Weight" | "Item Drop Penalty" | "Initiative Penalty" | "Food Drop" | "Booze Drop" | "Hat Drop" | "Weapon Drop" | "Offhand Drop" | "Shirt Drop" | "Pants Drop" | "Accessory Drop" | "Volleyball Effectiveness" | "Sombrero Effectiveness" | "Familiar Weight Cap" | "Slime Resistance" | "Slime Hates It" | "Spell Critical Percent" | "Muscle Experience" | "Mysticality Experience" | "Moxie Experience" | "Effect Duration" | "Candy Drop" | "DB Combat Damage" | "Sombrero Bonus" | "Familiar Experience" | "Sporadic Meat Drop" | "Sporadic Item Drop" | "Meat Bonus" | "Pickpocket Chance" | "Combat Mana Cost" | "Muscle Experience Percent" | "Mysticality Experience Percent" | "Moxie Experience Percent" | "Minstrel Level" | "Muscle Limit" | "Mysticality Limit" | "Moxie Limit" | "Song Duration" | "Prismatic Damage" | "Smithsness" | "Supercold Resistance" | "Reduce Enemy Defense" | "Pool Skill" | "Familiar Damage" | "Gear Drop" | "Maximum Hooch" | "Water Level" | "Crimbot Outfit Power" | "Familiar Tuning Muscle" | "Familiar Tuning Mysticality" | "Familiar Tuning Moxie" | "Random Monster Modifiers" | "Luck" | "Othello Skill" | "Disco Style" | "Rollover Effect Duration" | "Sixgun Damage" | "Fishing Skill" | "Sprinkle Drop" | "Absorb Adventures" | "Absorb Stats" | "Rubee Drop" | "Kruegerand Drop" | "WarBear Armor Penetration" | "Maximum PP" | "Plumber Power" | "Drippy Damage" | "Drippy Resistance" | "Energy" | "Scrap" | "Familiar Action Bonus" | "Water" | "Spleen Drop" | "Potion Drop" | "Sauce Spell Damage" | "Monster Level Percent" | "Food Fairy" | "Booze Fairy" | "Candy Fairy" | "Food Fairy Effectiveness" | "Booze Fairy Effectiveness" | "Candy Fairy Effectiveness" | "Damage Aura" | "Sporadic Damage Aura" | "Thorns" | "Sporadic Thorns" | "Stomach Capacity" | "Liver Capacity" | "Spleen Capacity" | "Free Rests" | "Leaves" | "Elf Warfare Effectiveness" | "Pirate Warfare Effectiveness" | "MPC Drop" | "Piece of Twelve Drop" | "Combat Item Damage Percent" | "Avoid Attack" | "Damage vs. Bugbears" | "Damage vs. Werewolves" | "Damage vs. Zombies" | "Damage vs. Ghosts" | "Damage vs. Vampires" | "Damage vs. Skeletons" | "Damage vs. Undead">;
|
|
9
9
|
export type NumericModifier = typeof numericModifiers[number];
|
|
10
10
|
export type ModifierType = NumericModifier | StringModifier | BooleanModifier;
|
package/dist/overlappingNames.js
CHANGED
package/dist/property.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bounty, Class, Coinmaster, Effect, Element, Familiar, getProperty, Item, Location, Monster, Phylum, propertyExists, removeProperty, Servant, setProperty, Skill, Slot, Stat, Thrall, toBounty, toClass, toCoinmaster, toEffect, toElement, toFamiliar, toItem, toLocation, toMonster, toPhylum, toServant, toSkill, toSlot, toStat, toThrall, } from "kolmafia";
|
|
2
|
+
import { familiarNumericProperties, itemNumericProperties, monsterNumericProperties, } from "./propertyTypes.js";
|
|
2
3
|
import { isBooleanProperty, isFamiliarProperty, isItemProperty, isLocationProperty, isMonsterProperty, isNumericOrStringProperty, isNumericProperty, isPhylumProperty, isStatProperty, isStringProperty, } from "./propertyTyping.js";
|
|
3
4
|
const createPropertyGetter = (transform) => (property, default_) => {
|
|
4
5
|
const value = getProperty(property);
|
|
@@ -7,12 +8,20 @@ const createPropertyGetter = (transform) => (property, default_) => {
|
|
|
7
8
|
}
|
|
8
9
|
return transform(value, property);
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
function createMafiaClassPropertyGetter(Type,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
toType, numericPropertyNames = []) {
|
|
14
|
+
return createPropertyGetter((value, property) => {
|
|
15
|
+
if (value === "")
|
|
16
|
+
return null;
|
|
17
|
+
const v = numericPropertyNames.includes(property)
|
|
18
|
+
? value.match(/^[0-9]+$/)
|
|
19
|
+
? toType(parseInt(value))
|
|
20
|
+
: null
|
|
21
|
+
: toType(value);
|
|
22
|
+
return v === Type.none ? null : v;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
16
25
|
export const getString = createPropertyGetter((value) => value);
|
|
17
26
|
export const getCommaSeparated = createPropertyGetter((value) => value.split(/, ?/));
|
|
18
27
|
export const getBoolean = createPropertyGetter((value) => value === "true");
|
|
@@ -22,10 +31,10 @@ export const getClass = createMafiaClassPropertyGetter(Class, toClass);
|
|
|
22
31
|
export const getCoinmaster = createMafiaClassPropertyGetter(Coinmaster, toCoinmaster);
|
|
23
32
|
export const getEffect = createMafiaClassPropertyGetter(Effect, toEffect);
|
|
24
33
|
export const getElement = createMafiaClassPropertyGetter(Element, toElement);
|
|
25
|
-
export const getFamiliar = createMafiaClassPropertyGetter(Familiar, toFamiliar);
|
|
26
|
-
export const getItem = createMafiaClassPropertyGetter(Item, toItem);
|
|
34
|
+
export const getFamiliar = createMafiaClassPropertyGetter(Familiar, toFamiliar, familiarNumericProperties);
|
|
35
|
+
export const getItem = createMafiaClassPropertyGetter(Item, toItem, itemNumericProperties);
|
|
27
36
|
export const getLocation = createMafiaClassPropertyGetter(Location, toLocation);
|
|
28
|
-
export const getMonster = createMafiaClassPropertyGetter(Monster, toMonster);
|
|
37
|
+
export const getMonster = createMafiaClassPropertyGetter(Monster, toMonster, monsterNumericProperties);
|
|
29
38
|
export const getPhylum = createMafiaClassPropertyGetter(Phylum, toPhylum);
|
|
30
39
|
export const getServant = createMafiaClassPropertyGetter(Servant, toServant);
|
|
31
40
|
export const getSkill = createMafiaClassPropertyGetter(Skill, toSkill);
|