Feature - Implemented Make buy/sell for coinmasters work with batch_open/close

zarqon

Well-known member
Many coinmasters are only accessible in a certain outfit, which means that repeated calls to the coinmaster versions of buy() or sell() can result in many, many outfit changes, unless special handling is written into the script. But it's not always easy to work around.

We could manage it by writing a map or switch function of coinmaster => outfit name, then foreaching all the items and adding qualifying items to a separate map for each coinmaster, then processing those maps one by one with outfit changes before and after. But that's nontrivial and is the part that leads me to this feature request -- I don't think it should be so much easier in ASH to hit the server many times for a given task than it is to hit it few times.

So I'd like to propose that the coinmaster versions of buy() and sell() function with batch_open() and batch_close(). Mafia would group all the sell() calls by coinmaster and perform all the sell operations for each coinmaster consecutively, with a single outfit checkpoint at the beginning and end of the entire batch and individual coinmaster outfit swaps in between as needed. Likewise for buy(). So, despite the fact that you can't buy or sell multiple types of items at once, it would still save as many as two server hits per item.
 

Veracity

Developer
Staff member
batch_open and batch_close work with commands that are implemented as CLI commands. They work by adding more and more parameters to a single CLI command. The CLI command with all the arguments is executed when you do batch_close.

There is no CLI command to "buy" from a coinmaster. That was on my initial list of things to do, but I decided that it wasn't especially useful.

Adding such would be the necessary first step towards implementing this feature.
 

Veracity

Developer
Staff member
Revision 13254 does the "guts" of this: a CoinMasterRequest now takes an array of items to buy or sell, rather than just a single item.
 

Veracity

Developer
Staff member
Revision 13256 adds the CLI command that will be needed for this:

coinmaster buy <nickname> <item>, ...
coinmaster sell <nickname> <item>, …

"nickname" is fuzzy matched and comes from the following list:

BURT
FDKOL
arcade
awol
bigbrother
dimemaster
dollhawker
dreadsylvania
fudge
gameshoppe
hermit
hunter
isotopesmithery
lunarlunch
mrstore
quartersmaster
shore
snacks
swagger
trader
trapper
vendingmachine

crimbo11
cartel
bonealtar
CRIMBCO

Obviously, the non-longer accessible coinmasters (CRIMBCO, cartel, etc.) will not work.
 

Veracity

Developer
Staff member
So I'd like to propose that the coinmaster versions of buy() and sell() function with batch_open() and batch_close(). Mafia would group all the sell() calls by coinmaster and perform all the sell operations for each coinmaster consecutively, with a single outfit checkpoint at the beginning and end of the entire batch and individual coinmaster outfit swaps in between as needed.
This is now easily done; the return value for all "sell" type commands is simply a boolean saying whether it worked or not.

Likewise for buy().
Not so easy. Yes, it would save outfit swapping and such, but the return value for all "buy" type commands is the number of items that were obtained. When you are buying diverse items, what do you propose that the return value be?
 

Veracity

Developer
Staff member
Revision 13272 lets you use multiple "prefixes" inside a batch_open()/batch_close() section.

Revision 13273 makes sell( <coinmaster>, <count>, <item> ) go through "coinmaster sell <coinmaster>" if the script is batching commands - and the "prefix" in this case is "sell <coinmaster>".

Given those two changes, you could batch multiple sales to the Dimemaster and multiple sales to the Quartersmaster and when you do batch_close(), each group will be executed as a single command, which should, we hope, only do outfit swapping once.

Nothing is done for buy( <coinmaster>, <count>, <item> ) since, as I mentioned above, the buy command returns the "number obtained", not a "success vs. failure", and we can't batch commands that return anything other than "success vs. failure".

I think that's all I can do with this Feature.
 

zarqon

Well-known member
Excellent. Selling IsleWar items was the initial reason for the feature request, so as far as I'm concerned this is as fully implemented as I personally need it to be. Thanks very much Veracity!
 
Top