Bug - Fixed sells_item() does not report current status of coinmaster

Bale

Minion
Testing this tiny script:

PHP:
visit($coinmaster[Hermit]);
if(sells_item($coinmaster[Hermit], $item[ten-leaf clover]))
	print("There is still a ten-leaf clover available to purchase today!");
else print("The Hermit is out of clovers. :(");

Unfortunately that will report that the Hermit is selling ten-leaf clovers, even if he is sold out. If all the sells_item() command does is to report that the value of $item[ten-leaf clover].seller == "Hermit", then it isn't really very useful. I could check that instead and the proxy record is more useful.


Is this command behaving as intended?
 

Veracity

Developer
Staff member
The Hermit is the ONLY Coinmaster whose stock varies within a particular day; Mr. Store and the Traveling Trader may not have the same stock as they had yesterday or will have tomorrow, but they don't sell out. The Hermit's stock can also vary from character to character; the figurine of an ancient seal is available only to Seal Clubbers, and the gold twig is only available to the very newest characters.

As coded, the Hermit's list includes the seal figurine if you are a Seal Clubber, never includes the golden twig, and always includes a ten-leaf clover, with the "quantity" set to 0 or 1 or whatever, after we visit the hermit for the first time. The Coinmaster Frame will show you "ten leaf clover (0)" if he is sold out for the day.

Note that last comment: we don't KNOW if there is a clover available until you visit - which I see you have done in your code snippet.

The sells_item() function (not "command") should presumably look at the available quantity, rather than simply seeing if the item on the coinmaster's list.
 

Veracity

Developer
Staff member
Well, I have fix for the bug reported, but it reveals another bug: when you buy a ten-leaf clover from the hermit (through ASH, at least), we do not decrement the available clover count. So, the following works:

Code:
coinmaster hermit = $coinmaster[ hermit ];
item clover = $item[ ten-leaf clover ];

hermit.visit();
while ( hermit.sells_item( clover ) ) {
	hermit.buy( 1, clover );
	hermit.visit();
 }

But, leaving out hermit.visit() in the loop will not currently work.

There's also no way to ask how many of an item is available ( if it is limited ) so that you could just buy all of them with a single buy() call.
 

Veracity

Developer
Staff member
Revision 9655 fixes both issues; hermit.sells_item() will return false if you've bought all the clovers today, and when you buy a clover, we no longer depend on being able to look at his stock to see how many clovers are still available, since if you have no worthless items, he "sends you packing" and we can't look.

One last oddity, which I will not fix: buy() returns true or false depending on whether your inventory of the desired item went up by the amount you tried to buy. If you have clover protection active, that will always fail when you buy ten-leaf clovers - either from the hermit or from the mall.
 

Bale

Minion
Thank you.

One last oddity, which I will not fix: buy() returns true or false depending on whether your inventory of the desired item went up by the amount you tried to buy. If you have clover protection active, that will always fail when you buy ten-leaf clovers - either from the hermit or from the mall.

That certainly deserves a mention on the wiki. That applies to the non-coinmaster version of buy() as well, right?
 
Last edited:
Top