Actions

Template

Difference between revisions of "MapPrice"

From P6 Spheres

Line 19: Line 19:
  
 
-->{{#if:{{#phptag: if(is_numeric($argv[1])) echo true;}}<!--
 
-->{{#if:{{#phptag: if(is_numeric($argv[1])) echo true;}}<!--
 
+
  -->|{{#ifexpr:{{{1|}}} = 0.0<!--
--><!--{{#expr: floor({{{1|}}})}}
+
    -->|—<!--
  0  -->|{{#ifexpr:{{#expr:{{{1|}}} = 0.0}}|—<!--
+
    -->|{{#vardefine:GP|{{#expr: floor({{{1|}}})}}}}<!--
     GP -->|{{#ifexpr:{{#expr:{{{1|}}} >= 1.0}}|{{#number_format:{{{1|}}}|0|.|,}} gp<!--
+
    -->{{#vardefine:SP|{{#expr: floor(({{{1|}}} - {{#var:GP}}) * 10)}}}}<!--
     SP  -->|{{#ifexpr:{{#expr:{{{1|}}} >= 0.1}}|{{#expr: {{{1|}}} * 10}} sp<!--
+
     -->{{#vardefine:CP|{{#expr: floor(({{{1|}}} - {{#var:GP}} - {{#var:SP}}/10) * 100)}}}}<!--
    CP     -->|{{#expr: {{{1|}}} * 100}} cp<!--
+
    -->{{#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}}<!--
    -->|{{{1|}}}<!--
+
    -->{{IfAnd|{{#var:GP}}|{{#var:SP}}|, <wbr>}}<!--
 +
    -->{{#if:{{#var:SP}}|{{#var:SP}} sp}}<!--
 +
    -->{{IfAnd|{{#var:SP}}|{{#var:CP}}|, <wbr>}}<!--
 +
    -->{{#if:{{#var:CP}}|{{#var:CP}} cp}}<!--
 
   -->}}<!--
 
   -->}}<!--
--></includeonly>
+
  -->|{{{1|}}}<!--
 +
-->}}</includeonly>

Revision as of 23:26, 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.33}}: 3 gp, 3 sp, 3 cp