Difference between revisions of "Mall price"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[int]] '''mall_price( item it )'''
+
<onlyinclude>{{{{{format|Function2}}}
 +
|name=mall_price
 +
|function1.return_type=int
 +
|function1.description=Returns the current (lowest) mall price of an item.
 +
|function1.param1=shop_for
 +
|function1.param1.type=item
 +
|function1.param1.description=Item to search for
 +
|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.
 +
|code1={{CodeSample
 +
  |title=Code Samples
 +
  |description=Creates Mae Wests based on your stills remaining. Puts the created items into your shop, pricing them using {{f|mall_price}}.
 +
  |code=
 +
{{{!}} class="wikitable"
 +
! style="width: 45%" {{!}} ASH
 +
! style="width: 55%" {{!}} JavaScript
 +
{{!}}- 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");
  
Returns the current mall price of the given item. Specifically it returns the price of the 5th item that would be purchased. Hopefully this will skip over some limited items and give you useful data. If items are purchased mall_price is automatically increased to the price of the new 5th item.
+
const MAE_WEST = Item.get("Mae West");
 
+
if (stillsAvailable() > 1) {
For example, if there are 7 Stench Wads priced at 385 meat and 700 priced at 390, the following code:
+
   setProperty("promptAboutCrafting", "0");
 
+
   let stillsLeft = Math.floor(stillsAvailable() / 2);
<code>
+
   create(stillsLeft, MAE_WEST);
  print("stench wad price: "+ mall_price($item[stench wad]));
+
   print("Created " + stillsLeft + " Mae West.", "blue");
   buy(5, $item[stench wad]);
+
   setProperty("promptAboutCrafting", 1);
   print("stench wad price: "+ mall_price($item[stench wad]));
+
   putShop(mallPrice(MAE_WEST), 0, itemAmount(MAE_WEST), MAE_WEST);
   buy(5, $item[stench wad]);
+
}
   print("stench wad price: "+ mall_price($item[stench wad]));
+
</syntaxhighlight>
</code>
+
{{!}}}
 
+
  |moreinfo=
Will yield this output:
+
}}
 
+
|see_also={{SeeAlso/Mall Prices}}
<code>
+
|cli_equiv=
  Searching for "stench wad"...
+
|more_info=
  stench wad price: 385
+
|special=
  Searching for "stench wad"...
+
|{{{1|}}}
  Purchasing stench wad (5 @ 385)...
+
}}</onlyinclude>
   You acquire stench wad (5)
+
[[Category:Item Management]]
   Purchases complete.
 
  stench wad price: 390
 
  Using cached search results for stench wad...
 
  Purchasing stench wad (2 @ 385)...
 
  You acquire stench wad (2)
 
  Purchasing stench wad (3 @ 390)...
 
  You acquire stench wad (3)
 
  Purchases complete.
 
  stench wad price: 390
 
</code>
 
 
 
Notice how mall_price went to 390 before any stench wads were purchased at that price. Magic!
 
[[Category:Your Character | My meat()]]
 
[[Category:Ash Functions | My meat()]]
 
 
 
When not logged in, this function returns -1.
 
 
 
<center><table style="width:80%;margin-top:+.7em;background-color:#F4DF3B;border:2px solid #8663A8"><tr>
 
    <td class="box_tgen" style="text-align:center;color:#000;font-size:90%;border:none;margin: 0;padding:.1em;">
 
'''See Also:''' <br> [[my_closetmeat()]] || [[item_amount()]]</td>
 
</tr></table></center>
 

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
 1 if ( stills_available() > 1 ) {
 2    set_property( "promptAboutCrafting", 0 );
 3    int stills_left = floor( stills_available() / 2 );
 4    create( stills_left, $item[ Mae West ] );
 5    print( `Created {stills_left} Mae West.`, "blue" );
 6    set_property( "promptAboutCrafting", 1 );
 7    put_shop(
 8      mall_price( $item[ Mae West ] ), 
 9      0,
10      item_amount( $item[ Mae West ] ),
11      $item[ Mae West ]
12    );
13 }
 1 const {
 2   create,
 3   itemAmount,
 4   mallPrice,
 5   print,
 6   putShop,
 7   setProperty,
 8   stillsAvailable,
 9 } = require("kolmafia");
10 
11 const MAE_WEST = Item.get("Mae West");
12 if (stillsAvailable() > 1) {
13   setProperty("promptAboutCrafting", "0");
14   let stillsLeft = Math.floor(stillsAvailable() / 2);
15   create(stillsLeft, MAE_WEST);
16   print("Created " + stillsLeft + " Mae West.", "blue");
17   setProperty("promptAboutCrafting", 1);
18   putShop(mallPrice(MAE_WEST), 0, itemAmount(MAE_WEST), MAE_WEST);
19 }

See Also

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