Feature - Implemented Overload put_shop() to stock from Hagnk's

I'd love a version of put_shop() to be able to stock my shop from Hagnk's instead of only from inventory. The Store Manager interface can already do this, but as far as I can tell, there's not currently an ASH equivalent.

I'd propose boolean put_shop( int, int, int, item, boolean from_hagnks )
 

Bale

Minion
I'll mention that this is similar to our update to purchase with meat from Hangk's. We created a new function called buy_using_storage() instead of overloading buy(). Perhaps we shouldn't overload put_shop() which already has too many parameters. Instead we could create a new function called put_shop_using_storage().

I think consistency is a good thing.
 
That sounds fine to me, too. I guess in that case, it would have two versions, a la put_shop():

boolean put_shop_using_storage( int price, int limit, item it )

boolean put_shop_using_storage( int price, int limit, int qty, item it )
 
Bumping this again. I spend upwards of 90% of my time in-run, so the existing put_shop() does very little for me. I can't overstate how helpful a stock-from-Hangk's version would be. I keep hoping that I'm not the only one, and that someone else will chime in...
 

heeheehee

Developer
Staff member
One concern that I had and never posted apparently is that "put_shop_using_storage" is an awfully unwieldy name. Will look into this again. Sorry for the delay!
 

Bale

Minion
Unwieldy? That thought should have occurred before buy_using_storage() was created. This is just a natural evolution of the naming schema. Now any other option would lack consistency.
 

heeheehee

Developer
Staff member
So, apparently put_shop() works by batching requests for "shop put". Similarly, buy_using_storage() puts together requests via "buy using storage".

There's also not currently code to add items from storage to the shop with limits. I'll have to look into that in a bit, as well.
 

Crowther

Active member
Unwieldy? That thought should have occurred before buy_using_storage() was created. This is just a natural evolution of the naming schema. Now any other option would lack consistency.
:(

I think that thought every time I type "mallbuy using storage". I know aliases and such, but there are advantages to staying vanilla. Still, I think it is past time for me to write a "pull and buy from the mall if I don't have one, then pull" alias.

Anyway, I really don't like "using storage" it is long and feels wrong and something. I agree it is too late now. That ship has sailed. Constancy wins.
 

Bale

Minion
I think it is past time for me to write a "pull and buy from the mall if I don't have one, then pull" alias.

I'll save you the trouble:

Code:
alias buypull => ash if(in_hardcore()) print("You cannot pull items in hardcore.", "red"); else {matcher input = create_matcher("(?:(\\d+)\\s+)?(.+)", $string[%%]); if(input.find()) {item topull = to_item(input.group(2)); int q = input.group(1) == ""? 1: input.group(1).to_int(); if(topull == $item[none]) print('Unknown items: '+q+" "+input.group(2), "red"); else if(pulls_remaining() >= q) {if(storage_amount(topull) < q) buy_using_storage(q-storage_amount(topull), topull, get_property("autoBuyPriceLimit").to_int()); take_storage(q, topull);} else print((pulls_remaining() == 0? "No": "Only "+pulls_remaining())+" pulls remaining for today.", "red");} else print("Unparseable input.", "red");}

The only weakness of that alias is that you can do "buypull 3 power pill" but if you try "buypull 3 power pills" it will fail. I need to fix plural recognition one of these days, but I don't do softcore very often so I haven't gotten around to it yet. (The quantity is an optional parameter -- it will default to 1.)
 
Last edited:

heeheehee

Developer
Staff member
Hm. I did some digging for historical context regarding the decision behind buy_using_storage(), and found this thread: http://kolmafia.us/showthread.php?16143. The rationale for a new CLI command was that "buy" was overloaded to either purchase from NPC stores or mall stores (whichever's cheaper); thus, "buy using storage" was introduced to force mall purchasing using meat from storage.

From a gameplay perspective, though, there isn't a way of specifying to use meat from Hagnk's when making mall purchases; it's decided by whether you can_interact(). If I were to implement this today, I'd probably have favored an explicit mallbuy command (and a corresponding mallbuy() ASH function), where the user would need to understand the caveat that mallbuy only dumps results into inventory if he can_interact().

That said, I support the design decisions outlined in that thread, even if I personally think the naming conventions are a bit unwieldy -- I doubt most players will write scripts using, say, put_shop_using_storage(), and even so, it involves less cognitive load than, say, overloading put_shop() to optionally also take a boolean argument.

Also, my buypull alias is just "buy using storage %%; pull %%", since that's usually what I want anyways.
 

Bale

Minion
I think it is past time for me to write a "pull and buy from the mall if I don't have one, then pull" alias.

The challenge path season is over so as we approach Crimbo I'm finally finishing up my wicker outfit which means softcore. To make things a tittle bit easier I finished perfecting my buypull alias. It's kinda insane now and I'm willing to share.

Code:
alias buypull => ash string pulls(){int p = pulls_remaining(); return p == 0? "No pulls": "Only "+(p == 1? "1 pull": p+" pulls");}if(in_hardcore()) print("You cannot pull items in hardcore.", "red"); else {matcher input = create_matcher("(?:(\\d+)\\s+)?(.+)", $string[%%]); if(input.find()) {int q = input.group(1) == ""? 1: input.group(1).to_int(); item topull = to_item(input.group(2),q); if(topull == $item[none]) topull = to_item(input.group(2),2); if(topull == $item[none]) print('Unknown items: '+q+" "+input.group(2), "red"); else if(pulls_remaining() < 0){int s = shop_amount(topull); if(s > 0) take_shop(min(s, q), topull); buy(q-s, topull, get_property("autoBuyPriceLimit").to_int());} else if(pulls_remaining() >= q) {if(storage_amount(topull) < q) {if(shop_amount(topull) > 0) take_shop(min(shop_amount(topull), q-storage_amount(topull)), topull); buy_using_storage(q-storage_amount(topull), topull, get_property("autoBuyPriceLimit").to_int());} take_storage(q, topull); print(pulls()+" remain.", "blue");} else print(pulls()+" pulls remaining for today.", "red");} else print("Unparseable input.", "red");}

The most interesting improvement to it is that if I lack an item in storage, but do have that item in my mall store, it will pull from my shop before considering purchasing in the mall. (If I have a partial amount in my shop, it does both.)

The second most interesting improvement is that if I use the alias in aftercore it will pull items from my shop and then consider purchasing any remainder in the mall. This is nice because sometimes I wish for a command that figures out if I have it in my own store before purchasing in from others. Who says that pulling is only useful for ronin?
 
Top