If buy() fails, can we get mall_price() updated?

dj_d

Member
This is a scenario from eatdrink.ash. You use mall_price to figure out how much you should pay. You buy the item for up to that amount, actually a bit more:
buy(1, it, mall_price(it)*1.25)
Buy() fails because the price has gone way up. The problem is, mall_price still mistakenly thinks the price is low. I want to recalculate and make sure it's a good value at the new price, then try again.

So It would be great if mall_price updated the price on an item it if a buy() command for that item fails because the item was unavailable for that price, and the limit price was equal to or greater than the mall_price amount. Or at the very least, if buy(quant, it, price) fails, set mallprice(it) = max(mallprice(it), price+1).

Did that all make sense? Any reasons that won't work? The workaround in eatdrink.ash otherwise is pretty ugly.
 

Bale

Minion
Asked about that previously. Jason pointed out that would allow unlimited mall price searches per day by simply sending buy() requests with a low price limit that you know will fail. :(

What I do if my purchase fails is to raise the price limit to the most that makes sense and only try to purchase 1 of the item. Then if it fails, I remove it from consideration altogether. I'm not happy about it, but... meh.
 

dj_d

Member
No, the situation I described doesn't do that, since it only forces an update if the buy request is at or above mall_price. In plain english, if you make a good-faith attempt to buy at the ostensible mall price and fail, it's reasonable to update you with the current mall price.
 

Bale

Minion
I understand now. That sounds reasonable. If a buy request is made for a price that is at or above mall_price(), then it should update on failure...

I hope that Jason and Veracity agree with us.
 

dj_d

Member
The alternative is to wrap mall_price() and, in the case where a buy() fails, return the amount of the attempted buy + 1. But that's more likely to generate a second purchase failure than just finding the correct new mall_price().

(this isn't theoretical - eatdrink just hung on twinkly wads for this reason yesterday; there were some of them super-cheap, with a limit of 9 or so).
 

dj_d

Member
Yay! I just knew that as soon as I wrote the workaround, it would become unnecessary. Thank you, universe*, and thank you, JH**.

* sarcastically
** seriously

:)
 
Top