Difference between revisions of "Template:Infobox Enemy/style"

From Twinsuniverse
Jump to: navigation, search
m
m (fixed the bulleted single item issue (attempt))
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<includeonly>{{
 
<includeonly>{{
#vardefine: melee | {{#ifeq: {{lc: {{#if:{{{melee|}}}|{{{melee}}}|no}}}} | no |
+
#vardefine: style | {{#var:style|}}{{#ifeq: {{lc:{{#if:   {{{melee|}}}|   {{{melee}}}|no}}}} |no||m}}}}{{
    | {{categorizer|nocat={{{nocat|false}}}
+
#vardefine: style | {{#var:style|}}{{#ifeq: {{lc:{{#if:   {{{ranged|}}}|   {{{ranged}}}|no}}}} |no||r}}}}{{
        |category=Melee enemies
+
#vardefine: style | {{#var:style|}}{{#ifeq: {{lc:{{#if:   {{{magic|}}}|   {{{magic}}}|no}}}} |no||g}}}}{{
        |label=Melee}} }}}}{{
+
#vardefine: style | {{#var:style|}}{{#ifeq: {{lc:{{#if:{{{explosive|}}}|{{{explosive}}}|no}}}} |no||e}}}}{{
#vardefine: ranged | {{#ifeq: {{lc: {{#if:{{{ranged|}}}|{{{ranged}}}|no}}}} | no |
+
#ifexpr: {{#len:{{#var:style|}}}} < 1
    | {{categorizer|nocat={{{nocat|false}}}
+
|{{maintenance task|nocat={{{nocat|false}}} <!-- all options are invalid -->
        |category=Ranged enemies
+
  |category=Enemies of an unknown combat style
        |label=Ranged}} }}}}{{
+
  |doclink=Infobox Enemy/style
#vardefine: magic | {{#ifeq: {{lc: {{#if:{{{magic|}}}|{{{magic}}}|no}}}} | no |
+
  |label=''unknown''
    | {{categorizer|nocat={{{nocat|false}}}
+
  |reason=None of the '''melee''', '''ranged''', '''magic''' and '''explosive''' parameters are specified}}
        |category=Magical enemies
+
|{{
        |label=Magic}} }}}}{{
+
  #ifexpr: {{#len:{{#var:style|}}}} > 1
#vardefine: explosive | {{#ifeq: {{lc: {{#if:{{{explosive|}}}|{{{explosive}}}|no}}}} | no |
+
  |{{categorizer|nocat={{{nocat|false}}} <!-- multiple options are valid -->
    | {{categorizer|nocat={{{nocat|false}}}
+
    |category=Multistyle enemies
        |category=Explosive enemies
+
    |label=Multiple:}}
        |label=Explosive}} }}}}{{
+
  </td></tr>
#switch:  
+
  <tr><td colspan="2">}}{{list|range=4|separator={{#ifexpr: {{#len:{{#var:style|}}}} <= 1|implode}}
| {{#var:melee}}{{#var:ranged}}{{#var:magic}}{{#var:explosive}} = {{maintenance task|nocat={{{nocat|false}}} <!-- all options are invalid -->
+
  |{{#if: {{#pos:{{#var:style|}}|m}} | {{categorizer|category=Melee enemies|label=Melee|nocat={{{nocat|false}}}}}}}
    |category=Enemies of an unknown combat style
+
  |{{#if: {{#pos:{{#var:style|}}|r}} | {{categorizer|category=Ranged enemies|label=Ranged|nocat={{{nocat|false}}}}}}}
    |label=''unknown''
+
  |{{#if: {{#pos:{{#var:style|}}|g}} | {{categorizer|category=Magical enemies|label=Magic|nocat={{{nocat|false}}}}}}}
    |reason=None of the '''melee''', '''ranged''', '''magic''' and '''explosive''' parameters are specified}}
+
  |{{#if: {{#pos:{{#var:style|}}|e}} | {{categorizer|category=Explosive enemies|label=Explosive|nocat={{{nocat|false}}}}}}} }}
| {{#var:melee}}{{#var:ranged}}{{#var:magic}}
+
}}</includeonly><noinclude>{{Infobox Template
| {{#var:melee}}{{#var:ranged}}{{#var:explosive}}
+
|purpose=infobox
| {{#var:melee}}{{#var:magic}}{{#var:explosive}}
+
|singletag=no
| {{#var:ranged}}{{#var:magic}}{{#var:explosive}} = {{#var:melee}}{{#var:ranged}}{{#var:magic}}{{#var:explosive}} <!-- only one option is valid -->
+
|multiline=optional
| #default = {{categorizer|nocat={{{nocat|false}}} <!-- multiple options are valid -->
+
|gamerelated=yes
        |category=Multistyle enemies
+
|suppressible=recursively
        |label=Multiple:}}
+
|choice=multiple
    </td></tr>
+
|cat1=Melee enemies!melee
    <tr><td colspan="2"><ul>{{
+
|cat2=Ranged enemies!ranged
        #if:{{#var:melee}}|<li>{{#var:melee}}</li>}}{{
+
|cat3=Magical enemies!magic
        #if:{{#var:ranged}}|<li>{{#var:ranged}}</li>}}{{
+
|cat4=Explosive enemies!explosive
        #if:{{#var:magic}}|<li>{{#var:magic}}</li>}}{{
+
|cat5=Multistyle enemies!''multiple''
        #if:{{#var:explosive}}|<li>{{#var:explosive}}</li>}}</ul>
+
|cat6=Enemies of an unknown combat style!''unknown''!maintenance
}}</includeonly><noinclude>
+
|var1=style
 +
}}
 +
 
 
This template offers a multiple choice for defining which combat style(s) an (enemy) article belongs to. It can also automatically categorize a page under those categories.
 
This template offers a multiple choice for defining which combat style(s) an (enemy) article belongs to. It can also automatically categorize a page under those categories.
  
Line 63: Line 65:
 
:{{categorizer|category=Melee enemies|label=Melee|nocat=true}}
 
:{{categorizer|category=Melee enemies|label=Melee|nocat=true}}
 
:{{categorizer|category=Ranged enemies|label=Ranged|nocat=true}}
 
:{{categorizer|category=Ranged enemies|label=Ranged|nocat=true}}
:{{categorizer|category=Magic enemies|label=Magic|nocat=true}}
+
:{{categorizer|category=Magical enemies|label=Magic|nocat=true}}
 
:{{categorizer|category=Explosive enemies|label=Explosive|nocat=true}}
 
:{{categorizer|category=Explosive enemies|label=Explosive|nocat=true}}
  
Line 113: Line 115:
 
This would render the same result as the first example above, but would not automatically categorize under [[:Category:Melee enemies]]. This feature works both on valid values and the maintenance task mentioned above.
 
This would render the same result as the first example above, but would not automatically categorize under [[:Category:Melee enemies]]. This feature works both on valid values and the maintenance task mentioned above.
  
[[Category:Article Categorizers|enemy]]</noinclude>
+
</noinclude>

Latest revision as of 17:22, 7 June 2014

Infobox Enemy/style
Purpose

Infobox [list all]

Single tag

No [list all]

Multi-line

Optional [list all]

Protected

No [list all]

Game related

Yes [list all]

Categorization
Suppressible

Recursively [list all]

Choice

Multiple categories [list all]

Categories

Multiple: [list all]

Variables
Names

One: [list all]

  • style  (free for reuse)
Subpages

This template offers a multiple choice for defining which combat style(s) an (enemy) article belongs to. It can also automatically categorize a page under those categories.

Parameters

  • melee: Whether or not this enemy attacks using hand-to-hand combat (defaults to no, enable by any other nonempty value)
  • ranged: Whether or not this enemy attacks using a weapon from a distance (defaults to no, enable by any other nonempty value)
  • magic: Whether or not this enemy attacks using magical spells/objects (defaults to no, enable by any other nonempty value)
  • explosive: Whether or not this enemy's attacks explode on hit (defaults to no, enable by any other nonempty value)
  • nocat: Whether or not to suppress categorization under the chosen categories (defaults to false, which means auto categorization).


Note: the explosive parameter is often paired with ranged, when enemies throw with explosive objects.

Note: this categorizer is multiple choice: you can specify any combination of the four options.

Note: if neither melee, ranged, magic or explosive specify a positive value, the default 'unknown' will be used.

Syntax

{{Infobox Enemy/style|melee=value|ranged=value|magic=value|explosive=value}}

Examples

Common use include any of the melee, ranged, magic or explosive parameters to specify the style an enemy attacks with (value "yes" is recommended):

{{Infobox Enemy/style|melee=yes}}
{{Infobox Enemy/style|ranged=yes}}
{{Infobox Enemy/style|magic=yes}}
{{Infobox Enemy/style|explosive=yes}}
Melee [list all]
Ranged [list all]
Magic [list all]
Explosive [list all]


You can also specify multiple styles for one enemy (warning: this will force a table cell to split in two, so do not do this outside table cells!):

{{Infobox Enemy/style|melee=yes|ranged=yes}}
Multiple: [list all]


It doesn't matter which value you use, any nonempty value other than "no" will express a positive value, so these all have the same result:

{{Infobox Enemy/style|melee=aye, let's do this!}}
{{Infobox Enemy/style|melee=false}}
{{Infobox Enemy/style|melee=not}}
{{Infobox Enemy/style|melee=maybe}}
{{Infobox Enemy/style|melee=0}}
{{Infobox Enemy/style|melee=zero}}
{{Infobox Enemy/style|melee=null}}
{{Infobox Enemy/style|melee=n}}
{{Infobox Enemy/style|melee=whatever}}
{{Infobox Enemy/style|melee=yes}}
{{Infobox Enemy/style|melee=YES}}
Melee [list all]


The only ways to express a negative value is by leaving out the parameter, leaving it empty or specifying "no" (case insensitive), so these all have the same result:

{{Infobox Enemy/style|melee=yes}}
{{Infobox Enemy/style|melee=yes|ranged=}}
{{Infobox Enemy/style|melee=yes|ranged=no}}
{{Infobox Enemy/style|melee=yes|ranged=NO}}
Melee [list all]


You may leave the "style" undefined (which would raise the Enemies of an unknown combat style maintenance task) by not specifying any positive value for any of the options, so these all have the same result:

{{Infobox Enemy/style}}
{{Infobox Enemy/style|melee=no}}
{{Infobox Enemy/style|melee=|ranged=|magic=|explosive=}}
unknown [list all]


The nocat parameter may be used to suppress automatic categorization like this (any value will do):

{{Infobox Enemy/style|melee=yes|nocat=true}}

This would render the same result as the first example above, but would not automatically categorize under Category:Melee enemies. This feature works both on valid values and the maintenance task mentioned above.