Bug - Fixed Sometimes unable to buy limited items from Underground Fireworks Shop

doRetrieveItem has...
Java:
    if (shouldUseNPCStore || scriptSaysBuy) {
      if (sim) {
        return shouldUseNPCStore ? "buy from NPC" : "buy";
      }

      // If buying from the mall will leave the item in storage, use only NPCs
      AdventureResult instance = item.getInstance(missingCount);
      boolean onlyNPC = forceNoMall || !InventoryManager.canUseMall();
      List<PurchaseRequest> results =
          onlyNPC ? MallPriceManager.searchNPCs(item) : MallPriceManager.searchMall(instance);
      KoLmafia.makePurchases(
          results,
          results.toArray(new PurchaseRequest[0]),
          InventoryManager.getPurchaseCount(itemId, missingCount),
          isAutomated,
          0);

I'm not sure whether `instanceof NPCPurchaseRequest` is adequate, especially for items that you've already purchased up to the limit.
I looked at that and wondered how it knew that had to get make an NPC purchase from the fireworks shop.

Code:
  public static boolean canUseMall(final int itemId) {
    return ItemDatabase.isTradeable(itemId) && InventoryManager.canUseMall();
  }
This is the crux: the firework shop equipment is all "lasts until rollover" quest items. I.e., not tradable.

Therefore, MallPriceManager.searchNPCs will return an array with a single NPCPurchaseRequest in it.

The instanceof will pick that out fine. What what will the "count" be if you've already bought one? I.e., "_fireworksShopHatBought" is true? Where, exactly, is that property enforced? I'll write an additional test.

Edit: MallPriceManager.searcNPCs() calls NPCStoreDatabase.getPurchaseRequest() which call NPCStoreDataBase.canPurchase(), which will return false if you've already bought a firework shop limited it.

Which is to say, the array of potential PurchaseRequests will be empty.

I think the instanceof will do fine, since there will only be a PurchaseRequest in the array if you can actually use it.
 
I'm experiencing this again for reasons I assume but cannot verify are related to the recent changes to coinmaster and shop.php handling
 
The Underground Fireworks Shop is an NPC store, not a coinmaster.

1) With a character in a clan with that shop, if I do a Mall Search for "fedora", I see a fedora-mounted-fountain available from that shop for (1 @475).
I.e., limited to 1 and not greyed out.

Code:
> acquire fedora-mounted fountain

Purchasing fedora-mounted fountain (1 @ 475)...
You spent 475 Meat
You acquire an item: fedora-mounted fountain
Purchases complete.

Doing that same mall search, it no longer appears.

2) With a character in the same clan, but in a Standard run, it does not appear.

All of the above are as expected.

Please describe exactly what you are "experiencing".
What you did. What you expected to happen. What actually happened.
Thanks.
 
For two days in a row, the following lines of code, which for a long time have basically functioned correctly, no longer successfully purchase the item in question:
JavaScript:
        visitUrl("clan_viplounge.php?action=fwshop&whichfloor=2");
        buy(1, Item.get("sombrero-mounted sparkler"));
I'm able to abort my script, manually purchase the item, and resume.
The following prints to the CLI when it attempts to purchase it:
Visiting Underground Fireworks Shop in clan VIP lounge

/shop.php?whichshop=fwshop
But no successful purchase actually occurs.
When it happened the first time, I assumed I hit an internet hiccup or my computer had started to fall asleep or something else odd was happening. When it happened the second, I assumed it was related to older issues in this area, and came here. I'll pay closer attention tomorrow to see if there's anything else I can glean from the session log or the situation I'm stuck in.
 
OK. I should be able to test that. My aftercore character with access to the fireworks shop bought a hat, not an accessory, so it should still be available.
 
With my (currently open for review) PR:

Code:
> set _fireworksShop=false

_fireworksShop => false

> set _fireworksShopEquipmentBought=false

> set _fireworksShopHatBought=false

_fireworksShopHatBought => false

> ashq visit_url("clan_viplounge.php?action=fwshop&whichfloor=2")

Visiting Underground Fireworks Shop in clan VIP lounge

> get _fireworksShop

true

> get _fireworksShopEquipmentBought

false

> get _fireworksShopHatBought

true

> ash buy($item[sombrero-mounted sparkler])

Searching for "sombrero-mounted sparkler"...
Search complete.
Returned: false

> ash buy($item[rocket boots])

Purchasing rocket boots (1 @ 950)...
You spent 950 Meat
You acquire an item: rocket boots
Purchases complete.
Returned: true
 
Something for me to think about:

Code:
> ash buy($item[sombrero-mounted sparkler])

Searching for "sombrero-mounted sparkler"...
Search complete.
Returned: false

> ash buy($item[rocket boots])

Purchasing rocket boots (1 @ 950)...
You spent 950 Meat
You acquire an item: rocket boots
Purchases complete.
Returned: true

rocket boots are a quest item available from an NPC store.
We knew we could buy them, so we just did it.

sombrero-mounted sparkler is a quest item available from an NPC store.
We knew we couldn't buy them - because they are one-per-day and we'd already done it.
So what's with this "searching"?
We're not going to find quest items in the mall.
 
Back
Top