Template:StatTable: Difference between revisions

From I-Pixelmon
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{| class="pkmn-stats"
<templatestyles src="Template:StatTable/styles.css" />
! scope="row" class="hp" | HP:
 
| {{{HP|N/A}}}
<!--
| style="width:{{#expr: {{{HP|0}}} > 255 ? 255 : {{{HP|0}}} }}px" |
  Parameters:  HP Attack Defense SpAtk SpDef Speed
              Total (optional – will be auto-calculated if omitted)
-->
 
{{#vardefine:hp   | {{{HP   |0}}} }}
{{#vardefine:atk  | {{{Attack |0}}} }}
{{#vardefine:def  | {{{Defense|0}}} }}
{{#vardefine:spa  | {{{SpAtk  |0}}} }}
{{#vardefine:spd  | {{{SpDef  |0}}} }}
{{#vardefine:spe | {{{Speed |0}}} }}
 
{{#vardefine:tot
  | {{#if:{{{Total|}}} | {{{Total}}}
    | {{#expr:{{#var:hp}}+{{#var:atk}}+{{#var:def}}+{{#var:spa}}+{{#var:spd}}+{{#var:spe}} }}
  }} }}
 
{| class="pkmn-stats" style="border:1px solid #555; background:#dcdce9; border-radius:6px; padding:2px;"
|-
|-
! scope="row" class="atk" | Attack:
 
| {{{Attack|N/A}}}
! colspan="3" style="display:none;" | <!-- invisible header keeps table validators happy -->
| style="width:{{#expr: {{{Attack|0}}} > 255 ? 255 : {{{Attack|0}}} }}px" |
 
|-
<!-- 6 stat rows -->
! scope="row" class="def" | Defense:
{{#lsth:StatTable |row|hp  |HP      |HP          }}
| {{{Defense|N/A}}}
{{#lsth:StatTable |row|atk |Attack |Attack      }}
| style="width:{{#expr: {{{Defense|0}}} > 255 ? 255 : {{{Defense|0}}} }}px" |
{{#lsth:StatTable |row|def |Defense |Defense     }}
|-
{{#lsth:StatTable |row|spa |Sp.&nbsp;Atk |SpAtk   }}
! scope="row" class="spa" | Sp.&nbsp;Atk:
{{#lsth:StatTable |row|spd |Sp.&nbsp;Def |SpDef   }}
| {{{SpAtk|N/A}}}
{{#lsth:StatTable |row|spe |Speed  |Speed        }}
| style="width:{{#expr: {{{SpAtk|0}}} > 255 ? 255 : {{{SpAtk|0}}} }}px" |
 
|-
<!-- total -->
! scope="row" class="spd" | Sp.&nbsp;Def:
| {{{SpDef|N/A}}}
| style="width:{{#expr: {{{SpDef|0}}} > 255 ? 255 : {{{SpDef|0}}} }}px" |
|-
|-
! scope="row" class="spe" | Speed:
| class="total-row" colspan="3" | Total: {{#var:tot}}
| {{{Speed|N/A}}}
| style="width:{{#expr: {{{Speed|0}}} > 255 ? 255 : {{{Speed|0}}} }}px" |
|-
! class="total" | Total:
| {{#if:{{{Total|}}}|{{{Total}}}|{{#expr:
      ({{{HP|0}}})  +
      ({{{Attack|0}}}) +
      ({{{Defense|0}}}) +
      ({{{SpAtk|0}}}) +
      ({{{SpDef|0}}}) +
      ({{{Speed|0}}})
}} }}
|}
|}


<noinclude>
<noinclude>
Adds a coloured Bulbapedia-style base-stat chart.
==== Helper for the six rows ====
 
<onlyinclude>{{#if:{{{row|}}}|
**Parameters**
<!-- invoked through {{#lsth:StatTable |row|class|Label|Param}} -->
 
|-
* `HP Attack Defense SpAtk SpDef Speed` – numbers (or omit ⇒ “N/A”) 
| class="stat-row {{{1}}}" |
* `Total` (optional) – total shown; if omitted it’s auto-calculated
! class="stat-lbl" | {{{2}}}:
| class="stat-bar {{{1}}}" |
  <span class="stat-fill"
        style="width: {{#expr: min( ({{{3}}}), 255 ) * 100 / 255 round 2 }}%"></span>
| class="stat-val" | {{{3}}}
}}</onlyinclude>
</noinclude>
</noinclude>

Revision as of 03:46, 19 May 2025


{{#vardefine:hp | 0 }} {{#vardefine:atk | 0 }} {{#vardefine:def | 0 }} {{#vardefine:spa | 0 }} {{#vardefine:spd | 0 }} {{#vardefine:spe | 0 }}

{{#vardefine:tot

 | Expression error: Unrecognized punctuation character "{". }}

{{#lsth:StatTable |row|hp |HP |HP }} {{#lsth:StatTable |row|atk |Attack |Attack }} {{#lsth:StatTable |row|def |Defense |Defense }} {{#lsth:StatTable |row|spa |Sp. Atk |SpAtk }} {{#lsth:StatTable |row|spd |Sp. Def |SpDef }} {{#lsth:StatTable |row|spe |Speed |Speed }}

Total: {{#var:tot}}


Helper for the six rows

-