Difference between revisions of "Template:Qualityprice"
Jump to navigation
Jump to search
(Revamp using new helper templates. Plus handles non-numeric input. Spacing tweaks (consistent with other templates). But no more iridium-conflict warning.) |
(Move auto-derived prices/qualities here instead of infosection_price) |
||
Line 3: | Line 3: | ||
// Define letter/symbol used for gold in current language | // Define letter/symbol used for gold in current language | ||
-->{{#arraydefine:$lang_qp_gold|g}}<!-- | -->{{#arraydefine:$lang_qp_gold|g}}<!-- | ||
− | + | // Items that get autofilled by Infobox and therefore need to be autotranslated to fill in link | |
+ | // (other items are tested below, but the tested values should be image names which are same on all sites) | ||
+ | -->{{ParseInputValues|code=qitem|| | ||
+ | , Wine, | ||
+ | , Juice, | ||
+ | , Jelly, | ||
+ | , Pickles, | ||
+ | , Roe, | ||
+ | , Aged Roe, | ||
+ | , Caviar, | ||
+ | }}<!-- | ||
// END of translation | // END of translation | ||
− | -->{{#arraydefine:$ | + | // Get list of qualities. Set from quality/iridium/hide OR override for specific items if {{{auto}}} |
− | // | + | -->{{#arraydefine:$qpqual|{{ParseInputQuality|quality={{#if:{{{quality|}}}|{{{quality}}}|true}}|iridium={{{3|{{{iridium|}}}}}}|hide={{{hide|}}}}}}}<!-- |
− | -->< | + | -->{{#if:{{{auto|}}} |
− | // If | + | | {{#switch:{{lc:{{{1|}}}}} |
− | -->{{#iferror:{{#expr:{{# | + | |wine|pale ale|beer|mead= {{#arraydefine:$qpqual|Normal,Silver,Gold,Iridium}} |
− | + | |juice|jelly|pickles|honey|roe|caviar|aged roe= {{#arraydefine:$qpqual|Normal}} | |
− | + | }}}}<!-- | |
+ | // Don't allow artisan bonus to ever be applied to coffee, oil. Done regardless of {{{auto}}} | ||
+ | -->{{#arraydefine:$qpmult| | ||
+ | {{#switch:{{lc:{{{1|}}}}} | ||
+ | |oil|coffee = 1 | ||
+ | |#default = {{#iferror:{{#expr:{{{prof_mult}}}*1}}|1|{{{prof_mult}}}}}}}}}<!-- | ||
+ | // Set price to {{{2}}} or derive from srcprice if {{{auto}}}, srcprice is valid, and item name is recognized | ||
+ | // (extra complication for roe: allow [color]_roe to be recognized ... but don't confuse with aged roe) | ||
+ | -->{{#arraydefine:$qpprice | ||
+ | |{{#ifexpr:{{#if:{{{auto|}}}|1|0}} and {{#if:{{{srcprice|}}}|1|0}} and {{#iferror:{{#expr:{{{srcprice}}}*1}}|0|1}} | ||
+ | |{{#ifexpr:{{#ifeq:{{lc:{{{1|}}}}}|aged roe|0|1}} and {{#ifeq:{{lc:{{#sub:{{{1|}}}|-3|3}}}}|roe|1|0}} | ||
+ | |{{#expr:30+trunc({{{srcprice}}})/2}}{{#arraydefine:$qpqual|Normal}} | ||
+ | |{{#switch:{{lc:{{{1|}}}}}| | ||
+ | |wine = {{#expr:trunc({{{srcprice}}})*3}} | ||
+ | |juice = {{#expr:trunc({{{srcprice}}})*2.25}} | ||
+ | |jelly | ||
+ | |pickles = {{#expr:trunc({{{srcprice}}})*2 + 50}} | ||
+ | |honey = {{#expr:trunc({{{srcprice}}})*2 + 100}} | ||
+ | |roe = {{#expr:30+trunc({{{srcprice}}})/2}} | ||
+ | |caviar = 500 | ||
+ | |aged roe = {{#expr:2*trunc(30+trunc({{{srcprice}}})/2)}} | ||
+ | |pale ale = 300 | ||
+ | |beer = 200 | ||
+ | |mead = 200 | ||
+ | |#default = {{{2|0}}} | ||
+ | }}}} | ||
+ | |{{{2|0}}} | ||
+ | }}}}{{#arraydefine:$qplink|{{#if:{{{link|}}}|{{{link}}}|{{ParseInputValues|code=qitem|{{{1|}}}|translate=true}}}}}}<!-- | ||
+ | // If $qpprice is a text value (non-numeric) display it and quit; set sortkey=0 so it doesn't mess up table | ||
+ | -->{{#iferror:{{#expr:{{#arrayprint:$qpprice}}>0}} | ||
+ | |<span class="sortkey" style="display:none;">0</span>''{{{2|}}}''<!-- | ||
+ | // Display sort key and start table | ||
+ | --> |<span class="sortkey" style="display:none;">{{#expr:trunc(({{#arrayprint:$qpmult}})*trunc({{#arrayprint:$qpprice}}))}}</span> | ||
+ | {{{!}} class="no-wrap" style="border-spacing: 0;"<!-- | ||
// Loop through each requested quality. Display icon using Quality template and calculate/display price | // Loop through each requested quality. Display icon using Quality template and calculate/display price | ||
− | -->{{#arrayprint:$ | + | -->{{#arrayprint:$qpqual||@qual@|<nowiki/> |
{{!}}- | {{!}}- | ||
− | {{!}} {{Quality|{{{1|}}}|@qual@| size={{{size| | + | {{!}} {{Quality|{{{1|}}}|@qual@| size={{#if:{{{size|}}}|{{{size}}}|24}} |link={{#arrayprint:$qplink}} |alt={{#if:{{{alt|}}}|{{{alt}}}|{{#if:{{#arrayprint:$qplink}}|{{#arrayprint:$qplink}}|{{{1|}}}}}}}}} |
− | {{!}} {{#expr: | + | {{!}} {{formatnum:{{#expr: |
− | trunc( {{ | + | trunc( ({{#arrayprint:$qpmult}}) * |
trunc ( {{#switch:@qual@|Silver=1.25|Gold=1.5|Iridium=2|Normal|#default=1}} * | trunc ( {{#switch:@qual@|Silver=1.25|Gold=1.5|Iridium=2|Normal|#default=1}} * | ||
− | trunc({{# | + | trunc({{#arrayprint:$qpprice}}) ) ) |
− | }}{{#arrayprint:$lang_qp_gold}} | + | }}}}{{#arrayprint:$lang_qp_gold}} |
}} | }} | ||
{{!}}}<!-- | {{!}}}<!-- | ||
-->}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/> | -->}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/> | ||
{{{{FULLPAGENAME}}/doc}} }}</noinclude> | {{{{FULLPAGENAME}}/doc}} }}</noinclude> |
Revision as of 16:47, 10 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 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}}
|
Template:ParseInputValues
| ||
{{Qualityprice|Parsnip|35|pm=1.1}}
|
Template:ParseInputValues
| ||
{{Qualityprice|Ginger|60}}
|
Template:ParseInputValues
| ||
{{Qualityprice|Goat Cheese|400|hide=normal,silver}}
|
Template:ParseInputValues
| ||
{{Qualityprice|Large Goat Milk FR|345}}
|
Template:ParseInputValues
| ||
{{Qualityprice|Juice|260}} (The base sell price of Red Cabbage is 260, and the base sell price of Red Cabbage Juice is 585) |
Template:ParseInputValues
| ||
{{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) |
Template:ParseInputValues
| ||
{{Qualityprice|Honey|30}} (The base sell price of a Tulip is 30, and the base sell price of Tulip Honey is 160) |
Template:ParseInputValues
|