Buy price: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
r9555
 
imported>Gnocchi masala
m Fix obsolete syntax
Line 26: Line 26:
void print_price(item it) {
void print_price(item it) {
   if(is_coinmaster_item(it)) {
   if(is_coinmaster_item(it)) {
       coinmaster master = to_coinmaster(it.seller);
       coinmaster master = it.seller;
       string token = master.token;
       string token = master.token;
       int price = buy_price(master, it);
       int price = buy_price(master, it);

Revision as of 05:44, 18 March 2012

Function Syntax

boolean buy_price(coinmaster master ,item it )

  • master is the coinmaster to query
  • it is the item to check

Returns the number of tokens that master will trade you if you sell it to him.

Code Sample

This prints the price for which you can sell an item to a coinmaster.

void print_price(item it) {
   if(is_coinmaster_item(it)) {
      coinmaster master = it.seller;
      string token = master.token;
      int price = buy_price(master, it);
      if(price > 1) token += "s";
      print("You can sell that for "+ price + " "+token +".");
   } else if(is_tradeable(it))
      print("You can sell that in the mall for "+mall_price(it)+ " meat.");
   else if(autosell_price(it) > 0)
      print("You can autosell that for "+autosell_price(it)+ " meat.");
   else print("You cannot sell that!", "red");
}

See Also

buy() | sell_price()