Mall price: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
Convert to Template:Function2 format, use Template:SeeAlso/Mall Prices, add JS sample code
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<onlyinclude>{{{{{format|Function2}}}
<onlyinclude>{{{{{format|Function2}}}
|name=mall_price
|name=mall_price
|function1.return_type=
|function1.return_type=int
|function1.description=Returns the current mall price of the given item
|function1.description=Returns the current (lowest) mall price of an item.
|function1.param1=shop_for
|function1.param1=shop_for
|function1.param1.type=item
|function1.param1.type=item

Latest revision as of 15:28, 31 December 2020

Function Syntax

int mall_priceitem shop_for )

Returns the current (lowest) mall price of an item.
  • shop_for: Item to search for

Returns the current mall price of the given item, ignoring the first five items listed to compensate for stores with limits and min-priced sales. To prevent abuse, this will only perform an actual Mall search once per item per session; subsequent calls for the same item will return a cached value. The cache will be updated after attempts to purchase the item using the CLI or ASH buy() command (even unsuccessful ones), but not in any other conditions, including purchasing with the purchase tab.

Code Samples

Creates Mae Wests based on your stills remaining. Puts the created items into your shop, pricing them using mall_price().

ASH JavaScript
if ( stills_available() > 1 ) {
   set_property( "promptAboutCrafting", 0 );
   int stills_left = floor( stills_available() / 2 );
   create( stills_left, $item[ Mae West ] );
   print( `Created {stills_left} Mae West.`, "blue" );
   set_property( "promptAboutCrafting", 1 );
   put_shop(
     mall_price( $item[ Mae West ] ), 
     0,
     item_amount( $item[ Mae West ] ),
     $item[ Mae West ]
   );
}
const {
  create,
  itemAmount,
  mallPrice,
  print,
  putShop,
  setProperty,
  stillsAvailable,
} = require("kolmafia");

const MAE_WEST = Item.get("Mae West");
if (stillsAvailable() > 1) {
  setProperty("promptAboutCrafting", "0");
  let stillsLeft = Math.floor(stillsAvailable() / 2);
  create(stillsLeft, MAE_WEST);
  print("Created " + stillsLeft + " Mae West.", "blue");
  setProperty("promptAboutCrafting", 1);
  putShop(mallPrice(MAE_WEST), 0, itemAmount(MAE_WEST), MAE_WEST);
}

See Also

historical_age() | historical_price() | mall_price() | mall_prices()