libram 0.10.8 → 0.10.9

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.
@@ -1,4 +1,4 @@
1
- import { autosellPrice, buy, canInteract, cliExecute, getFuel, getWorkshed, haveEffect, historicalAge, historicalPrice, isNpcItem, Item, itemAmount, mallPrice, mallPrices, retrieveItem, visitUrl, } from "kolmafia";
1
+ import { autosellPrice, availableAmount, buy, canInteract, cliExecute, getFuel, getWorkshed, haveEffect, historicalAge, historicalPrice, isNpcItem, Item, itemAmount, mallPrice, mallPrices, npcPrice, retrieveItem, use, visitUrl, } from "kolmafia";
2
2
  import { getAverageAdventures, have as haveItem } from "../../lib.js";
3
3
  import { $effect, $item, $items } from "../../template-string.js";
4
4
  import { clamp } from "../../utils.js";
@@ -160,8 +160,20 @@ export function fillTo(targetUnits) {
160
160
  const efficiencyOfSecondBest = mallPrice(secondBest) / getAverageAdventures(secondBest);
161
161
  ceiling = Math.ceil(efficiencyOfSecondBest * getAverageAdventures(bestFuel));
162
162
  }
163
- if (!canInteract())
164
- retrieveItem(count, bestFuel);
163
+ if (!canInteract()) {
164
+ // If we can't access the bugbear bakery but do have access to all-purpose flower, use that to get soda bread
165
+ if (npcPrice($item `wad of dough`) === 0 &&
166
+ npcPrice($item `all-purpose flower`) > 0) {
167
+ const maxTries = Math.ceil(count / 35); // minimum amount of wad of dough created from all-purpose flower is 35
168
+ for (let i = 0; i < maxTries && availableAmount($item `wad of dough`) < count; i++) {
169
+ buy($item `all-purpose flower`);
170
+ use($item `all-purpose flower`);
171
+ }
172
+ retrieveItem(count, bestFuel);
173
+ }
174
+ else
175
+ retrieveItem(count, bestFuel);
176
+ }
165
177
  else if (ceiling)
166
178
  buy(count, bestFuel, ceiling);
167
179
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libram",
3
- "version": "0.10.8",
3
+ "version": "0.10.9",
4
4
  "description": "JavaScript helper library for KoLmafia",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",