Difference between revisions of "Is coinmaster item"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
(r9555)
 
imported>Gnocchi masala
m (fix obsolete syntax)
 
Line 25: Line 25:
 
boolean buyit(int qty, item it) {
 
boolean buyit(int qty, item it) {
 
   if(is_coinmaster_item(it)) {
 
   if(is_coinmaster_item(it)) {
       coinmaster seller = to_coinmaster(it.seller);
+
       coinmaster seller = it.seller;
 
       int price = sell_price(seller, it);
 
       int price = sell_price(seller, it);
 
       if(!is_accessible(seller) || seller.available_tokens < price) {
 
       if(!is_accessible(seller) || seller.available_tokens < price) {

Latest revision as of 05:42, 18 March 2012

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