Mall price: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Eliteofdelete
No edit summary
Convert to Template:Function2 format, use Template:SeeAlso/Mall Prices, add JS sample code
Line 1: Line 1:
{{
<onlyinclude>{{{{{format|Function2}}}
#vardefine:name|mall_price}}{{
|name=mall_price
#vardefine:return_type|int}}{{
|function1.return_type=
 
|function1.description=Returns the current mall price of the given item
FunctionPage|
|function1.param1=shop_for
name={{#var:name}}|
|function1.param1.type=item
 
|function1.param1.description=Item to search for
function1={{Function|
|description=
name={{#var:name}}|
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 {{f|buy}} command (even unsuccessful ones), but not in ''any'' other conditions, including purchasing with the purchase tab.
aggregate={{#var:aggregate}}|
|code1={{CodeSample
return_type={{#var:return_type}}|
  |title=Code Samples
return_also={{#var:return_also}}|
  |description=Creates Mae Wests based on your stills remaining. Puts the created items into your shop, pricing them using {{f|mall_price}}.
parameter1={{Param|item|shop_for}}|
  |code=
p1desc={{Pspan|shop_for}} is the item to inquire on the mall price of|
{{{!}} class="wikitable"
}}|
! style="width: 45%" {{!}} ASH
 
! style="width: 55%" {{!}} JavaScript
function_description=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 {{f|buy}} command (even unsuccessful ones), but not in ''any'' other conditions, including purchasing with the purchase tab.|
{{!}}- style="vertical-align: top"
{{!}}
<syntaxhighlight lang="d" line highlight="8">
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 ]
  );
}
</syntaxhighlight>
{{!}}
<syntaxhighlight lang="js" line highlight="18">
const {
  create,
  itemAmount,
  mallPrice,
  print,
  putShop,
  setProperty,
  stillsAvailable,
} = require("kolmafia");


code1={{CodeSample|
const MAE_WEST = Item.get("Mae West");
title=Code Samples|
if (stillsAvailable() > 1) {
description=Creates Mae Wests based on your stills remaining. Puts the created items into your shop, pricing them using the mall_price() command.|
  setProperty("promptAboutCrafting", "0");
code=
  let stillsLeft = Math.floor(stillsAvailable() / 2);
<syntaxhighlight>
  create(stillsLeft, MAE_WEST);
if (stills_available() > 1) {
  print("Created " + stillsLeft + " Mae West.", "blue");
  set_property("promptAboutCrafting", 0);
  setProperty("promptAboutCrafting", 1);
  int stillsleft;
  putShop(mallPrice(MAE_WEST), 0, itemAmount(MAE_WEST), MAE_WEST);
  stillsleft = floor((stills_available()/2));
  create(stillsleft, $item[Mae West]);
  print("Created " + stillsleft + " Mae West.", "blue");
  set_property("promptAboutCrafting", 1);
  put_shop(mall_price($item[Mae West]), 0, item_amount($item[Mae West]), $item[Mae West]);
}
}
</syntaxhighlight>|
</syntaxhighlight>
moreinfo=
{{!}}}
Mall_price() is best used when the exact price of the item is needed. See historical_price() for theorizing.
  |moreinfo=
}}|
 
see_also={{SeeAlso|historical_price|buy|retrieve_item}}|
cli_equiv=The CLI command "searchmall" also returns current mall prices.|
special=Untradeable items will return 0 without any server requests. Items not listed in the mall will return -1. When not logged in, this function returns -1 for all items.|
}}
}}
 
|see_also={{SeeAlso/Mall Prices}}
|cli_equiv=
|more_info=
|special=
|{{{1|}}}
}}</onlyinclude>
[[Category:Item Management]]
[[Category:Item Management]]

Revision as of 15:24, 31 December 2020

Function Syntax



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