Sell price: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
r9555
 
imported>AlbinoRhino
m update code sample
 
(2 intermediate revisions by 2 users not shown)
Line 9: Line 9:
name={{#var:name}}|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
aggregate={{#var:aggregate}}|
return_type=boolean|
return_type=int|
return_also={{#var:return_also}}|
return_also={{#var:return_also}}|
parameter1={{Param|coinmaster|master}}|
parameter1={{Param|coinmaster|master}}|
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.buyer);
       coinmaster master = it.seller;
       string token = master.token;
       string token = master.token;
       int price = buy_price(master, it);
       int price = sell_price(master, it);
       if(price > 1) token += "s";
       if(price > 1) token += "s";
       print("You can buy that for "+ price + " "+token +".");
       print("You can buy that for "+ price + " "+token +".");

Latest revision as of 22:44, 9 July 2017

Function Syntax

int sell_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 charge you if you want him to sell it to you.

Code Sample

This prints the price for which you can buy an item from a coinmaster.

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

See Also

sell() | buy_price()