libram 0.3.2 → 0.4.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.
Files changed (99) hide show
  1. package/dist/Clan.js +268 -485
  2. package/dist/Copier.js +11 -48
  3. package/dist/Dungeon.js +77 -157
  4. package/dist/Kmail.d.ts +13 -7
  5. package/dist/Kmail.js +92 -233
  6. package/dist/Path.js +68 -120
  7. package/dist/ascend.js +153 -172
  8. package/dist/combat.d.ts +86 -1
  9. package/dist/combat.js +295 -387
  10. package/dist/console.js +13 -36
  11. package/dist/diet/index.d.ts +31 -0
  12. package/dist/diet/index.js +333 -0
  13. package/dist/diet/knapsack.d.ts +7 -0
  14. package/dist/diet/knapsack.js +106 -0
  15. package/dist/dungeons/Dreadsylvania.d.ts +4 -0
  16. package/dist/dungeons/Dreadsylvania.js +14 -0
  17. package/dist/dungeons/Dungeon.d.ts +28 -0
  18. package/dist/dungeons/Dungeon.js +99 -0
  19. package/dist/dungeons/Hobopolis.d.ts +4 -0
  20. package/dist/dungeons/Hobopolis.js +14 -0
  21. package/dist/dungeons/SlimeTube.d.ts +4 -0
  22. package/dist/dungeons/SlimeTube.js +14 -0
  23. package/dist/freerun.d.ts +23 -0
  24. package/dist/freerun.js +92 -0
  25. package/dist/index.d.ts +6 -1
  26. package/dist/index.js +21 -263
  27. package/dist/lib.d.ts +43 -0
  28. package/dist/lib.js +296 -405
  29. package/dist/logger.js +23 -63
  30. package/dist/maximize.d.ts +29 -12
  31. package/dist/maximize.js +318 -421
  32. package/dist/modifier.d.ts +13 -0
  33. package/dist/modifier.js +35 -0
  34. package/dist/modifierTypes.d.ts +16 -0
  35. package/dist/modifierTypes.js +9 -0
  36. package/dist/mood.js +220 -531
  37. package/dist/property.d.ts +2 -0
  38. package/dist/property.js +96 -242
  39. package/dist/propertyTypes.d.ts +9 -0
  40. package/dist/propertyTypes.js +1 -0
  41. package/dist/propertyTyping.d.ts +2 -9
  42. package/dist/propertyTyping.js +42 -53
  43. package/dist/resources/2007/CandyHearts.d.ts +9 -0
  44. package/dist/resources/2007/CandyHearts.js +24 -0
  45. package/dist/resources/2008/DivineFavors.d.ts +9 -0
  46. package/dist/resources/2008/DivineFavors.js +27 -0
  47. package/dist/resources/2009/Bandersnatch.js +37 -112
  48. package/dist/resources/2009/LoveSongs.d.ts +9 -0
  49. package/dist/resources/2009/LoveSongs.js +24 -0
  50. package/dist/resources/2009/SpookyPutty.js +20 -46
  51. package/dist/resources/2010/Brickos.d.ts +9 -0
  52. package/dist/resources/2010/Brickos.js +21 -0
  53. package/dist/resources/2010/CrownOfThrones.d.ts +18 -0
  54. package/dist/resources/2010/CrownOfThrones.js +550 -0
  55. package/dist/resources/2011/Gygaxian.d.ts +9 -0
  56. package/dist/resources/2011/Gygaxian.js +24 -0
  57. package/dist/resources/2011/ObtuseAngel.js +21 -63
  58. package/dist/resources/2012/RainDoh.js +14 -40
  59. package/dist/resources/2012/Resolutions.d.ts +9 -0
  60. package/dist/resources/2012/Resolutions.js +28 -0
  61. package/dist/resources/2013/Florist.d.ts +61 -0
  62. package/dist/resources/2013/Florist.js +149 -0
  63. package/dist/resources/2013/PulledTaffy.d.ts +9 -0
  64. package/dist/resources/2013/PulledTaffy.js +33 -0
  65. package/dist/resources/2014/WinterGarden.js +15 -43
  66. package/dist/resources/2015/ChateauMantegna.js +52 -86
  67. package/dist/resources/2015/MayoClinic.d.ts +13 -0
  68. package/dist/resources/2015/MayoClinic.js +36 -0
  69. package/dist/resources/2016/SourceTerminal.d.ts +1 -0
  70. package/dist/resources/2016/SourceTerminal.js +114 -237
  71. package/dist/resources/2016/Witchess.js +33 -59
  72. package/dist/resources/2017/TunnelOfLove.js +62 -111
  73. package/dist/resources/2018/SongBoom.js +32 -68
  74. package/dist/resources/2019/BeachComb.d.ts +2 -0
  75. package/dist/resources/2019/BeachComb.js +26 -0
  76. package/dist/resources/2019/Snapper.d.ts +28 -0
  77. package/dist/resources/2019/Snapper.js +70 -0
  78. package/dist/resources/2020/Guzzlr.js +79 -163
  79. package/dist/resources/LibramSummon.d.ts +12 -0
  80. package/dist/resources/LibramSummon.js +66 -0
  81. package/dist/resources/index.d.ts +18 -11
  82. package/dist/resources/index.js +19 -85
  83. package/dist/resources/putty-likes.js +15 -30
  84. package/dist/ring-buffer.d.ts +24 -0
  85. package/dist/ring-buffer.js +135 -0
  86. package/dist/since.d.ts +1 -0
  87. package/dist/since.js +56 -112
  88. package/dist/template-string.js +40 -132
  89. package/dist/utils.d.ts +14 -0
  90. package/dist/utils.js +50 -114
  91. package/package.json +5 -3
  92. package/dist/libram-example-briefcase.js +0 -16073
  93. package/dist/libram-example-clan.js +0 -8898
  94. package/dist/libram-example-consult.js +0 -6179
  95. package/dist/libram-example-item.js +0 -3248
  96. package/dist/libram-example-kmail.js +0 -2065
  97. package/dist/libram-example-lib.js +0 -7608
  98. package/dist/libram-example-props.js +0 -4770
  99. package/dist/libram-example-resources.js +0 -12226
package/dist/ascend.js CHANGED
@@ -1,114 +1,65 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.array.slice.js");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.ascend = ascend;
9
- exports.prepareAscension = prepareAscension;
10
- exports.Lifestyle = void 0;
11
-
12
- require("core-js/modules/es.array.includes.js");
13
-
14
- require("core-js/modules/es.string.includes.js");
15
-
16
- require("core-js/modules/es.array.concat.js");
17
-
18
- require("core-js/modules/es.object.to-string.js");
19
-
20
- require("core-js/modules/es.regexp.to-string.js");
21
-
22
- var _kolmafia = require("kolmafia");
23
-
24
- var _templateString = require("./template-string");
25
-
26
- var _property = require("./property");
27
-
28
- var _resources = require("./resources");
29
-
30
- var _lib = require("./lib");
31
-
32
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
33
-
34
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
35
-
36
- var Lifestyle;
37
- exports.Lifestyle = Lifestyle;
38
-
1
+ import { containsText, eudoraItem, getCampground, getWorkshed, toInt, use, visitUrl, xpath, } from "kolmafia";
2
+ import { $item, $items, $stat } from "./template-string";
3
+ import { get } from "./property";
4
+ import { ChateauMantegna } from "./resources";
5
+ import { have } from "./lib";
6
+ export var Lifestyle;
39
7
  (function (Lifestyle) {
40
- Lifestyle[Lifestyle["casual"] = 1] = "casual";
41
- Lifestyle[Lifestyle["softcore"] = 2] = "softcore";
42
- Lifestyle[Lifestyle["normal"] = 2] = "normal";
43
- Lifestyle[Lifestyle["hardcore"] = 3] = "hardcore";
44
- })(Lifestyle || (exports.Lifestyle = Lifestyle = {}));
45
-
8
+ Lifestyle[Lifestyle["casual"] = 1] = "casual";
9
+ Lifestyle[Lifestyle["softcore"] = 2] = "softcore";
10
+ Lifestyle[Lifestyle["normal"] = 2] = "normal";
11
+ Lifestyle[Lifestyle["hardcore"] = 3] = "hardcore";
12
+ })(Lifestyle || (Lifestyle = {}));
46
13
  function toMoonId(moon, playerClass) {
47
- if (typeof moon === "number") return moon;
48
-
49
- var offset = () => {
50
- switch (playerClass.primestat) {
51
- case (0, _templateString.$stat)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Muscle"]))):
52
- return 0;
53
-
54
- case (0, _templateString.$stat)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Mysticality"]))):
55
- return 1;
56
-
57
- case (0, _templateString.$stat)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Moxie"]))):
58
- return 2;
59
-
60
- default:
61
- throw "unknown prime stat for ".concat(playerClass);
14
+ if (typeof moon === "number")
15
+ return moon;
16
+ const offset = () => {
17
+ switch (playerClass.primestat) {
18
+ case $stat `Muscle`:
19
+ return 0;
20
+ case $stat `Mysticality`:
21
+ return 1;
22
+ case $stat `Moxie`:
23
+ return 2;
24
+ default:
25
+ throw `unknown prime stat for ${playerClass}`;
26
+ }
27
+ };
28
+ switch (moon.toLowerCase()) {
29
+ case "mongoose":
30
+ return 1;
31
+ case "wallaby":
32
+ return 2;
33
+ case "vole":
34
+ return 3;
35
+ case "platypus":
36
+ return 4;
37
+ case "opossum":
38
+ return 5;
39
+ case "marmot":
40
+ return 6;
41
+ case "wombat":
42
+ return 7;
43
+ case "blender":
44
+ return 8;
45
+ case "packrat":
46
+ return 9;
47
+ case "degrassi":
48
+ case "degrassi knoll":
49
+ case "friendly degrassi knoll":
50
+ case "knoll":
51
+ return 1 + offset();
52
+ case "canada":
53
+ case "canadia":
54
+ case "little canadia":
55
+ return 4 + offset();
56
+ case "gnomads":
57
+ case "gnomish":
58
+ case "gnomish gnomads camp":
59
+ return 7 + offset();
60
+ default:
61
+ return -1;
62
62
  }
63
- };
64
-
65
- switch (moon.toLowerCase()) {
66
- case "mongoose":
67
- return 1;
68
-
69
- case "wallaby":
70
- return 2;
71
-
72
- case "vole":
73
- return 3;
74
-
75
- case "platypus":
76
- return 4;
77
-
78
- case "opossum":
79
- return 5;
80
-
81
- case "marmot":
82
- return 6;
83
-
84
- case "wombat":
85
- return 7;
86
-
87
- case "blender":
88
- return 8;
89
-
90
- case "packrat":
91
- return 9;
92
-
93
- case "degrassi":
94
- case "degrassi knoll":
95
- case "friendly degrassi knoll":
96
- case "knoll":
97
- return 1 + offset();
98
-
99
- case "canada":
100
- case "canadia":
101
- case "little canadia":
102
- return 4 + offset();
103
-
104
- case "gnomads":
105
- case "gnomish":
106
- case "gnomish gnomads camp":
107
- return 7 + offset();
108
-
109
- default:
110
- return -1;
111
- }
112
63
  }
113
64
  /**
114
65
  * Hops the gash, perming no skills
@@ -119,76 +70,106 @@ function toMoonId(moon, playerClass) {
119
70
  * @param consumable From the astral deli. Pick the container item, not the product.
120
71
  * @param pet From the astral pet store.
121
72
  */
122
-
123
-
124
- function ascend(path, playerClass, lifestyle, moon) {
125
- var consumable = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : (0, _templateString.$item)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["astral six-pack"])));
126
- var pet = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
127
-
128
- if (!(0, _kolmafia.containsText)((0, _kolmafia.visitUrl)("charpane.php"), "Astral Spirit")) {
129
- (0, _kolmafia.visitUrl)("ascend.php?action=ascend&confirm=on&confirm2=on");
130
- }
131
-
132
- if (!(0, _kolmafia.containsText)((0, _kolmafia.visitUrl)("charpane.php"), "Astral Spirit")) throw "Failed to ascend.";
133
- if (!path.classes.includes(playerClass)) throw "Invalid class ".concat(playerClass, " for this path");
134
- if (path.id < 0) throw "Invalid path ID ".concat(path.id);
135
- var moonId = toMoonId(moon, playerClass);
136
- if (moonId < 1 || moonId > 9) throw "Invalid moon ".concat(moon);
137
- if (consumable && !(0, _templateString.$items)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["astral six-pack, astral hot dog dinner"]))).includes(consumable)) throw "Invalid consumable ".concat(consumable);
138
- if (pet && !(0, _templateString.$items)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["astral bludgeon, astral shield, astral chapeau, astral bracer, astral longbow, astral shorts, astral mace, astral ring, astral statuette, astral pistol, astral mask, astral pet sweater, astral shirt, astral belt"]))).includes(pet)) throw "Invalid astral item ".concat(pet);
139
- (0, _kolmafia.visitUrl)("afterlife.php?action=pearlygates");
140
- if (consumable) (0, _kolmafia.visitUrl)("afterlife.php?action=buydeli&whichitem=".concat((0, _kolmafia.toInt)(consumable)));
141
- if (pet) (0, _kolmafia.visitUrl)("afterlife.php?action=buyarmory&whichitem=".concat((0, _kolmafia.toInt)(pet)));
142
- (0, _kolmafia.visitUrl)("afterlife.php?action=ascend&confirmascend=1&whichsign=".concat(moonId, "&gender=2&whichclass=").concat((0, _kolmafia.toInt)(playerClass), "&whichpath=").concat(path.id, "&asctype=").concat(lifestyle, "&nopetok=1&noskillsok=1&lamepathok=1&pwd"), true);
73
+ export function ascend(path, playerClass, lifestyle, moon, consumable = $item `astral six-pack`, pet = undefined) {
74
+ if (!containsText(visitUrl("charpane.php"), "Astral Spirit")) {
75
+ visitUrl("ascend.php?action=ascend&confirm=on&confirm2=on");
76
+ }
77
+ if (!containsText(visitUrl("charpane.php"), "Astral Spirit"))
78
+ throw "Failed to ascend.";
79
+ if (!path.classes.includes(playerClass))
80
+ throw `Invalid class ${playerClass} for this path`;
81
+ if (path.id < 0)
82
+ throw `Invalid path ID ${path.id}`;
83
+ const moonId = toMoonId(moon, playerClass);
84
+ if (moonId < 1 || moonId > 9)
85
+ throw `Invalid moon ${moon}`;
86
+ if (consumable &&
87
+ !$items `astral six-pack, astral hot dog dinner`.includes(consumable))
88
+ throw `Invalid consumable ${consumable}`;
89
+ if (pet &&
90
+ !$items `astral bludgeon, astral shield, astral chapeau, astral bracer, astral longbow, astral shorts, astral mace, astral ring, astral statuette, astral pistol, astral mask, astral pet sweater, astral shirt, astral belt`.includes(pet))
91
+ throw `Invalid astral item ${pet}`;
92
+ visitUrl("afterlife.php?action=pearlygates");
93
+ if (consumable)
94
+ visitUrl(`afterlife.php?action=buydeli&whichitem=${toInt(consumable)}`);
95
+ if (pet)
96
+ visitUrl(`afterlife.php?action=buyarmory&whichitem=${toInt(pet)}`);
97
+ visitUrl(`afterlife.php?action=ascend&confirmascend=1&whichsign=${moonId}&gender=2&whichclass=${toInt(playerClass)}&whichpath=${path.id}&asctype=${lifestyle}&nopetok=1&noskillsok=1&lamepathok=1&pwd`, true);
143
98
  }
144
-
145
- var worksheds = (0, _templateString.$items)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["warbear LP-ROM burner, warbear jackhammer drill press, warbear induction oven, warbear high-efficiency still, warbear chemistry lab, warbear auto-anvil, spinning wheel, snow machine, Little Geneticist DNA-Splicing Lab, portable Mayo Clinic, Asdon Martin keyfob, diabolic pizza cube"])));
146
- var gardens = (0, _templateString.$items)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["packet of pumpkin seeds, Peppermint Pip Packet, packet of dragon's teeth, packet of beer seeds, packet of winter seeds, packet of thanksgarden seeds, packet of tall grass seeds, packet of mushroom spores"]))); // eslint-disable-next-line libram/verify-constants
147
-
148
- var eudorae = (0, _templateString.$items)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["My Own Pen Pal kit, GameInformPowerDailyPro subscription card, Xi Receiver Unit, New-You Club Membership Form, Our Daily Candles\u2122 order form"])));
149
- var desks = (0, _templateString.$items)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["fancy stationery set, Swiss piggy bank, continental juice bar"])));
150
- var ceilings = (0, _templateString.$items)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["antler chandelier, ceiling fan, artificial skylight"])));
151
- var nightstands = (0, _templateString.$items)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["foreign language tapes, bowl of potpourri, electric muscle stimulator"])));
99
+ const worksheds = $items `warbear LP-ROM burner, warbear jackhammer drill press, warbear induction oven, warbear high-efficiency still, warbear chemistry lab, warbear auto-anvil, spinning wheel, snow machine, Little Geneticist DNA-Splicing Lab, portable Mayo Clinic, Asdon Martin keyfob, diabolic pizza cube`;
100
+ const gardens = $items `packet of pumpkin seeds, Peppermint Pip Packet, packet of dragon's teeth, packet of beer seeds, packet of winter seeds, packet of thanksgarden seeds, packet of tall grass seeds, packet of mushroom spores`;
101
+ // eslint-disable-next-line libram/verify-constants
102
+ const eudorae = $items `My Own Pen Pal kit, GameInformPowerDailyPro subscription card, Xi Receiver Unit, New-You Club Membership Form, Our Daily Candles™ order form`;
103
+ const desks = $items `fancy stationery set, Swiss piggy bank, continental juice bar`;
104
+ const ceilings = $items `antler chandelier, ceiling fan, artificial skylight`;
105
+ const nightstands = $items `foreign language tapes, bowl of potpourri, electric muscle stimulator`;
152
106
  /**
153
107
  * Sets up various iotms you may want to use in the coming ascension
154
108
  * @param ascensionItems An object potentially containing your workshed, garden, and eudora, all as items
155
109
  * @param chateauItems An object potentially containing your chateau desk, ceiling, and nightstand, all as items
156
110
  * @param throwOnFail If true, this will throw an error when it fails to switch something
157
111
  */
158
-
159
- function prepareAscension(ascensionItems, chateauItems) {
160
- var throwOnFail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
161
-
162
- if (ascensionItems) {
163
- if (ascensionItems.workshed && (0, _kolmafia.getWorkshed)() !== ascensionItems.workshed) {
164
- if (!worksheds.includes(ascensionItems.workshed) && throwOnFail) throw "Invalid workshed: ".concat(ascensionItems.workshed, "!");else if (!(0, _lib.have)(ascensionItems.workshed) && throwOnFail) throw "I'm sorry buddy, but you don't seem to own a ".concat(ascensionItems.workshed, ". Which makes it REALLY hard for us to plop one into your workshed.");else if ((0, _property.get)("_workshedItemUsed") && throwOnFail) throw "Seems like you've already swapped your workshed, buddy.";else (0, _kolmafia.use)(ascensionItems.workshed);
165
- if ((0, _kolmafia.getWorkshed)() !== ascensionItems.workshed && throwOnFail) throw "We really thought we changed your workshed to a ".concat(ascensionItems.workshed, ", but Mafia is saying otherwise.");
166
- }
167
-
168
- if (ascensionItems.garden && !Object.getOwnPropertyNames((0, _kolmafia.getCampground)()).includes(ascensionItems.garden.name)) {
169
- if (!gardens.includes(ascensionItems.garden) && throwOnFail) throw "Invalid garden: ".concat(ascensionItems.garden, "!");else if (!(0, _lib.have)(ascensionItems.garden) && throwOnFail) throw "I'm sorry buddy, but you don't seem to own a ".concat(ascensionItems.garden, ". Which makes it REALLY hard for us to plant one into your garden.");else (0, _kolmafia.use)(ascensionItems.garden);
170
- if (!Object.getOwnPropertyNames((0, _kolmafia.getCampground)()).includes(ascensionItems.garden.name) && throwOnFail) throw "We really thought we changed your garden to a ".concat(ascensionItems.garden, ", but Mafia is saying otherwise.");
171
- }
172
-
173
- if (ascensionItems.eudora && (0, _kolmafia.eudoraItem)() !== ascensionItems.eudora) {
174
- if (!eudorae.includes(ascensionItems.eudora) && throwOnFail) throw "Invalid eudora: ".concat(ascensionItems.eudora, "!");
175
- var eudoraNumber = 1 + eudorae.indexOf(ascensionItems.eudora);
176
- if (!(0, _kolmafia.xpath)((0, _kolmafia.visitUrl)("account.php?tab=correspondence"), "//select[@name=\"whichpenpal\"]/option/@value").includes(eudoraNumber.toString()) && throwOnFail) throw "I'm sorry buddy, but you don't seem to be subscribed to ".concat(ascensionItems.eudora, ". Which makes it REALLY hard to correspond with them.");else (0, _kolmafia.visitUrl)("account.php?actions[]=whichpenpal&whichpenpal=".concat(eudoraNumber, "&action=Update"), true);
177
- if ((0, _kolmafia.eudoraItem)() !== ascensionItems.eudora && throwOnFail) throw "We really thought we chaned your eudora to a ".concat(ascensionItems.eudora, ", but Mafia is saying otherwise.");
112
+ export function prepareAscension(ascensionItems, chateauItems, throwOnFail = true) {
113
+ if (ascensionItems) {
114
+ if (ascensionItems.workshed && getWorkshed() !== ascensionItems.workshed) {
115
+ if (!worksheds.includes(ascensionItems.workshed) && throwOnFail)
116
+ throw `Invalid workshed: ${ascensionItems.workshed}!`;
117
+ else if (!have(ascensionItems.workshed) && throwOnFail)
118
+ throw `I'm sorry buddy, but you don't seem to own a ${ascensionItems.workshed}. Which makes it REALLY hard for us to plop one into your workshed.`;
119
+ else if (get("_workshedItemUsed") && throwOnFail)
120
+ throw `Seems like you've already swapped your workshed, buddy.`;
121
+ else
122
+ use(ascensionItems.workshed);
123
+ if (getWorkshed() !== ascensionItems.workshed && throwOnFail)
124
+ throw `We really thought we changed your workshed to a ${ascensionItems.workshed}, but Mafia is saying otherwise.`;
125
+ }
126
+ if (ascensionItems.garden &&
127
+ !Object.getOwnPropertyNames(getCampground()).includes(ascensionItems.garden.name)) {
128
+ if (!gardens.includes(ascensionItems.garden) && throwOnFail)
129
+ throw `Invalid garden: ${ascensionItems.garden}!`;
130
+ else if (!have(ascensionItems.garden) && throwOnFail)
131
+ throw `I'm sorry buddy, but you don't seem to own a ${ascensionItems.garden}. Which makes it REALLY hard for us to plant one into your garden.`;
132
+ else
133
+ use(ascensionItems.garden);
134
+ if (!Object.getOwnPropertyNames(getCampground()).includes(ascensionItems.garden.name) &&
135
+ throwOnFail)
136
+ throw `We really thought we changed your garden to a ${ascensionItems.garden}, but Mafia is saying otherwise.`;
137
+ }
138
+ if (ascensionItems.eudora && eudoraItem() !== ascensionItems.eudora) {
139
+ if (!eudorae.includes(ascensionItems.eudora) && throwOnFail)
140
+ throw `Invalid eudora: ${ascensionItems.eudora}!`;
141
+ const eudoraNumber = 1 + eudorae.indexOf(ascensionItems.eudora);
142
+ if (!xpath(visitUrl("account.php?tab=correspondence"), `//select[@name="whichpenpal"]/option/@value`).includes(eudoraNumber.toString()) &&
143
+ throwOnFail)
144
+ throw `I'm sorry buddy, but you don't seem to be subscribed to ${ascensionItems.eudora}. Which makes it REALLY hard to correspond with them.`;
145
+ else
146
+ visitUrl(`account.php?actions[]=whichpenpal&whichpenpal=${eudoraNumber}&action=Update`, true);
147
+ if (eudoraItem() !== ascensionItems.eudora && throwOnFail)
148
+ throw `We really thought we chaned your eudora to a ${ascensionItems.eudora}, but Mafia is saying otherwise.`;
149
+ }
178
150
  }
179
- }
180
-
181
- if (chateauItems && _resources.ChateauMantegna.have()) {
182
- if (chateauItems.ceiling && _resources.ChateauMantegna.getCeiling() !== chateauItems.ceiling) {
183
- if (!ceilings.includes(chateauItems.ceiling) && throwOnFail) throw "Invalid chateau ceiling: ".concat(chateauItems.ceiling, "!");else if (!_resources.ChateauMantegna.changeCeiling(chateauItems.ceiling) && throwOnFail) throw "We tried, but were unable to change your chateau ceiling to ".concat(chateauItems.ceiling, ". Probably.");
151
+ if (chateauItems && ChateauMantegna.have()) {
152
+ if (chateauItems.ceiling &&
153
+ ChateauMantegna.getCeiling() !== chateauItems.ceiling) {
154
+ if (!ceilings.includes(chateauItems.ceiling) && throwOnFail)
155
+ throw `Invalid chateau ceiling: ${chateauItems.ceiling}!`;
156
+ else if (!ChateauMantegna.changeCeiling(chateauItems.ceiling) &&
157
+ throwOnFail)
158
+ throw `We tried, but were unable to change your chateau ceiling to ${chateauItems.ceiling}. Probably.`;
159
+ }
160
+ if (chateauItems.desk && ChateauMantegna.getDesk() !== chateauItems.desk) {
161
+ if (!desks.includes(chateauItems.desk) && throwOnFail)
162
+ throw `Invalid chateau desk: ${chateauItems.desk}!`;
163
+ else if (!ChateauMantegna.changeDesk(chateauItems.desk) && throwOnFail)
164
+ throw `We tried, but were unable to change your chateau desk to ${chateauItems.desk}. Probably.`;
165
+ }
166
+ if (chateauItems.nightstand &&
167
+ ChateauMantegna.getNightstand() !== chateauItems.nightstand) {
168
+ if (!nightstands.includes(chateauItems.nightstand) && throwOnFail)
169
+ throw `Invalid chateau nightstand: ${chateauItems.nightstand}!`;
170
+ else if (!ChateauMantegna.changeNightstand(chateauItems.nightstand) &&
171
+ throwOnFail)
172
+ throw `We tried, but were unable to change your chateau nightstand to ${chateauItems.nightstand}. Probably.`;
173
+ }
184
174
  }
185
-
186
- if (chateauItems.desk && _resources.ChateauMantegna.getDesk() !== chateauItems.desk) {
187
- if (!desks.includes(chateauItems.desk) && throwOnFail) throw "Invalid chateau desk: ".concat(chateauItems.desk, "!");else if (!_resources.ChateauMantegna.changeDesk(chateauItems.desk) && throwOnFail) throw "We tried, but were unable to change your chateau desk to ".concat(chateauItems.desk, ". Probably.");
188
- }
189
-
190
- if (chateauItems.nightstand && _resources.ChateauMantegna.getNightstand() !== chateauItems.nightstand) {
191
- if (!nightstands.includes(chateauItems.nightstand) && throwOnFail) throw "Invalid chateau nightstand: ".concat(chateauItems.nightstand, "!");else if (!_resources.ChateauMantegna.changeNightstand(chateauItems.nightstand) && throwOnFail) throw "We tried, but were unable to change your chateau nightstand to ".concat(chateauItems.nightstand, ". Probably.");
192
- }
193
- }
194
- }
175
+ }
package/dist/combat.d.ts CHANGED
@@ -68,6 +68,16 @@ export declare class Macro {
68
68
  * @returns {Macro} This object itself.
69
69
  */
70
70
  static abort<T extends Macro>(this: Constructor<T>): T;
71
+ /**
72
+ * Add a "runaway" step to this macro.
73
+ * @returns {Macro} This object itself.
74
+ */
75
+ runaway(): this;
76
+ /**
77
+ * Create a new macro with an "runaway" step.
78
+ * @returns {Macro} This object itself.
79
+ */
80
+ static runaway<T extends Macro>(this: Constructor<T>): T;
71
81
  /**
72
82
  * Add an "if" statement to this macro.
73
83
  * @param condition The BALLS condition for the if statement.
@@ -100,9 +110,10 @@ export declare class Macro {
100
110
  * Conditionally add a step to a macro based on a condition evaluated at the time of building the macro.
101
111
  * @param condition The JS condition.
102
112
  * @param ifTrue Continuation to add if the condition is true.
113
+ * @param ifFalse Optional input to turn this into an if...else statement.
103
114
  * @returns {Macro} This object itself.
104
115
  */
105
- externalIf(condition: boolean, ifTrue: string | Macro): this;
116
+ externalIf(condition: boolean, ifTrue: string | Macro, ifFalse?: string | Macro): this;
106
117
  /**
107
118
  * Create a new macro with a condition evaluated at the time of building the macro.
108
119
  * @param condition The JS condition.
@@ -185,6 +196,18 @@ export declare class Macro {
185
196
  * @returns {Macro} This object itself.
186
197
  */
187
198
  static attack<T extends Macro>(this: Constructor<T>): T;
199
+ /**
200
+ * Create an if_ statement that triggers only against a particular monster
201
+ * @param monster The monster in question
202
+ * @param macro The macro to trigger when the monster is found
203
+ */
204
+ ifMonster(monster: Monster, macro: Macro): Macro;
205
+ /**
206
+ * Create a new macro with an if_ statement that triggers only against a particular monster
207
+ * @param monster The monster in question
208
+ * @param macro The macro to trigger when the monster is found
209
+ */
210
+ static ifMonster(monster: Monster, macro: Macro): Macro;
188
211
  }
189
212
  /**
190
213
  * Adventure in a location and handle all combats with a given macro.
@@ -207,4 +230,66 @@ export declare function adventureMacro(loc: Location, macro: Macro): void;
207
230
  * @param nextMacro Macro to execute manually after autoattack completes.
208
231
  */
209
232
  export declare function adventureMacroAuto(loc: Location, autoMacro: Macro, nextMacro?: Macro | null): void;
233
+ export declare class StrictMacro extends Macro {
234
+ /**
235
+ * Add one or more skill cast steps to the macro.
236
+ * @param skills Skills to cast.
237
+ * @returns {StrictMacro} This object itself.
238
+ */
239
+ skill(...skills: Skill[]): this;
240
+ /**
241
+ * Create a new macro with one or more skill cast steps.
242
+ * @param skills Skills to cast.
243
+ * @returns {StrictMacro} This object itself.
244
+ */
245
+ static skill<T extends StrictMacro>(this: Constructor<T>, ...skills: Skill[]): T;
246
+ /**
247
+ * Add one or more item steps to the macro.
248
+ * @param items Items to use. Pass a tuple [item1, item2] to funksling.
249
+ * @returns {StrictMacro} This object itself.
250
+ */
251
+ item(...items: (Item | [Item, Item])[]): this;
252
+ /**
253
+ * Create a new macro with one or more item steps.
254
+ * @param items Items to use. Pass a tuple [item1, item2] to funksling.
255
+ * @returns {StrictMacro} This object itself.
256
+ */
257
+ static item<T extends StrictMacro>(this: Constructor<T>, ...items: (Item | [Item, Item])[]): T;
258
+ /**
259
+ * Add one or more skill cast steps to the macro, where each step checks if you have the skill first.
260
+ * @param skills Skills to try casting.
261
+ * @returns {StrictMacro} This object itself.
262
+ */
263
+ trySkill(...skills: Skill[]): this;
264
+ /**
265
+ * Create a new macro with one or more skill cast steps, where each step checks if you have the skill first.
266
+ * @param skills Skills to try casting.
267
+ * @returns {StrictMacro} This object itself.
268
+ */
269
+ static trySkill<T extends StrictMacro>(this: Constructor<T>, ...skills: Skill[]): T;
270
+ /**
271
+ * Add one or more item steps to the macro, where each step checks to see if you have the item first.
272
+ * @param items Items to try using. Pass a tuple [item1, item2] to funksling.
273
+ * @returns {StrictMacro} This object itself.
274
+ */
275
+ tryItem(...items: (Item | [Item, Item])[]): this;
276
+ /**
277
+ * Create a new macro with one or more item steps, where each step checks to see if you have the item first.
278
+ * @param items Items to try using. Pass a tuple [item1, item2] to funksling.
279
+ * @returns {StrictMacro} This object itself.
280
+ */
281
+ static tryItem<T extends StrictMacro>(this: Constructor<T>, ...items: (Item | [Item, Item])[]): T;
282
+ /**
283
+ * Add one or more skill-cast-and-repeat steps to the macro, where each step checks if you have the skill first.
284
+ * @param skills Skills to try repeatedly casting.
285
+ * @returns {StrictMacro} This object itself.
286
+ */
287
+ trySkillRepeat(...skills: Skill[]): this;
288
+ /**
289
+ * Create a new macro with one or more skill-cast-and-repeat steps, where each step checks if you have the skill first.
290
+ * @param skills Skills to try repeatedly casting.
291
+ * @returns {StrictMacro} This object itself.
292
+ */
293
+ static trySkillRepeat<T extends StrictMacro>(this: Constructor<T>, ...skills: Skill[]): T;
294
+ }
210
295
  export {};