Feature Consider retrieval price for CLI command "cheapest"

heeheehee

Developer
Staff member
I am fairly fond of the "cheapest" CLI command, but one thing that I feel is lacking is that it doesn't take into account retrieval price (which Mafia uses internally when retrieving an item).

Current state of things:
> cheapest snow crab, mouth-watering mayolus

Searching for "snow crab"...
Search complete.
Searching for "mouth-watering mayolus"...
Search complete.
mouth-watering mayolus @ 6,000
snow crab @ 6,750

> retrieve_price snow berries

Returned: 2650
(note that 2 snow berries can be used to make a snow crab at no additional cost)

What I would like to be the case:
> cheapest snow crab, mouth-watering mayolus

Searching for "snow crab"...
Search complete.
Searching for "snow berries"...
Search complete.
Searching for "mouth-watering mayolus"...
Search complete.
snow crab @ 5,300
mouth-watering mayolus @ 6,000
 

heeheehee

Developer
Staff member
Oh, right, I had jiggered a custom ASH function for myself that exposed the internal retrieval price. Eh, same thing.


edit that doesn't really add anything:
Either way, it could be written using a little ASH script as something like
Code:
int retrieve_price(item it) {
	int FAIL = 2 ** 31;
	float price = is_tradeable(i) ? historical_price(i) : FAIL;
	float total;
	if (i.seller != $coinmaster[none]) {
		price = min(sell_price(i.seller, i) * historical_price(i.seller.item), price);
	}
	foreach j,qty in get_ingredients(i) {
		if ($items[disassembled clover, wad of dough] contains j) {
			// stop infinite clover recursion.
			total = FAIL;
			break;
		}
		total += historical_price(j) * qty;
	}
	if (count(get_ingredients(i)) == 0) {
		total = FAIL;
	}
	price = min(total, price);
	return price;
}
 
Last edited:

Veracity

Developer
Staff member
Of course, for internal code, we can use "the internal retrieval price", even if don't expose it to scripters.
 
Top