Jump to content

Template:Qualityprice: Difference between revisions

From Stardew Valley Wiki
imported>Nebulous Maestress
Add prof_mult parameter and truncations matching game code. Remove incorrect #len in sortkey
imported>Nebulous Maestress
Revamp using new helper templates. Plus handles non-numeric input. Spacing tweaks (consistent with other templates). But no more iridium-conflict warning.
Line 1: Line 1:
<includeonly>{|
<includeonly><!--
|<span class="sortkey" style="display:none;">{{#expr:trunc(trunc({{{2|0}}})*{{{prof_mult|1}}})}}</span>{{#if:{{#pos:{{{hide|}}}|normal}}
 
|
// Define letter/symbol used for gold in current language
|<nowiki />
-->{{#arraydefine:$lang_qp_gold|g}}<!--
 
// END of translation
 
-->{{#arraydefine:$qpqualities|{{ParseInputQuality|quality={{#if:{{{quality|}}}|{{{quality}}}|true}}|iridium={{{3|{{{iridium|}}}}}}|hide={{{hide|}}}}}}}<!--
// Create span containing sort key
--><span class="sortkey" style="display:none;">{{#expr:trunc(trunc({{#if:{{{2|}}}|{{{2}}}|0}})*{{{prof_mult|1}}})}}</span><!--
// If base_price is a text value (non-numeric) display it and quit
-->{{#iferror:{{#expr:{{#if:{{{2|}}}|{{{2}}}|0}}>0}}
      |{{{2|}}}
      |{{{!}} class="no-wrap" style="border-spacing: 0;"<!--
 
// Loop through each requested quality.  Display icon using Quality template and calculate/display price
-->{{#arrayprint:$qpqualities||@qual@|<nowiki/>
{{!}}-
{{!}}-
{{!}}{{Quality|{{{1|}}}||{{#switch: {{{size|}}} |16=16|32=32|48=48|64=64|#default=24}}}}
{{!}} {{Quality|{{{1|}}}|@qual@| size={{{size|24}}} |link={{{link|}}} |alt={{{alt|{{{link|{{{1|}}}}}}}}}}}
{{!}}{{#expr:trunc(trunc({{{2|0}}})*{{{prof_mult|1}}})}}g}}{{#if: {{#pos:{{{hide|}}}|silver}}
{{!}} {{#expr:
|
          trunc( {{{prof_mult|1}}} *
|<nowiki />
            trunc ( {{#switch:@qual@|Silver=1.25|Gold=1.5|Iridium=2|Normal|#default=1}} *
{{!}}-
                trunc({{#if:{{{2|}}}|{{{2}}}|0}}) ) )
{{!}}{{Quality|{{{1|}}}|silver|{{#switch: {{{size|}}} |16=16|32=32|48=48|64=64|#default=24}}}}
      }}{{#arrayprint:$lang_qp_gold}}
{{!}}{{#expr:trunc(trunc(trunc({{{2|0}}})*1.25)*{{{prof_mult|1}}})}}g}}{{#if: {{#pos:{{{hide|}}}|gold}}
|
|<nowiki />
{{!}}-
{{!}}{{Quality|{{{1|}}}|gold|{{#switch: {{{size|}}} |16=16|32=32|48=48|64=64|#default=24}}}}
{{!}}{{#expr:trunc(trunc(trunc({{{2|0}}})*1.50)*{{{prof_mult|1}}})}}g}}{{#if: {{{3|}}}
| {{#if: {{#pos:{{{hide|}}}|iridium}}
  |<strong class="error">Qualityprice: Cannot show and hide iridium.</strong>
  |<nowiki />
  {{!}}-
  {{!}}{{Quality|{{{1}}}|iridium|{{#switch: {{{size|}}} |16=16|32=32|48=48|64=64|#default=24}}}}
  {{!}}{{#expr:trunc(trunc(trunc({{{2|0}}})*2)*{{{prof_mult|1}}})}}g
  }}
}}
}}
|}</includeonly><noinclude>{{{{FULLPAGENAME}}/doc}}</noinclude>
{{!}}}<!--
-->}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/>
{{{{FULLPAGENAME}}/doc}} }}</noinclude>

Revision as of 00:04, 4 September 2020

Description

This template displays prices for items of specified qualities, formatted appropriately for the language where they appear. The image of the item is included (with any quality stars) instead of the gold icon. The size of the image is always 24px.

Parameters

Parameter Notes
First (unnamed) parameter Name of image (minus ".png")
Second (unnamed) parameter Normal/base sell price of item (can be found in ObjectInformation.xnb)
or
Normal/base sell price of item used to make Artisan Good (see examples below)
Note: also accepts non-numbers such as "3x base fruit price" without throwing an error
quality Single quality to display.
Defaults to all qualities (normal, silver, gold, iridium) if omitted.
Items that exist in normal quality only do not have to specify quality=normal (i.e., Cave Carrot, Ginger, Green Tea, Honey, Jelly, Juice, Oil, Pickles, Qi Fruit, and Tea Leaves)
Note: Other items may be added in the future. In the meantime, specifying quality=normal or quality=0 will work.
hide Qualities to hide
(e.g., hide=silver,gold)
pm Profession modifier
Tiller gives a 10% bonus, so specify pm=1.1
Angler gives a 50% bonus, so specify pm=1.5
etc.
dsv data-sort-value
Set to false if the quality price(s) are displayed in a non-sortable structure (like an infobox)
Default value is true (the entire parameter can be omitted if a data-sort-value is desired).

Examples

Template Call Result
{{Qualityprice|Melon|250}}
250g
{{Qualityprice|Parsnip|35|pm=1.1}}
35g
{{Qualityprice|Ginger|60}}
60g
{{Qualityprice|Goat Cheese|400|hide=normal,silver}}
400g
{{Qualityprice|Large Goat Milk FR|345}}
345g
{{Qualityprice|Juice|260}}
(The base sell price of Red Cabbage is 260,
and the base sell price of Red Cabbage Juice is 585)
260g
{{Qualityprice|Purple Juice|260|quality=0}}
(Must specify quality=normal or
quality=0 if using a colored sprite)
260g
{{Qualityprice|Wine|750|pm=1.4}}
(The base sell price of Starfruit is 750,
and the Artisan base sell price of Starfruit Wine is 3,150)
750g
{{Qualityprice|Honey|30}}
(The base sell price of a Tulip is 30,
and the base sell price of Tulip Honey is 160)
30g