Template:WeaponsTable.dpl: Difference between revisions

From HorizonXI Wiki
No edit summary
m (updated code in documentation)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><onlyinclude><!--
<includeonly><onlyinclude><!--
-->|[[{{{%PAGE%}}}|{{{%TITLE%}}}]]
-->align=center | {{#ifeq: {{#len:{{{level}}}}} | 1 | &nbsp;{{{level}}} | {{{level}}}}}
|{{#ifeq: {{#len:{{{level}}}}} | 1 | &nbsp;{{{level}}} | {{{level}}}}}
|align=center | {{{damage}}}
|{{{damage}}}
|align=center | {{{delay}}}
|{{{delay}}}
|align=center | {{Weapon Calculation|dps|{{{damage}}}|{{{delay}}}|type={{{weapon type}}}|}}
|{{Weapon Calculation|dps|{{{damage}}}|{{{delay}}}|type={{{weapon type}}}|}}
|align=center | {{#if: {{{jobs|}}}|{{trim|<!--
|{{#if: {{{jobs|}}}|{{trim|<!--
-->{{#replace:<!--
-->{{#replace:<!--
-->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!--
-->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!--
Line 24: Line 23:
See [[:Template:ArmorTable.dpl]] for the analoguous table for armor.  
See [[:Template:ArmorTable.dpl]] for the analoguous table for armor.  
===Code===
===Code===
<pre>|{{#ifeq: {{#len:{{{level}}}}} | 1 | &nbsp;{{{level}}} | {{{level}}}}}
<pre>align=center | {{#ifeq: {{#len:{{{level}}}}} | 1 | &nbsp;{{{level}}} | {{{level}}}}}
|{{{damage}}}
|align=center | {{{damage}}}
|{{{delay}}}
|align=center | {{{delay}}}
|{{Weapon Calculation|dps|{{{damage}}}|{{{delay}}}|type={{{weapon type}}}|}}
|align=center | {{Weapon Calculation|dps|{{{damage}}}|{{{delay}}}|type={{{weapon type}}}|}}
|{{#if: {{{jobs|}}}|{{trim|<!--
|align=center | {{#if: {{{jobs|}}}|{{trim|<!--
-->{{#replace:<!--
-->{{#replace:<!--
-->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!--
-->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!--
Line 48: Line 47:
* '''<nowiki>{{{jobs}}}</nowiki>''' and '''<nowiki>{{{stats}}}</nowiki>''' needed some extra work: jobs are usually manually put into new lines by using the html < br> or < br/>. Each of those get replaced with a whitespace (the < nowiki/> < nowiki/>) and in the end, the <nowiki>{{trim}}</nowiki> template will remove all excessive whitespace.  
* '''<nowiki>{{{jobs}}}</nowiki>''' and '''<nowiki>{{{stats}}}</nowiki>''' needed some extra work: jobs are usually manually put into new lines by using the html < br> or < br/>. Each of those get replaced with a whitespace (the < nowiki/> < nowiki/>) and in the end, the <nowiki>{{trim}}</nowiki> template will remove all excessive whitespace.  
** Fallback if no <nowiki>{{{jobs}}}</nowiki> is given is to display "All Jobs"
** Fallback if no <nowiki>{{{jobs}}}</nowiki> is given is to display "All Jobs"
===Example from WeaponsTable===
{{WeaponsTable|title1=Blessed Hammer}}

Latest revision as of 19:19, 17 September 2023

Documentation

This is a phantom template for a dpl3 call in Template:WeaponsTable which takes arguments from Template:Item Statistics.

The basic idea is that Template:WeaponsTable will display information based on parameters of Template:Item Statistics. This phantom template takes the arguments from Template:Item Statistics, manipulates them and then produces an output with | as separator because the output is intended to be used as a row in a table. Template:WeaponsTable generates this table.

See Template:ArmorTable.dpl for the analoguous table for armor.

Code

align=center | {{#ifeq: {{#len:{{{level}}}}} | 1 |  {{{level}}} | {{{level}}}}}
|align=center | {{{damage}}}
|align=center | {{{delay}}}
|align=center | {{Weapon Calculation|dps|{{{damage}}}|{{{delay}}}|type={{{weapon type}}}|}}
|align=center | {{#if: {{{jobs|}}}|{{trim|<!--
-->{{#replace:<!--
-->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!--
-->|<br/>|<nowiki/> <nowiki/>}}<!--
-->}}|All Jobs}}
|{{trim|<!--
-->{{#replace:<!--
-->{{#replace:{{{stats}}}|<br>|<nowiki/> <nowiki/>}}<!--
-->|<br/>|<nowiki/> <nowiki/>}}<!--
-->}}

Code Explanation

(There are a lot of html comment < !-- and -- > in there. Their only purpose is to structure the code and they have no effect on the output)

  • The {{{level}}} line. If returning just {{{level}}}, the sorting of the table by that column would be wrong. dpl can only sort alphabetically and not numerically, therefore, single digit numbers get mixed up with multidigit numbers since it sorts by first digit, then by second digit and so on. To circumvent this, we check if {{{level}}} is a one digit number. If it is, insert a blank space html code (& nbsp;). Since html is rendered after mediawiki templates, the & is considered the first digit and will thereby cause all single digit numbers to be sorted above all two digit numbers.
  • {{{damage}}} and {{{delay}}} are simply returned as is. There is no weapon without these.
  • dps is calculated using the template {{Weapon Calculation}}
  • {{{jobs}}} and {{{stats}}} needed some extra work: jobs are usually manually put into new lines by using the html < br> or < br/>. Each of those get replaced with a whitespace (the < nowiki/> < nowiki/>) and in the end, the {{trim}} template will remove all excessive whitespace.
    • Fallback if no {{{jobs}}} is given is to display "All Jobs"

Example from WeaponsTable

Name Level Damage Delay DPS Jobs Stats Horizon Changes HorizonXI specific changes
Blessed Hammer 40 31 324 5.74 WHM MP +10 MND +2 MP recovered while healing +3