Actions

Template

Difference between revisions of "MapPrice"

From P6 Spheres

(Created page with "<noinclude>Accepts Float. Returns String where float has been converted to a price: Example: <nowiki>{{MapPrice|0.03}}</nowiki>: {{MapPrice|0.03}} Example: <nowiki>{{MapPri...")
 
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
Returns String where float has been converted to a price:
 
Returns String where float has been converted to a price:
 +
 +
Example: <nowiki>{{MapPrice|free}}</nowiki>: {{MapPrice|free}}
 +
 +
Example: <nowiki>{{MapPrice|0.0}}</nowiki>: {{MapPrice|0.0}}
  
 
Example: <nowiki>{{MapPrice|0.03}}</nowiki>: {{MapPrice|0.03}}
 
Example: <nowiki>{{MapPrice|0.03}}</nowiki>: {{MapPrice|0.03}}
Line 10: Line 14:
  
 
Example: <nowiki>{{MapPrice|2500.0}}</nowiki>: {{MapPrice|2500.0}}
 
Example: <nowiki>{{MapPrice|2500.0}}</nowiki>: {{MapPrice|2500.0}}
 +
 +
Example: <nowiki>{{MapPrice|3.3}}</nowiki>: {{MapPrice|3.3}}
 +
 +
Example: <nowiki>{{MapPrice|3.03}}</nowiki>: {{MapPrice|3.03}}
 +
 +
Example: <nowiki>{{MapPrice|3.33}}</nowiki>: {{MapPrice|3.33}}
 
</noinclude><includeonly><!--
 
</noinclude><includeonly><!--
  
GP -->{{#ifexpr:{{#expr:{{{1|}}} >= 1.0}}|{{#number_format:{{{1|}}}|0|.|,}} gp<!--
+
-->{{#if:{{#phptag: if(is_numeric($argv[1])) echo true;}}<!--
SP  -->|{{#ifexpr:{{#expr:{{{1|}}} >= 0.1}}|{{#expr: {{{1|}}} * 10}} sp<!--
+
  -->|{{#ifexpr:{{{1|}}} = 0.0<!--
CP     -->|{{#expr: {{{1|}}} * 100}} cp<!--
+
    -->|—<!--
    -->}}<!--
+
    -->|{{#vardefine:GP|{{#expr: floor({{{1|}}})}}}}<!--
  -->}}<!--
+
    -->{{#vardefine:SP|{{#expr: floor({{{1|}}} * 10 - {{#var:GP}} * 10)}}}}<!--
 
+
    -->{{#vardefine:CP|{{#expr: floor({{{1|}}} * 100 - {{#var:GP}} * 100 - {{#var:SP}} * 10)}}}}<!--
--></includeonly>
+
    -->{{#vardefine:GP|{{#ifeq:{{#var:GP}}|0||{{#var:GP}}}}}}<!--
 +
    -->{{#vardefine:SP|{{#ifeq:{{#var:SP}}|0||{{#var:SP}}}}}}<!--
 +
    -->{{#vardefine:CP|{{#ifeq:{{#var:CP}}|0||{{#var:CP}}}}}}<!--
 +
    -->{{#if:{{#var:GP}}|{{#number_format:{{#var:GP}}|0|.|,}} gp}}<!--
 +
    -->{{IfAnd|{{#var:GP}}|{{#var:SP}}|,&#32;}}<!--
 +
    -->{{#if:{{#var:SP}}|{{#var:SP}} sp}}<!--
 +
     -->{{IfAnd|{{#var:SP}}|{{#var:CP}}|,&#32;}}<!--
 +
    -->{{#if:{{#var:CP}}|{{#var:CP}} cp}}<!--
 +
  -->}}<!--
 +
  -->|{{{1|}}}<!--
 +
-->}}</includeonly>

Latest revision as of 23:38, 22 March 2020

Accepts Float.

Returns String where float has been converted to a price:

Example: {{MapPrice|free}}: free

Example: {{MapPrice|0.0}}: —

Example: {{MapPrice|0.03}}: 3 cp

Example: {{MapPrice|0.2}}: 2 sp

Example: {{MapPrice|5.0}}: 5 gp

Example: {{MapPrice|2500.0}}: 2,500 gp

Example: {{MapPrice|3.3}}: 3 gp, 3 sp

Example: {{MapPrice|3.03}}: 3 gp3 cp

Example: {{MapPrice|3.33}}: 3 gp, 3 sp, 3 cp