Difference between revisions of "Template:Qualityprice/doc"

From Stardew Valley Wiki
Jump to navigation Jump to search
(Document prof_mult parameter)
(Complete params, formatting)
Line 1: Line 1:
==Description==
+
This template displays a table of the sell prices of an item for each requested item.  Each sell price is shown with the image icon and a superimposed quality star (see [[Template:Quality]]). It intentionally does not show the money icon as to not clutter the page with multiple icons.
This template is used to provide a template that takes the base cost of each item, calculates the silver and gold quality costs, and displays it in a table. The cost calculation is silver=(basecost)*1.25 and gold=(basecost)*1.50. It always truncates any fraction (rounds down).
 
  
 
In order for the values to be calculated correctly, the input value should always be the item base cost.  If other factors should be included (e.g., professions that increase the price), those factors should be specified using the <tt>prof_mult</tt> parameter.
 
In order for the values to be calculated correctly, the input value should always be the item base cost.  If other factors should be included (e.g., professions that increase the price), those factors should be specified using the <tt>prof_mult</tt> parameter.
  
Note that this intentionally doesn't show the money icon as to not clutter the page with multiple icons.
+
Additionally, a sortkey is provided allowing correct sorting in tables where a column contains multiple instances of this template.
  
Additionally, a sortkey is provided allowing correct sorting in tables where a column contains multiple instances of this template.
+
==Notes==
 +
The sell price is calculated by:
 +
* Rounding down (truncating any fraction) on the input base cost (for the sake of derived base costs such as fruit-specific wine)
 +
* Applying the quality adjustment to the price: multiplying by 1.25 for Silver, 1.5 for Gold, or 2 for Iridium
 +
* Rounding down the quality-adjusted price
 +
* Applying any profession-related bonuses (from the <tt>prof_mult</tt> parameter)
 +
* Rounding down to yield the final displayed sell price.
 +
This sequence of operations (and the specific order in which they are done) replicates the calculations done by the game code in <tt>Object::sellToStorePrice</tt>. Changing the order of operations and/or omitting any of the rounding-down steps will cause changes in the calculated values for some items and result in discrepancies between the wiki's displayed values and the actual in-game values.
  
 
==Usage==
 
==Usage==
This template can be used by entering the following onto a relevant page.
+
===Syntax===
 +
Basic usage:
 +
<nowiki>{{</nowiki>[[Template:Qualityprice|Qualityprice]] |''item_name''| ''base_cost'' <nowiki>}}</nowiki>
 +
 
 +
Complete argument list:
 +
 
 +
<nowiki>{{</nowiki>[[Template:Qualityprice|Qualityprice]] |''item_name''| ''base_cost'' | prof_mult=''mult'' | quality=''values''
 +
                | iridium=true | hide=''values'' | size=''px'' | link=''link''| alt=''alt'' <nowiki>}}</nowiki>
 +
 
 +
===Parameters===
 +
There are two unnamed, required parameters, ''item_name'' and ''base_cost''.  All other parameters are named and optional.  Default value for all arguments is empty, unless specified otherwise.
 +
 
 +
See [[Template:ParseInputQuality]] for more information on quality-related parameters.
 +
 
 +
* '''''item_name'''''
 +
** First unnamed parameter, required
 +
** Name of item being displayed. There should be a corresponding image named <tt>File:item_name.png</tt>.
 +
** On non-english wikis this should normally be the '''english''' item_name, unless there's a language-specific image of the item, e.g., <tt>Large_Milk_FR</tt> should be used in French instead of <tt>Large_Milk</tt>.  To provide the translated item name, see <tt>alt</tt>
 +
** Note that there must be no spaces following the item_name -- the "|" symbol must come immediately afterwards, or the template will fail (due to quirks of how mediawiki templates process arguments)
 +
 
 +
* '''''base_cost'''''
 +
** Second unnamed parameter, rquired
 +
** The base cost of the item
 +
 
 +
* '''prof_mult=''mult'''''
 +
** Any other multipliers (e.g., profession price bonuses) that should be included in the calculated price.  Default value is 1
 +
 
 +
* '''quality=''values'''''
 +
** List of quality values to display. Default value is <tt>Normal, Silver, Gold</tt>
 +
** Set quality to true to get <tt>Normal, Silver, Gold</tt>, or
 +
** Set quality to false or Normal to get <tt>Normal</tt>, or
 +
** Set quality to one or more specific quality values
 +
** iridium is disabled by default. Enable by explicitly adding iridium to the listed quality values or by setting <tt>iridium=true</tt>
 +
 
 +
* '''iridium=true'''
 +
** Set iridium to true to display iridium values.
 +
** Also recognizes <tt>iridium=false</tt> as equivalent to <tt>hide=iridium</tt> (although it's easier to just omit the entire iridium parameter)
 +
 
 +
* '''hide=''values'''''
 +
** List of quality values to hide, as a comma-separated list of individual values.
 +
** In case of conflict, hide overrides any other input.
 +
** For backwards compatibility <tt>hide=base</tt> is recognized as equivalent to <nowiki>hide=normal</nowiki>, but this is deprecated.
 +
 
 +
* '''size=''px'''''
 +
** Size of icons in pixels.  Default value is 24
 +
** Only the number should be provided (do not append "px").
 +
 
 +
* '''link=''link'''''
 +
** Name of page (without square brackets) that item icon should link to.  By default empty, meaning clicking on the icon does nothing.
  
<pre>
+
* '''alt=''alt'''''
{{Qualityprice|item name|item base cost}}
+
** Alt text for item icon. Default value is ''link'' (if non-empty) or ''item_name''.
{{Qualityprice|item name|item base cost|iridium quality|hide|size}}
+
** This is not normally directly displayed on the page, but may be used by screen readers or accessibility-aware browsers.
{{Qualityprice|item_name|item base cost|prof_mult=1.25}}
 
</pre>
 
===parameters===
 
; item name: This unnamed parameter accepts an item name.
 
; item base cost: This unnamed parameter accepts the item's base cost.
 
; iridium quality: (optional) If this unnamed parameter exist, iridium quality will be added.
 
; hide: (optional) Any quality listed here will hide that quality. Specifying iridium here and in the third parameter will result in an error.  To hide normal/regular quality, specify "hide=normal".
 
; size: (optional) Size of item image in pixels (16, 32, 48, 64).  Default is 24.
 
; prof_mult: (optional) Any other multipliers (e.g., profession price bonuses) that should be included in the calculated price.
 
  
===Example===
+
===Examples===
 
<pre>
 
<pre>
 
{{Qualityprice|Pumpkin|100}}
 
{{Qualityprice|Pumpkin|100}}
Line 51: Line 96:
  
 
<includeonly>[[Category:Formatting templates]]</includeonly><noinclude>[[Category:Template documentation]]</noinclude>
 
<includeonly>[[Category:Formatting templates]]</includeonly><noinclude>[[Category:Template documentation]]</noinclude>
<includeonly>{{Addlanglinks}}</includeonly>
 

Revision as of 15:14, 5 September 2020

This template displays a table of the sell prices of an item for each requested item. Each sell price is shown with the image icon and a superimposed quality star (see Template:Quality). It intentionally does not show the money icon as to not clutter the page with multiple icons.

In order for the values to be calculated correctly, the input value should always be the item base cost. If other factors should be included (e.g., professions that increase the price), those factors should be specified using the prof_mult parameter.

Additionally, a sortkey is provided allowing correct sorting in tables where a column contains multiple instances of this template.

Notes

The sell price is calculated by:

  • Rounding down (truncating any fraction) on the input base cost (for the sake of derived base costs such as fruit-specific wine)
  • Applying the quality adjustment to the price: multiplying by 1.25 for Silver, 1.5 for Gold, or 2 for Iridium
  • Rounding down the quality-adjusted price
  • Applying any profession-related bonuses (from the prof_mult parameter)
  • Rounding down to yield the final displayed sell price.

This sequence of operations (and the specific order in which they are done) replicates the calculations done by the game code in Object::sellToStorePrice. Changing the order of operations and/or omitting any of the rounding-down steps will cause changes in the calculated values for some items and result in discrepancies between the wiki's displayed values and the actual in-game values.

Usage

Syntax

Basic usage:

{{Qualityprice |item_name| base_cost }}

Complete argument list:

{{Qualityprice |item_name| base_cost | prof_mult=mult | quality=values
               | iridium=true | hide=values | size=px | link=link| alt=alt }}

Parameters

There are two unnamed, required parameters, item_name and base_cost. All other parameters are named and optional. Default value for all arguments is empty, unless specified otherwise.

See Template:ParseInputQuality for more information on quality-related parameters.

  • item_name
    • First unnamed parameter, required
    • Name of item being displayed. There should be a corresponding image named File:item_name.png.
    • On non-english wikis this should normally be the english item_name, unless there's a language-specific image of the item, e.g., Large_Milk_FR should be used in French instead of Large_Milk. To provide the translated item name, see alt
    • Note that there must be no spaces following the item_name -- the "|" symbol must come immediately afterwards, or the template will fail (due to quirks of how mediawiki templates process arguments)
  • base_cost
    • Second unnamed parameter, rquired
    • The base cost of the item
  • prof_mult=mult
    • Any other multipliers (e.g., profession price bonuses) that should be included in the calculated price. Default value is 1
  • quality=values
    • List of quality values to display. Default value is Normal, Silver, Gold
    • Set quality to true to get Normal, Silver, Gold, or
    • Set quality to false or Normal to get Normal, or
    • Set quality to one or more specific quality values
    • iridium is disabled by default. Enable by explicitly adding iridium to the listed quality values or by setting iridium=true
  • iridium=true
    • Set iridium to true to display iridium values.
    • Also recognizes iridium=false as equivalent to hide=iridium (although it's easier to just omit the entire iridium parameter)
  • hide=values
    • List of quality values to hide, as a comma-separated list of individual values.
    • In case of conflict, hide overrides any other input.
    • For backwards compatibility hide=base is recognized as equivalent to hide=normal, but this is deprecated.
  • size=px
    • Size of icons in pixels. Default value is 24
    • Only the number should be provided (do not append "px").
  • link=link
    • Name of page (without square brackets) that item icon should link to. By default empty, meaning clicking on the icon does nothing.
  • alt=alt
    • Alt text for item icon. Default value is link (if non-empty) or item_name.
    • This is not normally directly displayed on the page, but may be used by screen readers or accessibility-aware browsers.

Examples

{{Qualityprice|Pumpkin|100}}

data-sort-value="100"

Pumpkin.png
100g
Pumpkin.png
Silver Quality Icon.png
125g
Pumpkin.png
Gold Quality Icon.png
150g
Pumpkin.png
Iridium Quality Icon.png
200g
{{Qualityprice|Pumpkin|100|prof_mult=1.1}}

data-sort-value="100"

Pumpkin.png
100g
Pumpkin.png
Silver Quality Icon.png
125g
Pumpkin.png
Gold Quality Icon.png
150g
Pumpkin.png
Iridium Quality Icon.png
200g
{{Qualityprice|Leek|60|iridium}}

data-sort-value="60"

Leek.png
60g
Leek.png
Silver Quality Icon.png
75g
Leek.png
Gold Quality Icon.png
90g
Leek.png
Iridium Quality Icon.png
120g
{{Qualityprice|Apple|42|iridium|hide=gold,silver|size=48}}

data-sort-value="42"

Apple.png
42g
Apple.png
Iridium Quality Icon.png
84g
{{Qualityprice|Apple|42|iridium|hide=silver,iridium}}

data-sort-value="42"

Apple.png
42g
Apple.png
Gold Quality Icon.png
63g