Is coinmaster item

From Kolmafia
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Function Syntax

boolean is_coinmaster_item(item it )

  • it is the item to check

Returns true if it can be purchased from a coinmaster. You'll need to discover which coinmaster by checking the seller proxy record.

Code Sample

Purchases an item from a coinmaster if possible. Otherwise purchased from the mall.

boolean buyit(int qty, item it) {
   if(is_coinmaster_item(it)) {
      coinmaster seller = it.seller;
      int price = sell_price(seller, it);
      if(!is_accessible(seller) || seller.available_tokens < price) {
         print("You cannot afford to purchase that from the "+ seller+ ".", "red");
      } else if(seller.available_tokens < price * qty) {
         print("You don't have enough "+ seller.token+ "s to purchase that many. "
            +" Buying as many from the coinmaster as you can afford.");
         buy(seller, floor(qty / price), it);
      } else return buy(seller, qty, it);
   }
   return buy(qty, it);
}

See Also

sells_item() | sell_price() | is_accessible()