Difference between pages "Sell" and "Visit"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Gnocchi masala
m (Fix obsolete syntax)
 
imported>Bale
(r9555)
 
Line 1: Line 1:
 
{{
 
{{
#vardefine:name|sell}}{{
+
#vardefine:name|visit}}{{
 
#vardefine:return_type|boolean}}{{
 
#vardefine:return_type|boolean}}{{
  
Line 12: Line 12:
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
 
parameter1={{Param|coinmaster|master}}|
 
parameter1={{Param|coinmaster|master}}|
parameter2={{Param|int|qty}}|
 
parameter3={{Param|item|it}}|
 
 
p1desc={{pspan|master}} is the coinmaster to purchase from|
 
p1desc={{pspan|master}} is the coinmaster to purchase from|
p2desc={{pspan|qty}} is the number to purchase|
+
 
p3desc={{pspan|it}} is the item to purchase|
 
 
}}|
 
}}|
  
function_description=Attempts to purchase {{pspan|qty}} amount of item {{pspan|it}} from {{pspan|master}}. If {{pspan|qty}} is less than 1, the function will return true without purchasing anything. Otherwise it returns true if the purchase succeeded and false if it did not.|
+
function_description=Visits a coinmaster to see what is currently for sale there. This is useful for coinmasters whose inventory may change, such as the Hermit, Mr. Store and Traveling Trader. Returns true if the visit was successful or false if it was unsuccessful.|
  
 
code1={{CodeSample|
 
code1={{CodeSample|
 
title=Code Sample|
 
title=Code Sample|
description=This expands upon selling to a coinmaster to show many related functions.|
+
description=This checks to see if a clover is currently available for purchase.|
 
code=
 
code=
 
<syntaxhighlight>
 
<syntaxhighlight>
boolean sell_coinmaster(int qty, item it) {
+
if(visit($coinmaster[Hermit])) {
  coinmaster master = it.buyer;
+
   if(sells_item($coinmaster[Hermit], $item[ten-leaf clover]))
   if(master == $coinmaster[none]) {
+
       print("There is still a ten-leaf clover available to purchase today!");  
       print("No coinmaster will purchase that", "red");
+
   else print("The Hermit is out of clovers. :(");  
      return false;
+
} else print(inaccessible_reason($coinmaster[Hermit]));
  }
 
   if(!is_accessible(master)) {
 
      print(inaccessible_reason(master), "red");
 
      return false;
 
  }
 
  int coins = master.available_tokens;
 
  int price = sell_price(master, it);
 
  print("Selling "+it+" to "+master+" for "+price+" "+coins+(qty > 1? " each.": "."));
 
  return sell(master, qty, it);
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
}}|
 
}}|
  
see_also={{SeeAlso|buy|sell_price}}|
+
see_also={{SeeAlso|is_accessible|sells_item|buys_item}}|
 
}}
 
}}
  
 
[[Category:Item Management]]
 
[[Category:Item Management]]

Latest revision as of 06:04, 20 July 2011

Function Syntax

boolean visit(coinmaster master )

  • master is the coinmaster to purchase from

Visits a coinmaster to see what is currently for sale there. This is useful for coinmasters whose inventory may change, such as the Hermit, Mr. Store and Traveling Trader. Returns true if the visit was successful or false if it was unsuccessful.

Code Sample

This checks to see if a clover is currently available for purchase.

if(visit($coinmaster[Hermit])) {
   if(sells_item($coinmaster[Hermit], $item[ten-leaf clover])) 
      print("There is still a ten-leaf clover available to purchase today!"); 
   else print("The Hermit is out of clovers. :("); 
} else print(inaccessible_reason($coinmaster[Hermit]));

See Also

is_accessible() | sells_item() | buys_item()