libram 0.8.35 → 0.8.37

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.
Files changed (137) hide show
  1. package/dist/Clan.js +3 -3
  2. package/dist/Dungeon.js +4 -4
  3. package/dist/Kmail.js +3 -3
  4. package/dist/Macro.test.d.ts +1 -0
  5. package/dist/Macro.test.js +126 -0
  6. package/dist/actions/ActionSource.d.ts +2 -2
  7. package/dist/actions/ActionSource.js +3 -3
  8. package/dist/actions/Banish.d.ts +1 -1
  9. package/dist/actions/Banish.js +7 -7
  10. package/dist/actions/FreeKill.d.ts +1 -1
  11. package/dist/actions/FreeKill.js +7 -7
  12. package/dist/actions/FreeRun.d.ts +1 -1
  13. package/dist/actions/FreeRun.js +8 -8
  14. package/dist/actions/index.d.ts +4 -4
  15. package/dist/actions/index.js +4 -4
  16. package/dist/ascend.d.ts +2 -2
  17. package/dist/ascend.js +5 -5
  18. package/dist/challengePaths/2014/HeavyRains.js +3 -3
  19. package/dist/challengePaths/2015/CommunityService.d.ts +1 -1
  20. package/dist/challengePaths/2015/CommunityService.js +6 -6
  21. package/dist/challengePaths/2016/NuclearAutumn.js +1 -1
  22. package/dist/challengePaths/index.d.ts +3 -3
  23. package/dist/challengePaths/index.js +3 -3
  24. package/dist/combat.d.ts +13 -7
  25. package/dist/combat.js +39 -30
  26. package/dist/diet/index.js +7 -7
  27. package/dist/diet/knapsack.js +1 -1
  28. package/dist/diet/knapsack.test.d.ts +1 -0
  29. package/dist/diet/knapsack.test.js +77 -0
  30. package/dist/index.d.ts +29 -29
  31. package/dist/index.js +26 -26
  32. package/dist/lib.d.ts +4 -2
  33. package/dist/lib.js +6 -4
  34. package/dist/lib.test.d.ts +1 -0
  35. package/dist/lib.test.js +142 -0
  36. package/dist/maximize.js +4 -4
  37. package/dist/modifier.d.ts +1 -1
  38. package/dist/modifier.js +4 -4
  39. package/dist/mood.js +5 -5
  40. package/dist/property.d.ts +2 -2
  41. package/dist/property.js +1 -1
  42. package/dist/propertyTypes.d.ts +2 -2
  43. package/dist/propertyTypes.js +2 -2
  44. package/dist/propertyTyping.d.ts +1 -1
  45. package/dist/propertyTyping.js +1 -1
  46. package/dist/resources/2007/CandyHearts.js +2 -2
  47. package/dist/resources/2008/DivineFavors.js +3 -3
  48. package/dist/resources/2008/Stickers.js +1 -1
  49. package/dist/resources/2009/Bandersnatch.js +3 -3
  50. package/dist/resources/2009/LoveSongs.js +2 -2
  51. package/dist/resources/2009/SpookyPutty.js +3 -3
  52. package/dist/resources/2010/Brickos.js +3 -3
  53. package/dist/resources/2010/CrownOfThrones.d.ts +1 -1
  54. package/dist/resources/2010/CrownOfThrones.js +4 -4
  55. package/dist/resources/2010/LookingGlass.js +3 -3
  56. package/dist/resources/2011/Gygaxian.js +2 -2
  57. package/dist/resources/2011/ObtuseAngel.d.ts +1 -1
  58. package/dist/resources/2011/ObtuseAngel.js +4 -4
  59. package/dist/resources/2011/StompingBoots.js +3 -3
  60. package/dist/resources/2012/RainDoh.js +3 -3
  61. package/dist/resources/2012/ReagnimatedGnome.js +2 -2
  62. package/dist/resources/2012/Resolutions.js +2 -2
  63. package/dist/resources/2013/Florist.d.ts +2 -2
  64. package/dist/resources/2013/Florist.js +4 -4
  65. package/dist/resources/2013/JungMan.js +2 -2
  66. package/dist/resources/2013/PulledTaffy.js +3 -3
  67. package/dist/resources/2014/CrimboShrub.js +3 -3
  68. package/dist/resources/2014/DNALab.js +5 -5
  69. package/dist/resources/2014/WinterGarden.d.ts +1 -1
  70. package/dist/resources/2014/WinterGarden.js +4 -4
  71. package/dist/resources/2015/BarrelShrine.js +3 -3
  72. package/dist/resources/2015/ChateauMantegna.d.ts +1 -1
  73. package/dist/resources/2015/ChateauMantegna.js +1 -1
  74. package/dist/resources/2015/DeckOfEveryCard.js +4 -4
  75. package/dist/resources/2015/Dinseylandfill.js +3 -3
  76. package/dist/resources/2015/MayoClinic.js +4 -4
  77. package/dist/resources/2016/GingerBread.js +2 -2
  78. package/dist/resources/2016/SourceTerminal.d.ts +1 -1
  79. package/dist/resources/2016/SourceTerminal.js +5 -5
  80. package/dist/resources/2016/Witchess.d.ts +1 -1
  81. package/dist/resources/2016/Witchess.js +3 -3
  82. package/dist/resources/2017/AsdonMartin.js +3 -3
  83. package/dist/resources/2017/Horsery.d.ts +1 -1
  84. package/dist/resources/2017/Horsery.js +1 -1
  85. package/dist/resources/2017/MummingTrunk.d.ts +1 -1
  86. package/dist/resources/2017/MummingTrunk.js +1 -1
  87. package/dist/resources/2017/Pantogram.js +2 -2
  88. package/dist/resources/2017/Robortender.js +2 -2
  89. package/dist/resources/2017/Spacegate.js +2 -2
  90. package/dist/resources/2017/TunnelOfLove.d.ts +1 -1
  91. package/dist/resources/2017/TunnelOfLove.js +4 -4
  92. package/dist/resources/2018/LatteLoversMembersMug.d.ts +1 -1
  93. package/dist/resources/2018/LatteLoversMembersMug.js +5 -5
  94. package/dist/resources/2018/SongBoom.js +3 -3
  95. package/dist/resources/2019/BeachComb.js +4 -4
  96. package/dist/resources/2019/CampAway.js +4 -4
  97. package/dist/resources/2019/Snapper.js +1 -1
  98. package/dist/resources/2020/Cartography.js +3 -3
  99. package/dist/resources/2020/Guzzlr.js +4 -4
  100. package/dist/resources/2020/RetroCape.d.ts +1 -1
  101. package/dist/resources/2020/RetroCape.js +3 -3
  102. package/dist/resources/2021/CrystalBall.js +3 -3
  103. package/dist/resources/2021/DaylightShavings.js +3 -3
  104. package/dist/resources/2022/AutumnAton.js +4 -4
  105. package/dist/resources/2022/CombatLoversLocket.d.ts +1 -1
  106. package/dist/resources/2022/CombatLoversLocket.js +4 -4
  107. package/dist/resources/2022/GreyGoose.js +4 -4
  108. package/dist/resources/2022/JuneCleaver.js +1 -1
  109. package/dist/resources/2022/TrainSet.d.ts +1 -1
  110. package/dist/resources/2022/TrainSet.js +4 -4
  111. package/dist/resources/2023/AugustScepter.d.ts +1 -1
  112. package/dist/resources/2023/AugustScepter.js +3 -3
  113. package/dist/resources/2023/BurningLeaves.js +3 -3
  114. package/dist/resources/2023/CinchoDeMayo.js +4 -4
  115. package/dist/resources/2023/ClosedCircuitPayphone.d.ts +2 -1
  116. package/dist/resources/2023/ClosedCircuitPayphone.js +5 -4
  117. package/dist/resources/2023/CursedMonkeyPaw.js +5 -5
  118. package/dist/resources/2024/AprilingBandHelmet.js +4 -4
  119. package/dist/resources/2024/ChestMimic.d.ts +1 -1
  120. package/dist/resources/2024/ChestMimic.js +3 -3
  121. package/dist/resources/2024/MayamCalendar.d.ts +12 -0
  122. package/dist/resources/2024/MayamCalendar.js +23 -6
  123. package/dist/resources/LibramSummon.js +10 -10
  124. package/dist/resources/index.d.ts +54 -54
  125. package/dist/resources/index.js +54 -54
  126. package/dist/resources/putty-likes.d.ts +1 -1
  127. package/dist/resources/putty-likes.js +3 -3
  128. package/dist/session.js +3 -3
  129. package/dist/template-string.d.ts +18 -1
  130. package/dist/template-string.js +2 -1
  131. package/dist/url.test.d.ts +1 -0
  132. package/dist/url.test.js +147 -0
  133. package/dist/utils.d.ts +1 -1
  134. package/dist/utils.js +2 -2
  135. package/dist/utils.test.d.ts +1 -0
  136. package/dist/utils.test.js +8 -0
  137. package/package.json +7 -9
package/dist/Clan.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { decode as decodeEntities } from "html-entities";
2
2
  import { availableAmount, cliExecute, getClanId, getClanName, getPlayerId, Monster, putStash, refreshStash, retrieveItem, stashAmount, takeStash, visitUrl, xpath, } from "kolmafia";
3
- import { getFoldGroup } from "./lib";
4
- import logger from "./logger";
5
- import { arrayToCountedMap, countedMapToArray, countedMapToString, notNull, parseNumber, } from "./utils";
3
+ import { getFoldGroup } from "./lib.js";
4
+ import logger from "./logger.js";
5
+ import { arrayToCountedMap, countedMapToArray, countedMapToString, notNull, parseNumber, } from "./utils.js";
6
6
  const clanIdCache = {};
7
7
  const toPlayerId = (player) => typeof player === "string" ? getPlayerId(player) : player;
8
8
  const LOG_FAX_PATTERN = /(\d{2}\/\d{2}\/\d{2}, \d{2}:\d{2}(?:AM|PM): )<a [^>]+>([^<]+)<\/a>(?: faxed in a (?<monster>.*?))<br>/;
package/dist/Dungeon.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { getClanName, toItem, visitUrl, xpath } from "kolmafia";
2
- import { Clan } from "./Clan";
3
- import { getPlayerFromIdOrName } from "./lib";
4
- import { $items } from "./template-string";
5
- import { countedMapToArray } from "./utils";
2
+ import { Clan } from "./Clan.js";
3
+ import { getPlayerFromIdOrName } from "./lib.js";
4
+ import { $items } from "./template-string.js";
5
+ import { countedMapToArray } from "./utils.js";
6
6
  export class Dungeon {
7
7
  name_;
8
8
  loot;
package/dist/Kmail.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { decode as decodeEntities } from "html-entities";
2
2
  import { extractMeat, isGiftable, visitUrl } from "kolmafia";
3
- import { extractItems } from "./lib";
4
- import { combineQuery, EMPTY_VALUE, fetchUrl } from "./url";
5
- import { arrayToCountedMap, chunk } from "./utils";
3
+ import { extractItems } from "./lib.js";
4
+ import { combineQuery, EMPTY_VALUE, fetchUrl } from "./url.js";
5
+ import { arrayToCountedMap, chunk } from "./utils.js";
6
6
  export default class Kmail {
7
7
  id;
8
8
  date;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,126 @@
1
+ /* eslint-disable libram/verify-constants */
2
+ import { describe, it, expect } from "vitest";
3
+ import { InvalidMacroError, Macro } from "./combat.js";
4
+ import { $class, $effect, $item, $location, $monster, $skill, $stat, } from "./template-string.js";
5
+ describe(Macro, () => {
6
+ it("abort", () => {
7
+ expect(Macro.abort().toString()).toEqual(`abort;`);
8
+ });
9
+ it("abortWithWarning", () => {
10
+ expect(Macro.abortWithWarning("test").toString()).toEqual(`abort "test";`);
11
+ });
12
+ it("runaway", () => {
13
+ expect(Macro.runaway().toString()).toEqual(`runaway;`);
14
+ });
15
+ it("if_", () => {
16
+ expect(Macro.if_("mock", Macro.abort()).toString()).toEqual(`if mock;abort;endif;`);
17
+ });
18
+ it("ifNot", () => {
19
+ expect(Macro.ifNot("mock", Macro.abort()).toString()).toEqual(`if !(mock);abort;endif;`);
20
+ });
21
+ it("while_", () => {
22
+ expect(Macro.while_("mock", Macro.abort()).toString()).toEqual(`while mock;abort;endwhile;`);
23
+ });
24
+ it("externalIf false", () => {
25
+ expect(Macro.externalIf(false, "true", "false").toString()).toEqual(`false;`);
26
+ });
27
+ it("externalIf true", () => {
28
+ expect(Macro.externalIf(true, "true", "false").toString()).toEqual(`true;`);
29
+ });
30
+ it("repeat", () => {
31
+ expect(Macro.attack().repeat().toString()).toEqual(`attack;repeat;`);
32
+ });
33
+ it("repeat message", () => {
34
+ expect(Macro.attack().repeat("mock").toString()).toEqual(`attack;repeat mock;`);
35
+ });
36
+ it("skill", () => {
37
+ const mock = $skill `mock skill`;
38
+ expect(Macro.skill(mock).toString()).toEqual(`skill ${mock.name};`);
39
+ });
40
+ it("trySkill", () => {
41
+ const mock = $skill `mock skill`;
42
+ expect(Macro.trySkill(mock).toString()).toEqual(`if hasskill ${mock.name};skill ${mock.name};endif;`);
43
+ });
44
+ it("trySkillRepeat", () => {
45
+ const mock = $skill `mock skill`;
46
+ expect(Macro.trySkillRepeat(mock).toString()).toEqual(`if hasskill ${mock.name};skill ${mock.name};repeat hasskill ${mock.name};endif;`);
47
+ });
48
+ it("item", () => {
49
+ const mock = $item `mock item`;
50
+ expect(Macro.item(mock).toString()).toEqual(`use ${mock.name};`);
51
+ });
52
+ it("tryItem", () => {
53
+ const mock = $item `mock item`;
54
+ expect(Macro.tryItem(mock).toString()).toEqual(`if hascombatitem mock item;use ${mock.name};endif;`);
55
+ });
56
+ it("attack", () => {
57
+ expect(Macro.attack().toString()).toEqual(`attack;`);
58
+ });
59
+ it.todo("ifHolidayWanderer");
60
+ it.todo("ifNotHolidayWanderer");
61
+ });
62
+ describe(Macro.makeBALLSPredicate, () => {
63
+ it("Monster", () => {
64
+ const mock = $monster `mock monster`;
65
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`monsterid ${mock.id}`);
66
+ });
67
+ it("Monster[]", () => {
68
+ const mockArray = [$monster `mock monster1`, $monster `mock monster2`];
69
+ expect(Macro.makeBALLSPredicate(mockArray)).toEqual(`(monsterid ${mockArray[0].id} || monsterid ${mockArray[1].id})`);
70
+ });
71
+ it("Effect", () => {
72
+ const mock = $effect `mock effect`;
73
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`haseffect ${mock.id}`);
74
+ });
75
+ it("Skill", () => {
76
+ const mock = $skill `mock skill`;
77
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`hasskill ${mock.name}`);
78
+ });
79
+ it("Skill Overlapping", () => {
80
+ const mock = $skill `Thrust-Smack`;
81
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`hasskill ${mock.id}`);
82
+ });
83
+ it("Item", () => {
84
+ const mock = $item `mock item`;
85
+ // @ts-expect-error TypeScript believes that this is readonly
86
+ mock.combat = true;
87
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`hascombatitem ${mock.name}`);
88
+ });
89
+ it("Item Overlapping", () => {
90
+ const mock = $item `spider web`;
91
+ // @ts-expect-error TypeScript believes that this is readonly
92
+ mock.combat = true;
93
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`hascombatitem ${mock.id}`);
94
+ });
95
+ it("Item Invalid", () => {
96
+ const mock = $item `invalid mock item`;
97
+ expect(() => Macro.makeBALLSPredicate(mock)).toThrow(InvalidMacroError);
98
+ });
99
+ it("Location", () => {
100
+ const mock = $location `mock location`;
101
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`snarfblat ${mock.id}`);
102
+ });
103
+ it("Location Invalid", () => {
104
+ const mock = $location `invalid mock location`;
105
+ // @ts-expect-error TypeScript believes that this is readonly
106
+ mock.id = -1;
107
+ expect(() => Macro.makeBALLSPredicate(mock)).toThrow(InvalidMacroError);
108
+ });
109
+ it("Class", () => {
110
+ const mock = $class `Mock Name`;
111
+ // @ts-expect-error TypeScript believes that this is readonly
112
+ mock.id = 1;
113
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`mockname`);
114
+ });
115
+ it("Class Invalid", () => {
116
+ const mock = $class `invalid mock class`;
117
+ expect(() => Macro.makeBALLSPredicate(mock)).toThrow(InvalidMacroError);
118
+ });
119
+ it("Stat", () => {
120
+ const mock = $stat `Mock`;
121
+ expect(Macro.makeBALLSPredicate(mock)).toEqual(`mockclass`);
122
+ });
123
+ it("string", () => {
124
+ expect(Macro.makeBALLSPredicate("mock")).toEqual("mock");
125
+ });
126
+ });
@@ -1,6 +1,6 @@
1
1
  import { Familiar, Item, Skill } from "kolmafia";
2
- import { Macro } from "../combat";
3
- import { Requirement } from "../maximize";
2
+ import { Macro } from "../combat.js";
3
+ import { Requirement } from "../maximize.js";
4
4
  export type FindActionSourceConstraints = {
5
5
  /**
6
6
  * Function returning true if we only accept familiar-based actions.
@@ -1,7 +1,7 @@
1
1
  import { mallPrice, useFamiliar } from "kolmafia";
2
- import { Macro } from "../combat";
3
- import { Requirement } from "../maximize";
4
- import { sum, flat } from "../utils";
2
+ import { Macro } from "../combat.js";
3
+ import { Requirement } from "../maximize.js";
4
+ import { sum, flat } from "../utils.js";
5
5
  /**
6
6
  * Merge a set of constraints into one
7
7
  *
@@ -1,4 +1,4 @@
1
- import { ActionSource, FindActionSourceConstraints } from "./ActionSource";
1
+ import { ActionSource, FindActionSourceConstraints } from "./ActionSource.js";
2
2
  /**
3
3
  * Find an available banish source subject to constraints.
4
4
  *
@@ -1,11 +1,11 @@
1
1
  import { canEquip, cliExecute, myTurncount, restoreMp, retrieveItem, visitUrl, } from "kolmafia";
2
- import { Macro } from "../combat";
3
- import { getFoldGroup, have } from "../lib";
4
- import { Requirement } from "../maximize";
5
- import { get } from "../property";
6
- import * as AsdonMartin from "../resources/2017/AsdonMartin";
7
- import { $item, $items, $skill } from "../template-string";
8
- import { ActionSource, findActionSource, } from "./ActionSource";
2
+ import { Macro } from "../combat.js";
3
+ import { getFoldGroup, have } from "../lib.js";
4
+ import { Requirement } from "../maximize.js";
5
+ import { get } from "../property.js";
6
+ import * as AsdonMartin from "../resources/2017/AsdonMartin.js";
7
+ import { $item, $items, $skill } from "../template-string.js";
8
+ import { ActionSource, findActionSource, } from "./ActionSource.js";
9
9
  // Value of _lastCombatStarted the last time we updated scrapbook charges.
10
10
  let scrapbookChargesLastUpdated = get("_lastCombatStarted");
11
11
  // Free unlimited source every 30 turns.
@@ -1,4 +1,4 @@
1
- import { ActionSource, FindActionSourceConstraints } from "./ActionSource";
1
+ import { ActionSource, FindActionSourceConstraints } from "./ActionSource.js";
2
2
  /**
3
3
  * Find an available free kill source subject to constraints.
4
4
  *
@@ -1,11 +1,11 @@
1
1
  import { canEquip, myLightning, restoreMp, retrieveItem, use } from "kolmafia";
2
- import { Macro } from "../combat";
3
- import { have } from "../lib";
4
- import { Requirement } from "../maximize";
5
- import { get } from "../property";
6
- import * as AsdonMartin from "../resources/2017/AsdonMartin";
7
- import { $familiar, $item, $items, $skill } from "../template-string";
8
- import { ActionSource, findActionSource, } from "./ActionSource";
2
+ import { Macro } from "../combat.js";
3
+ import { have } from "../lib.js";
4
+ import { Requirement } from "../maximize.js";
5
+ import { get } from "../property.js";
6
+ import * as AsdonMartin from "../resources/2017/AsdonMartin.js";
7
+ import { $familiar, $item, $items, $skill } from "../template-string.js";
8
+ import { ActionSource, findActionSource, } from "./ActionSource.js";
9
9
  const freeKillSources = [
10
10
  // Free limited sources
11
11
  new ActionSource($skill `Gingerbread Mob Hit`, () => !get("_gingerbreadMobHitUsed") && have($skill `Gingerbread Mob Hit`)
@@ -1,4 +1,4 @@
1
- import { ActionSource, FindActionSourceConstraints } from "./ActionSource";
1
+ import { ActionSource, FindActionSourceConstraints } from "./ActionSource.js";
2
2
  /**
3
3
  * Find an available free run source subject to constraints.
4
4
  *
@@ -1,12 +1,12 @@
1
1
  import { retrieveItem } from "kolmafia";
2
- import { Macro } from "../combat";
3
- import { ensureEffect, getSongCount, getSongLimit, have } from "../lib";
4
- import { Requirement } from "../maximize";
5
- import { get } from "../property";
6
- import * as Bandersnatch from "../resources/2009/Bandersnatch";
7
- import * as StompingBoots from "../resources/2011/StompingBoots";
8
- import { $effect, $familiar, $item, $items, $skill } from "../template-string";
9
- import { ActionSource, findActionSource, } from "./ActionSource";
2
+ import { Macro } from "../combat.js";
3
+ import { ensureEffect, getSongCount, getSongLimit, have } from "../lib.js";
4
+ import { Requirement } from "../maximize.js";
5
+ import { get } from "../property.js";
6
+ import * as Bandersnatch from "../resources/2009/Bandersnatch.js";
7
+ import * as StompingBoots from "../resources/2011/StompingBoots.js";
8
+ import { $effect, $familiar, $item, $items, $skill, } from "../template-string.js";
9
+ import { ActionSource, findActionSource, } from "./ActionSource.js";
10
10
  const everythingLooksGreen = (otherClause = () => true) => () => otherClause() && !have($effect `Everything Looks Green`) ? 1 : 0;
11
11
  const freeRunSources = [
12
12
  // Free unlimited source
@@ -1,4 +1,4 @@
1
- export * from "./ActionSource";
2
- export * from "./Banish";
3
- export * from "./FreeKill";
4
- export * from "./FreeRun";
1
+ export * from "./ActionSource.js";
2
+ export * from "./Banish.js";
3
+ export * from "./FreeKill.js";
4
+ export * from "./FreeRun.js";
@@ -1,4 +1,4 @@
1
- export * from "./ActionSource";
2
- export * from "./Banish";
3
- export * from "./FreeKill";
4
- export * from "./FreeRun";
1
+ export * from "./ActionSource.js";
2
+ export * from "./Banish.js";
3
+ export * from "./FreeKill.js";
4
+ export * from "./FreeRun.js";
package/dist/ascend.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Skill, Class, Item, Path, MafiaClass } from "kolmafia";
2
- import { MoonSign } from "./moonSign";
3
- import { ChateauMantegna } from "./resources";
2
+ import { MoonSign } from "./moonSign.js";
3
+ import { ChateauMantegna } from "./resources/index.js";
4
4
  export declare enum Lifestyle {
5
5
  casual = 1,
6
6
  softcore = 2,
package/dist/ascend.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { eudoraItem, getCampground, Item, Path, use, visitUrl, xpath, haveSkill, getPermedSkills, toSkill, } from "kolmafia";
2
- import { signNameToId } from "./moonSign";
3
- import { get } from "./property";
4
- import { ChateauMantegna } from "./resources";
5
- import { $item, $items, $stat } from "./template-string";
6
- import { arrayContains, tc } from "./utils";
2
+ import { signNameToId } from "./moonSign.js";
3
+ import { get } from "./property.js";
4
+ import { ChateauMantegna } from "./resources/index.js";
5
+ import { $item, $items, $stat } from "./template-string.js";
6
+ import { arrayContains, tc } from "./utils.js";
7
7
  export var Lifestyle;
8
8
  (function (Lifestyle) {
9
9
  Lifestyle[Lifestyle["casual"] = 1] = "casual";
@@ -1,7 +1,7 @@
1
1
  import { Modifier, Monster, monsterFactoidsAvailable, myRain, numericModifier, useSkill, visitUrl, } from "kolmafia";
2
- import { have } from "../../lib";
3
- import { withChoice } from "../../property";
4
- import { $monster, $path, $skill } from "../../template-string";
2
+ import { have } from "../../lib.js";
3
+ import { withChoice } from "../../property.js";
4
+ import { $monster, $path, $skill } from "../../template-string.js";
5
5
  /**
6
6
  * Cast Rain Man and fight the target monster
7
7
  * @param target the monster to fight
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "kolmafia";
2
- import { Requirement } from "../../maximize";
2
+ import { Requirement } from "../../maximize.js";
3
3
  export default class CommunityService {
4
4
  private choice;
5
5
  private stat;
@@ -1,10 +1,10 @@
1
1
  import { equippedItem, familiarWeight, getPower, haveEquipped, myAdventures, myBasestat, myBuffedstat, myFamiliar, myMaxhp, myThrall, myTurncount, numericModifier, print, runChoice, toSlot, visitUrl, weightAdjustment, } from "kolmafia";
2
- import { have } from "../../lib";
3
- import { Requirement } from "../../maximize";
4
- import { get } from "../../property";
5
- import { MummingTrunk } from "../../resources";
6
- import { $effect, $familiar, $item, $items, $path, $slot, $stat, $thrall, } from "../../template-string";
7
- import { clamp, sum } from "../../utils";
2
+ import { have } from "../../lib.js";
3
+ import { Requirement } from "../../maximize.js";
4
+ import { get } from "../../property.js";
5
+ import { MummingTrunk } from "../../resources/index.js";
6
+ import { $effect, $familiar, $item, $items, $path, $slot, $stat, $thrall, } from "../../template-string.js";
7
+ import { clamp, sum } from "../../utils.js";
8
8
  const thralls = new Map([
9
9
  [$stat `muscle`, $thrall `Elbow Macaroni`],
10
10
  [$stat `moxie`, $thrall `Penne Dreadful`],
@@ -1,5 +1,5 @@
1
1
  import { visitUrl } from "kolmafia";
2
- import { $path } from "../../template-string";
2
+ import { $path } from "../../template-string.js";
3
3
  /**
4
4
  * Visits the Cooling Tank on level 8 of the Fallout shelter to gain 300 rads
5
5
  */
@@ -1,4 +1,4 @@
1
- import * as HeavyRains from "./2014/HeavyRains";
2
- import CommunityService from "./2015/CommunityService";
3
- import * as NuclearAutumn from "./2016/NuclearAutumn";
1
+ import * as HeavyRains from "./2014/HeavyRains.js";
2
+ import CommunityService from "./2015/CommunityService.js";
3
+ import * as NuclearAutumn from "./2016/NuclearAutumn.js";
4
4
  export { CommunityService, NuclearAutumn, HeavyRains };
@@ -1,4 +1,4 @@
1
- import * as HeavyRains from "./2014/HeavyRains";
2
- import CommunityService from "./2015/CommunityService";
3
- import * as NuclearAutumn from "./2016/NuclearAutumn";
1
+ import * as HeavyRains from "./2014/HeavyRains.js";
2
+ import CommunityService from "./2015/CommunityService.js";
3
+ import * as NuclearAutumn from "./2016/NuclearAutumn.js";
4
4
  export { CommunityService, NuclearAutumn, HeavyRains };
package/dist/combat.d.ts CHANGED
@@ -119,7 +119,7 @@ export declare class Macro {
119
119
  * Create a new macro with an "abort" step to this macro, with a warning message to print
120
120
  *
121
121
  * @param warning The warning message to print
122
- * @returns {Macro} This object itself.
122
+ * @returns {Macro} This object itself.
123
123
  */
124
124
  static abortWithWarning<T extends Macro>(this: Constructor<T>, warning: string): T;
125
125
  /**
@@ -134,7 +134,12 @@ export declare class Macro {
134
134
  * @returns {Macro} This object itself.
135
135
  */
136
136
  static runaway<T extends Macro>(this: Constructor<T>): T;
137
- private static makeBALLSPredicate;
137
+ /**
138
+ *
139
+ * @param condition The BALLS condition or a type to make a condition for (Monster, Item, Skill, etc.)
140
+ * @returns {string} The BALLS condition string
141
+ */
142
+ static makeBALLSPredicate(condition: PreBALLSPredicate): string;
138
143
  /**
139
144
  * Add an "if" statement to this macro.
140
145
  *
@@ -170,19 +175,19 @@ export declare class Macro {
170
175
  /**
171
176
  * Add a "while" statement to this macro.
172
177
  *
173
- * @param condition The BALLS condition for the if statement.
178
+ * @param condition The BALLS condition for the while statement.
174
179
  * @param contents Loop to repeat while the condition is true.
175
180
  * @returns {Macro} This object itself.
176
181
  */
177
- while_(condition: string, contents: string | Macro): this;
182
+ while_(condition: PreBALLSPredicate, contents: string | Macro): this;
178
183
  /**
179
184
  * Create a new macro with a "while" statement.
180
185
  *
181
- * @param condition The BALLS condition for the if statement.
186
+ * @param condition The BALLS condition for the while statement.
182
187
  * @param contents Loop to repeat while the condition is true.
183
188
  * @returns {Macro} This object itself.
184
189
  */
185
- static while_<T extends Macro>(this: Constructor<T>, condition: string, contents: string | Macro): T;
190
+ static while_<T extends Macro>(this: Constructor<T>, condition: PreBALLSPredicate, contents: string | Macro): T;
186
191
  /**
187
192
  * Conditionally add a step to a macro based on a condition evaluated at the time of building the macro.
188
193
  *
@@ -204,9 +209,10 @@ export declare class Macro {
204
209
  /**
205
210
  * Add a repeat step to the macro.
206
211
  *
212
+ * @param condition The BALLS condition for the repeat statement, optional.
207
213
  * @returns {Macro} This object itself.
208
214
  */
209
- repeat(): this;
215
+ repeat(condition?: PreBALLSPredicate): this;
210
216
  /**
211
217
  * Add one or more skill cast steps to the macro.
212
218
  *
package/dist/combat.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { adv1, choiceFollowsFight, Class, Effect, getAutoAttack, inMultiFight, Item, Location, Monster, removeProperty, runCombat, setAutoAttack, Skill, Stat, urlEncode, visitUrl, xpath, } from "kolmafia";
2
- import { getTodaysHolidayWanderers } from "./lib";
3
- import { overlappingItemNames, overlappingSkillNames, } from "./overlappingNames";
4
- import { get, set } from "./property";
2
+ import { getTodaysHolidayWanderers } from "./lib.js";
3
+ import { overlappingItemNames, overlappingSkillNames, } from "./overlappingNames.js";
4
+ import { get, set } from "./property.js";
5
5
  const MACRO_NAME = "Script Autoattack Macro";
6
6
  /**
7
7
  * Get the KoL native ID of the macro with name name.
@@ -246,7 +246,7 @@ export class Macro {
246
246
  * Create a new macro with an "abort" step to this macro, with a warning message to print
247
247
  *
248
248
  * @param warning The warning message to print
249
- * @returns {Macro} This object itself.
249
+ * @returns {Macro} This object itself.
250
250
  */
251
251
  static abortWithWarning(warning) {
252
252
  return new this().abortWithWarning(warning);
@@ -267,49 +267,49 @@ export class Macro {
267
267
  static runaway() {
268
268
  return new this().runaway();
269
269
  }
270
+ /**
271
+ *
272
+ * @param condition The BALLS condition or a type to make a condition for (Monster, Item, Skill, etc.)
273
+ * @returns {string} The BALLS condition string
274
+ */
270
275
  static makeBALLSPredicate(condition) {
271
- let ballsCondition = "";
272
276
  if (condition instanceof Monster) {
273
- ballsCondition = `monsterid ${condition.id}`;
277
+ return `monsterid ${condition.id}`;
274
278
  }
275
279
  else if (condition instanceof Array) {
276
- ballsCondition = condition
277
- .map((mon) => `monsterid ${mon.id}`)
278
- .join(" || ");
279
- ballsCondition = `(${ballsCondition})`;
280
+ return `(${condition
281
+ .map((entry) => Macro.makeBALLSPredicate(entry))
282
+ .join(" || ")})`;
280
283
  }
281
284
  else if (condition instanceof Effect) {
282
- ballsCondition = `haseffect ${condition.id}`;
285
+ return `haseffect ${condition.id}`;
283
286
  }
284
287
  else if (condition instanceof Skill) {
285
- ballsCondition = `hasskill ${skillBallsMacroName(condition)}`;
288
+ return `hasskill ${skillBallsMacroName(condition)}`;
286
289
  }
287
290
  else if (condition instanceof Item) {
288
291
  if (!condition.combat) {
289
292
  throw new InvalidMacroError(`Item ${condition} cannot be made a valid BALLS predicate (it is not combat-usable)`);
290
293
  }
291
- ballsCondition = `hascombatitem ${itemOrItemsBallsMacroName(condition)}`;
294
+ return `hascombatitem ${itemOrItemsBallsMacroName(condition)}`;
292
295
  }
293
296
  else if (condition instanceof Location) {
294
297
  const snarfblat = condition.id;
295
298
  if (snarfblat < 1) {
296
299
  throw new InvalidMacroError(`Location ${condition} cannot be made a valid BALLS predicate (it has no location id)`);
297
300
  }
298
- ballsCondition = `snarfblat ${snarfblat}`;
301
+ return `snarfblat ${snarfblat}`;
299
302
  }
300
303
  else if (condition instanceof Class) {
301
304
  if (condition.id > 6) {
302
305
  throw new InvalidMacroError(`Class ${condition} cannot be made a valid BALLS predicate (it is not a standard class)`);
303
306
  }
304
- ballsCondition = condition.toString().replaceAll(" ", "").toLowerCase();
307
+ return condition.toString().replaceAll(" ", "").toLowerCase();
305
308
  }
306
309
  else if (condition instanceof Stat) {
307
- ballsCondition = `${condition.toString().toLowerCase()}class`;
310
+ return `${condition.toString().toLowerCase()}class`;
308
311
  }
309
- else {
310
- ballsCondition = condition;
311
- }
312
- return ballsCondition;
312
+ return condition;
313
313
  }
314
314
  /**
315
315
  * Add an "if" statement to this macro.
@@ -358,17 +358,19 @@ export class Macro {
358
358
  /**
359
359
  * Add a "while" statement to this macro.
360
360
  *
361
- * @param condition The BALLS condition for the if statement.
361
+ * @param condition The BALLS condition for the while statement.
362
362
  * @param contents Loop to repeat while the condition is true.
363
363
  * @returns {Macro} This object itself.
364
364
  */
365
365
  while_(condition, contents) {
366
- return this.step(`while ${condition}`).step(contents).step("endwhile");
366
+ return this.step(`while ${Macro.makeBALLSPredicate(condition)}`)
367
+ .step(contents)
368
+ .step("endwhile");
367
369
  }
368
370
  /**
369
371
  * Create a new macro with a "while" statement.
370
372
  *
371
- * @param condition The BALLS condition for the if statement.
373
+ * @param condition The BALLS condition for the while statement.
372
374
  * @param contents Loop to repeat while the condition is true.
373
375
  * @returns {Macro} This object itself.
374
376
  */
@@ -405,10 +407,13 @@ export class Macro {
405
407
  /**
406
408
  * Add a repeat step to the macro.
407
409
  *
410
+ * @param condition The BALLS condition for the repeat statement, optional.
408
411
  * @returns {Macro} This object itself.
409
412
  */
410
- repeat() {
411
- return this.step("repeat");
413
+ repeat(condition) {
414
+ return condition === undefined
415
+ ? this.step("repeat")
416
+ : this.step(`repeat ${Macro.makeBALLSPredicate(condition)}`);
412
417
  }
413
418
  /**
414
419
  * Add one or more skill cast steps to the macro.
@@ -437,8 +442,10 @@ export class Macro {
437
442
  * @returns {Macro} This object itself.
438
443
  */
439
444
  trySkill(...skills) {
440
- return this.step(...skills.map((skill) => {
441
- return Macro.if_(`hasskill ${skillBallsMacroName(skill)}`, Macro.skill(skill));
445
+ return this.step(...skills
446
+ .map((skillOrName) => skillOrNameToSkill(skillOrName))
447
+ .map((skill) => {
448
+ return Macro.if_(Macro.makeBALLSPredicate(skill), Macro.skill(skill));
442
449
  }));
443
450
  }
444
451
  /**
@@ -457,8 +464,10 @@ export class Macro {
457
464
  * @returns {Macro} This object itself.
458
465
  */
459
466
  trySkillRepeat(...skills) {
460
- return this.step(...skills.map((skill) => {
461
- return Macro.if_(`hasskill ${skillBallsMacroName(skill)}`, Macro.skill(skill).repeat());
467
+ return this.step(...skills
468
+ .map((skillOrName) => skillOrNameToSkill(skillOrName))
469
+ .map((skill) => {
470
+ return Macro.if_(Macro.makeBALLSPredicate(skill), Macro.skill(skill).repeat(skill));
462
471
  }));
463
472
  }
464
473
  /**
@@ -498,7 +507,7 @@ export class Macro {
498
507
  */
499
508
  tryItem(...items) {
500
509
  return this.step(...items.map((item) => {
501
- return Macro.if_(itemOrItemsBallsMacroPredicate(item), `use ${itemOrItemsBallsMacroName(item)}`);
510
+ return Macro.if_(itemOrItemsBallsMacroPredicate(item), Macro.item(item));
502
511
  }));
503
512
  }
504
513
  /**
@@ -1,11 +1,11 @@
1
1
  import { canEquip, fullnessLimit, historicalAge, historicalPrice, inebrietyLimit, itemType, mallPrice, mallPrices, myFullness, myInebriety, myLevel, myPrimestat, mySpleenUse, npcPrice, spleenLimit, } from "kolmafia";
2
- import { have } from "../lib";
3
- import { get as getModifier } from "../modifier";
4
- import { get } from "../property";
5
- import { Mayo, installed as mayoInstalled } from "../resources/2015/MayoClinic";
6
- import { $effect, $item, $items, $skill, $stat } from "../template-string";
7
- import { notNullish, sum } from "../utils";
8
- import { knapsack } from "./knapsack";
2
+ import { have } from "../lib.js";
3
+ import { get as getModifier } from "../modifier.js";
4
+ import { get } from "../property.js";
5
+ import { Mayo, installed as mayoInstalled, } from "../resources/2015/MayoClinic.js";
6
+ import { $effect, $item, $items, $skill, $stat } from "../template-string.js";
7
+ import { notNullish, sum } from "../utils.js";
8
+ import { knapsack } from "./knapsack.js";
9
9
  function isMonday() {
10
10
  // Checking Tuesday's ruby is a hack to see if it's Monday in Arizona.
11
11
  return getModifier("Muscle Percent", $item `Tuesday's ruby`) > 0;
@@ -1,4 +1,4 @@
1
- import { sum } from "../utils";
1
+ import { sum } from "../utils.js";
2
2
  class Not {
3
3
  thing;
4
4
  constructor(thing) {
@@ -0,0 +1 @@
1
+ export {};