From GamingWiki
Jump to: navigation, search
 
(48 intermediate revisions by the same user not shown)
Line 1: Line 1:
Draw a section in a character sheet for skills. This template is unforgiving:
+
{{Documentation}}
all of its parameters are required (but may be empty).
 
  
 
{| class="infobox"
 
{| class="infobox"
 
<onlyinclude><!--
 
<onlyinclude><!--
 +
 +
-->{{#vardefine: defaultskillclass | skill }}<!--
 +
-->{{#vardefine: defaultskillranks | Average (+1) :: Decent (+2) :: Good (+3) :: Great (+4) :: Superb (+5) }}<!--
 +
-->{{#vardefine: defaultskilltypes | combat track }}<!--
 +
-->{{#vardefine: defaultskillmarks | }}<!--
 +
 +
  Parse a list of skills and their attributes
 +
-->{{#if: {{{skilllist|}}} |<!--
 +
  -->{{#hashdefine:  skilllisthash }}<!--
 +
  -->{{#arraydefine: skillgroupsarray | {{{skilllist}}} | ;; }}<!--
 +
  -->{{#arrayprint:  skillgroupsarray | | $skilllistline$ | <!--
 +
      -->{{#arraydefine: skillgrouparray | $skilllistline$ | :: }}<!--
 +
      -->{{#vardefine:  skillgroupname  | {{#arrayindex: skillgrouparray | 0}} }}<!--
 +
      -->{{#arrayslice:  skillgrouparray | skillgrouparray | 1 }}<!--
 +
      -->{{#arrayprint:  skillgrouparray | | $skillstring$ | <!--
 +
        -->{{#vardefine: skillname | {{#explode: $skillstring$ | // | 0 }} }}<!--
 +
        -->{{#vardefine: skillattr | {{#explode: $skillstring$ | // | 1 }} }}<!--
 +
        -->{{#hashinclude: skilllisthash | {{#var:skillname}} = 0 }}<!--
 +
        -->{{#hashinclude:  skillhash-{{#var:skillname}}
 +
            | group = {{#var:skillgroupname}}
 +
            | attributes = {{#var:skillgroupattr}}
 +
            }}<!--
 +
      -->}}<!--
 +
  -->}}<!--
 +
-->}}<!--
 +
 +
-->{{#vardefine: cols | {{{columns|6}}} }}<!--
  
 
   Define the types of skills available. These each have their own class, too.
 
   Define the types of skills available. These each have their own class, too.
-->{{#vardefine:  skillClass    | {{{skillclass}}} }}<!--
+
-->{{#vardefine:  skillClass    | {{{skillclass |{{#var:defaultskillclass}} }}} }}<!--
-->{{#arraydefine: skilltypearray | {{{skilltypes}}} | /\s+/ }}<!--
+
-->{{#arraydefine: skilltypearray | {{{skilltypes |{{#var:defaultskilltypes}} }}} | /\s+/ }}<!--
 
-->{{#arraytohash: classhash      | skilltypearray | skilltypearray }}<!--
 
-->{{#arraytohash: classhash      | skilltypearray | skilltypearray }}<!--
  
 
   We may have custom skill ranks.
 
   We may have custom skill ranks.
-->{{#arraydefine: skilllevelarray | {{{skillranks}}} | :: }}<!--
+
-->{{#arraydefine: skilllevelarray | {{{skillranks |{{#var:defaultskillranks}} }}} | :: }}<!--
 
-->{{#arraymerge: skilllevelsreverse | skilllevelarray }}<!--
 
-->{{#arraymerge: skilllevelsreverse | skilllevelarray }}<!--
 
-->{{#arraysort:  skilllevelsreverse | reverse }}<!--
 
-->{{#arraysort:  skilllevelsreverse | reverse }}<!--
Line 17: Line 43:
  
 
   There are various skill markers that may be defined -- these go into a hash.
 
   There are various skill markers that may be defined -- these go into a hash.
-->{{#hashdefine: skillmarkerhash | {{{skillmarkers}}} | :: | /\/\// }}<!--
+
-->{{#hashdefine: skillmarkerhash | {{{skillmarkers|{{#var:defaultskillmarks}} }}} | :: | /\/\// }}<!--
  
 
   Use a hash to store and then print the skills
 
   Use a hash to store and then print the skills
 
-->{{#hashdefine: skillhash}}<!--
 
-->{{#hashdefine: skillhash}}<!--
 +
  Keep track of how many skill slots have been used
 +
-->{{#vardefine: skillsused | 0}}<!--
  
 
   We either have a long section of skills, or one entry per level.
 
   We either have a long section of skills, or one entry per level.
-->{{#ifeq: {{{skills|M_NUL}}}|M_NUL|<!--
+
-->{{#if: {{{skills|}}}|<!--
 +
  One 'skills' section.
 +
  Lines are listed in descending order of skill. Each line is of the form:
 +
  ;; SkillName//OpType//OpModifier :: SkillName//OpType//OpModifier ...
 +
  where SkillName is just what it says, OpType is an optional type to the
 +
  skill (such as 'combat' or 'track' and OpModifier is an optional modifier
 +
  such as 'MG'.
 +
  Note: we assume that no skill lines are missing.
 +
 
 +
  -->{{#arraydefine: skillsbylevel | {{{skills}}}  | ;; }}<!--
 +
  -->{{#arrayslice:  skillsbylevel | skillsbylevel | 0 }}<!--
 +
  -->{{#arraytohash: skillhash    | skillsbylevel | skilllevelsreverse }}<!--
 +
  -->{{#arrayreset:  skillsbylevel}}<!--
 +
-->|<!--
 
   No single skills section. We look for multiple sections: 'skills1', 'skills2', etc.
 
   No single skills section. We look for multiple sections: 'skills1', 'skills2', etc.
 
   There are several parameters: skills1, skill2, and so on. Each corresponds  
 
   There are several parameters: skills1, skill2, and so on. Each corresponds  
Line 33: Line 74:
 
   -->{{#forargs: skills | thelevel | theskilllist | <!--
 
   -->{{#forargs: skills | thelevel | theskilllist | <!--
 
       -->{{#ifeq: {{#var:theskilllist}} | M_NUL ||<!--
 
       -->{{#ifeq: {{#var:theskilllist}} | M_NUL ||<!--
      -->{{#rmatch: {{#var:thelevel}} | /^\d+$/ | <!--
+
        -->{{#rmatch: {{#var:thelevel}} | /^\d+$/ | <!--
        -->{{#hashinclude: skillhash | <!--
+
            -->{{#hashinclude: skillhash | {{#var: thelevel}}={{#var:theskilllist}} }}<!--
            -->{{#arrayindex: skilllevelarray | {{#expr:{{#var: thelevel}}-1}} }}={{#var:theskilllist}}<!--
 
 
         -->}}<!--
 
         -->}}<!--
      -->}}<!--
 
 
       -->}}<!--
 
       -->}}<!--
 
   -->}}<!--
 
   -->}}<!--
-->|<!--
+
-->}}<!-- end if
  One 'skills' section.
 
  Lines are listed in descending order of skill. Each line is of the form:
 
  ;; SkillName//OpType//OpModifier :: SkillName//OpType//OpModifier ...
 
  where SkillName is just what it says, OpType is an optional type to the
 
  skill (such as 'combat' or 'track' and OpModifier is an optional modifier
 
  such as 'MG'.
 
  Note: we assume that no skill lines are missing.
 
  
  -->{{#arraydefine: skillsbylevel | {{{skills}}}  | ;; }}<!--
+
  Get the keys of our skill hash:
  -->{{#arrayslice: skillsbylevel | skillsbylevel | 0 }}<!--
+
-->{{#hashtoarray:|skillhash|skillhashkeys}}<!--
  -->{{#arraytohash: skillhash    | skillsbylevel | skilllevelsreverse }}<!--
+
-->{{#arraysort:skillhashkeys|desc}}<!--
-->}}<!--
+
-->{{#arraydefine: skillpartkeys | name, marker}}<!--
  
 +
  Print the section header
 
-->
 
-->
{{Character sheet/section
+
{{Character sheet/section  
| subhead  = Skills
+
| columns  = {{#var:cols}}
| righthead = types: {{#hashprint: classhash | , | %%%% | @@@@ | <span class="{{#var:skillClass}} @@@@"> %%%%</span> }}
+
| subhead  = {{{label|Skills}}}
}}<!-- end section --><!--
+
| righthead = {{#if:{{{skilltypes|}}}|<!--
 +
  -->skill types: {{#hashprint: classhash | , | %%%% | @@@@ | <span class="{{#var:skillClass}} @@@@"> %%%%</span> }}<!--
 +
  -->}}
 +
}}<!-- end section
  
-->{{#arraydefine: skillhashkeys | name, marker}}<!--
+
  Print the skill listings
-->{{#hashprint: skillhash || %%%% | @@@@ | <nowiki />
+
-->{{#hashprint: skillhash || $skillrank$ | $skline$ | <!--
{{!}}-
+
  -->{{#arraydefine: skilllineary | $skline$ | ; }}<!--
{{!}} class="label" {{!}} %%%%
+
  -->{{#if: $skline$ |<!--
{{!}} colspan="3" class="{{#var: skillClass }}" {{!}} <!--
+
      -->{{Character sheet/section<!--
  -->{{#arraydefine: skilllineary | @@@@ | :: }}<!--
+
      -->| labelclass1 = label <!--
  -->{{#arrayprint: skilllineary | ,&nbsp; | $theskill$ | <!--
+
      -->| dataclass1  = {{#var: skillClass }} <!--
      -->{{#arraydefine: theskillarray | $theskill$ | /\/\// }}<!--
+
      -->| label1 = {{#arrayindex: skilllevelarray | {{#expr: $skillrank$ -1}} }}<!--
      -->{{#arraytohash: theskillhash | theskillarray | skillhashkeys }}<!--
+
      -->| data1  = <!--
      --><span class="{{#var: skillClass}} {{lc:{{#hashvalue: theskillhash | name}}}}"><!--
+
        -->{{#arrayprint: skilllineary | ,&nbsp; | $theskill$ | <!--
      -->{{#hashvalue: theskillhash | name | _____ }}<!--
+
            -->{{#arraydefine: theskillarray | $theskill$ | /\/\// }}<!--
       --></span> <!--
+
            -->{{#arraytohash: theskillhash | theskillarray | skillpartkeys }}<!--
      -->{{#hashvalue: skillmarkerhash | {{#hashvalue: theskillhash | marker}} }}<!--
+
            -->{{#vardefine: theskillname | {{#hashvalue: theskillhash | name}} }}<!--
  -->}}<!--
+
            -->{{#vardefine: theskilltag  | {{lc:{{#replace:{{#var: theskillname}}||-}}}}}}<!--
-->|skilllevelsreverse}}<!--
+
 
 +
            --><span class="{{#var:skillClass}} skill-{{#var:theskilltag}}"><!--
 +
            -->{{#var: theskillname }}<!--
 +
            --></span> <!--
 +
            -->{{#hashvalue: skillmarkerhash | {{#hashvalue: theskillhash | marker}} }}<!--
 +
              Add SMW properties
 +
            -->{{#if:{{#var:theskillname}}|<!--
 +
              -->{{#set:
 +
                  | has skill = {{lc:{{#var:theskillname}}}} ; $skillrank$
 +
                  }}<!--
 +
            -->}}<!--
 +
 
 +
              Increment skill slot counter
 +
            -->{{#vardefine: skillsused | {{#expr: {{#var:skillsused|0}} + $skillrank$}} }}<!--
 +
 
 +
            -->{{#arrayreset: theskillarray}}<!--
 +
            -->{{#hashreset: theskillhash}}<!--
 +
        -->}}<!-- end arrayprint
 +
       -->}}<!-- end section
 +
  -->}}<!-- end if skline
 +
  -->{{#arrayreset: skilllinearray}}<!--
 +
--><!--|skilllevelsreverse}}--><!-- end hashprint
 +
-->|skillhashkeys}}<!-- end hashprint
 +
 
 +
  Print the section footer, if required
 +
-->{{#if: {{#vardefineecho:skillsallowed|{{{defaultskillpoints|}}}}}|
 +
{{Character sheet/section
 +
| columns  = {{#var:cols}}
 +
| llabel1  = Points used  | ldata1    = {{#var:skillsused}}
 +
| label1    = remaining    | data1    = {{#expr: {{#var:skillsallowed}} - {{#var:skillsused}} }}
 +
| rlabel1  = total        | rdata1    = {{#var:skillsallowed}}
 +
}}<!-- end section
 +
-->}}<!-- end if
 +
 
 +
-->{{#hashreset: skillhash | skillmarkerhash | classhash }}<!--
 +
-->{{#arrayreset: skilltypearray, skilllevelarray, skilllevelsreverse, skillhashkeys, skillpartkeys }}<!--
  
 
--></onlyinclude>
 
--></onlyinclude>
 
|}
 
|}

Latest revision as of 17:42, 3 February 2016

[create]
Error creating thumbnail: File missing
Template documentation
Skills