Difference between revisions of "Template:Qualityprice"

From Stardew Valley Wiki
Jump to navigation Jump to search
(Move auto-derived prices/qualities here instead of infosection_price)
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<includeonly><!--
+
<includeonly>{{#ifeq:{{lc:{{{dsv|}}}}}|false||<span style="display: none;">data-sort-value="{{#invoke:Calcsellprice|csp
 
+
|im = {{{1|}}} <!-- image -->
// Define letter/symbol used for gold in current language
+
|bp = {{#expr:{{{2|0}}}}} <!-- base price -->
-->{{#arraydefine:$lang_qp_gold|g}}<!--
+
|q  = 0 <!-- quality = normal -->
// Items that get autofilled by Infobox and therefore need to be autotranslated to fill in link
+
|pm = {{{pm|1}}} <!-- profession multiplier -->
// (other items are tested below, but the tested values should be image names which are same on all sites)
+
|fm = false <!-- format number? -->
-->{{ParseInputValues|code=qitem||
+
}}"</span>}}<!--
, Wine,
+
--><table class="no-wrap" style="text-align: left; margin: 0; padding: 0; border-spacing: 0; border: 0;">
, Juice,
+
{{#if:{{#pos:{{{hide|}}}|normal}}||
, Jelly,
+
{{#switch:{{{quality|all}}}
, Pickles,
+
  |normal|base|all|0 =
, Roe,
+
<tr>
, Aged Roe,
+
<td>{{Overlayimg|{{{1|Blank icon}}}|width=24|center=true|type=star|quality=0}}</td>
, Caviar,
+
<td>{{#iferror:{{#expr:{{{2|}}}}}|{{{2|}}}|{{#invoke:Calcsellprice|csp
}}<!--
+
|im = {{{1|}}} <!-- image -->
// END of translation
+
|bp = {{#expr:{{{2|0}}}}} <!-- base price -->
 
+
|q  = 0 <!-- normal quality -->
// Get list of qualities. Set from quality/iridium/hide OR override for specific items if {{{auto}}}
+
|pm = {{{pm|1}}} <!-- profession multiplier -->
-->{{#arraydefine:$qpqual|{{ParseInputQuality|quality={{#if:{{{quality|}}}|{{{quality}}}|true}}|iridium={{{3|{{{iridium|}}}}}}|hide={{{hide|}}}}}}}<!--
+
|fm = true <!-- format number? -->
-->{{#if:{{{auto|}}}
+
}} }}
      | {{#switch:{{lc:{{{1|}}}}}
+
</td>
          |wine|pale ale|beer|mead= {{#arraydefine:$qpqual|Normal,Silver,Gold,Iridium}}
+
</tr>
          |juice|jelly|pickles|honey|roe|caviar|aged roe= {{#arraydefine:$qpqual|Normal}}
+
}} }}{{#if:{{#pos:{{{hide|}}}|silver}}||{{#switch:{{lc:{{{1|}}}}}
  }}}}<!--
+
|juice|pickles|jelly|honey|oil|cave carrot|green tea|tea leaves|ginger|qi fruit=
// Don't allow artisan bonus to ever be applied to coffee, oil.  Done regardless of {{{auto}}}
+
|#default={{#switch:{{{quality|all}}}
-->{{#arraydefine:$qpmult|
+
|silver|all|1 =
      {{#switch:{{lc:{{{1|}}}}}
+
<tr>
        |oil|coffee = 1
+
<td>{{Overlayimg|{{{1|Blank icon}}}|width=24|center=true|type=star|quality=1}}</td>
|#default = {{#iferror:{{#expr:{{{prof_mult}}}*1}}|1|{{{prof_mult}}}}}}}}}<!--
+
<td>{{#iferror:{{#expr:{{{2|}}}}}|{{{2|}}}|{{#invoke:Calcsellprice|csp
// Set price to {{{2}}} or derive from srcprice if {{{auto}}}, srcprice is valid, and item name is recognized
+
|im = {{{1|}}} <!-- image -->
// (extra complication for roe: allow [color]_roe to be recognized ... but don't confuse with aged roe)
+
|bp = {{#expr:{{{2|0}}}}} <!-- base price -->
-->{{#arraydefine:$qpprice
+
|q  = 1 <!-- silver quality -->
      |{{#ifexpr:{{#if:{{{auto|}}}|1|0}} and {{#if:{{{srcprice|}}}|1|0}} and {{#iferror:{{#expr:{{{srcprice}}}*1}}|0|1}}
+
|pm = {{{pm|1}}} <!-- profession multiplier -->
        |{{#ifexpr:{{#ifeq:{{lc:{{{1|}}}}}|aged roe|0|1}} and {{#ifeq:{{lc:{{#sub:{{{1|}}}|-3|3}}}}|roe|1|0}}
+
|fm = true <!-- format number? -->
    |{{#expr:30+trunc({{{srcprice}}})/2}}{{#arraydefine:$qpqual|Normal}}
+
}} }}
            |{{#switch:{{lc:{{{1|}}}}}|
+
</td>
              |wine    = {{#expr:trunc({{{srcprice}}})*3}}
+
</tr>
              |juice    = {{#expr:trunc({{{srcprice}}})*2.25}}
+
}} }} }}{{#if:{{#pos:{{{hide|}}}|gold}}||{{#switch:{{lc:{{{1|}}}}}
              |jelly
+
|juice|pickles|jelly|honey|oil|cave carrot|green tea|tea leaves|ginger|qi fruit=
              |pickles  = {{#expr:trunc({{{srcprice}}})*2 + 50}}
+
|#default={{#switch:{{{quality|all}}}
              |honey    = {{#expr:trunc({{{srcprice}}})*2 + 100}}
+
|gold|all|2 =
              |roe      = {{#expr:30+trunc({{{srcprice}}})/2}}
+
<tr>
      |caviar  = 500
+
<td>{{Overlayimg|{{{1|Blank icon}}}|width=24|center=true|type=star|quality=2}}</td>
              |aged roe = {{#expr:2*trunc(30+trunc({{{srcprice}}})/2)}}
+
<td>{{#iferror:{{#expr:{{{2|}}}}}|{{{2|}}}|{{#invoke:Calcsellprice|csp
      |pale ale = 300
+
|im = {{{1|}}} <!-- image -->
      |beer    = 200
+
|bp = {{#expr:{{{2|0}}}}} <!-- base price -->
      |mead    = 200
+
|= 2 <!-- gold quality -->
              |#default = {{{2|0}}}
+
|pm = {{{pm|1}}} <!-- profession multiplier -->
          }}}}
+
|fm = true <!-- format number? -->
        |{{{2|0}}}
+
}} }}
  }}}}{{#arraydefine:$qplink|{{#if:{{{link|}}}|{{{link}}}|{{ParseInputValues|code=qitem|{{{1|}}}|translate=true}}}}}}<!--
+
</td>
// If $qpprice is a text value (non-numeric) display it and quit; set sortkey=0 so it doesn't mess up table
+
</tr>
-->{{#iferror:{{#expr:{{#arrayprint:$qpprice}}>0}}
+
}} }} }}{{#if:{{#pos:{{{hide|}}}|iridium}}||{{#switch:{{lc:{{{1|}}}}}
      |<span class="sortkey" style="display:none;">0</span>''{{{2|}}}''<!--
+
|juice|pickles|jelly|honey|oil|cave carrot|green tea|tea leaves|ginger|qi fruit=
// Display sort key and start table
+
|#default={{#switch:{{{quality|all}}}
-->   |<span class="sortkey" style="display:none;">{{#expr:trunc(({{#arrayprint:$qpmult}})*trunc({{#arrayprint:$qpprice}}))}}</span>
+
|iridium|all|4 =
{{{!}} class="no-wrap" style="border-spacing: 0;"<!--
+
<tr>
 
+
<td>{{Overlayimg|{{{1|Blank icon}}}|width=24|center=true|type=star|quality=4}}</td>
// Loop through each requested quality.  Display icon using Quality template and calculate/display price
+
<td>{{#iferror:{{#expr:{{{2|}}}}}|{{{2|}}}|{{#invoke:Calcsellprice|csp
-->{{#arrayprint:$qpqual||@qual@|<nowiki/>
+
|im = {{{1|}}} <!-- image -->
{{!}}-
+
|bp = {{#expr:{{{2|0}}}}} <!-- base price -->
{{!}} {{Quality|{{{1|}}}|@qual@| size={{#if:{{{size|}}}|{{{size}}}|24}} |link={{#arrayprint:$qplink}} |alt={{#if:{{{alt|}}}|{{{alt}}}|{{#if:{{#arrayprint:$qplink}}|{{#arrayprint:$qplink}}|{{{1|}}}}}}}}}
+
|q  = 4 <!-- iridium quality -->
{{!}} {{formatnum:{{#expr:
+
|pm = {{{pm|1}}} <!-- profession multiplier -->
          trunc( ({{#arrayprint:$qpmult}}) *
+
|fm = true
            trunc ( {{#switch:@qual@|Silver=1.25|Gold=1.5|Iridium=2|Normal|#default=1}} *
+
}} }}
                trunc({{#arrayprint:$qpprice}}) ) )
+
</td>
      }}}}{{#arrayprint:$lang_qp_gold}}
+
</tr>
}}
+
}} }} }}</table></includeonly><noinclude>{{{{FULLPAGENAME}}/doc}}</noinclude>
{{!}}}<!--
 
-->}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/>
 
{{{{FULLPAGENAME}}/doc}} }}</noinclude>
 

Latest revision as of 20:55, 18 March 2023

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 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}} data-sort-value="250"
Melon.png
250g
Melon.png
Silver Quality Icon.png
312g
Melon.png
Gold Quality Icon.png
375g
Melon.png
Iridium Quality Icon.png
500g
{{Qualityprice|Parsnip|35|pm=1.1}} data-sort-value="38"
Parsnip.png
38g
Parsnip.png
Silver Quality Icon.png
47g
Parsnip.png
Gold Quality Icon.png
57g
Parsnip.png
Iridium Quality Icon.png
77g
{{Qualityprice|Ginger|60}} data-sort-value="60"
Ginger.png
60g
{{Qualityprice|Goat Cheese|400|hide=normal,silver}} data-sort-value="400"
Goat Cheese.png
Gold Quality Icon.png
600g
Goat Cheese.png
Iridium Quality Icon.png
800g
{{Qualityprice|Large Goat Milk FR|345}} data-sort-value="345"
Large Goat Milk FR.png
345g
Large Goat Milk FR.png
Silver Quality Icon.png
431g
Large Goat Milk FR.png
Gold Quality Icon.png
517g
Large Goat Milk FR.png
Iridium Quality Icon.png
690g
{{Qualityprice|Juice|260}}
(The base sell price of Red Cabbage is 260,
and the base sell price of Red Cabbage Juice is 585)
data-sort-value="585"
Juice.png
585g
{{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)
data-sort-value="3150"
Wine.png
3,150g
Wine.png
Silver Quality Icon.png
3,936g
Wine.png
Gold Quality Icon.png
4,725g
Wine.png
Iridium Quality Icon.png
6,300g
{{Qualityprice|Honey|30}}
(The base sell price of a Tulip is 30,
and the base sell price of Tulip Honey is 160)
data-sort-value="160"
Honey.png
160g