Is coinmaster item

From Kolmafia
Revision as of 04:54, 23 July 2011 by imported>Bale (r9555)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 = to_coinmaster(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()