From GamingWiki
Jump to: navigation, search
Line 6: Line 6:
 
-->{{#vardefine: cols | {{{columns|6}}} }}<!--
 
-->{{#vardefine: cols | {{{columns|6}}} }}<!--
  
   debug: hard-code it for now.
+
   debug: hard-code some of it for now.
  
-->{{Character sheet/section
+
  @todo: implement skill point expenditure
| columns  = {{#var:cols}}
 
| header  = {{{label|Skill modes}}}
 
}}<!-- end section header
 
  
 
-->{{#hashdefine: sectionParams}}<!--
 
-->{{#hashdefine: sectionParams}}<!--
Line 18: Line 15:
 
-->{{#hashinclude: sectionParams
 
-->{{#hashinclude: sectionParams
 
| columns  = {{#var:cols}}
 
| columns  = {{#var:cols}}
 +
| header  = {{{label|Skill modes}}}
 
| labelclass1 = label  
 
| labelclass1 = label  
 
| llabel1 = &nbsp;
 
| llabel1 = &nbsp;
Line 25: Line 23:
 
| llabel5 = Fair (+2)
 
| llabel5 = Fair (+2)
 
| llabel6 = Average (+1)
 
| llabel6 = Average (+1)
| ldata1  = &nbsp;
 
| ldata2  = &nbsp;
 
| ldata3  = &nbsp;
 
| ldata4  = &nbsp;
 
| ldata5  = &nbsp;
 
| ldata6  = &nbsp;
 
| ldataclass2 = specialized skill
 
| ldataclass3 = focused skill
 
| ldataclass4 = trained skill
 
| ldataclass5 = shaded
 
| ldataclass6 = shaded
 
| cdata1  = &nbsp;
 
| cdata2  = &nbsp;
 
| cdata3  = &nbsp;
 
| cdata4  = &nbsp;
 
| cdata5  = &nbsp;
 
| cdata6  = &nbsp;
 
| cdataclass2 = shaded
 
| cdataclass3 = specialized skill
 
| cdataclass4 = focused skill
 
| cdataclass5 = trained skill
 
| cdataclass6 = shaded
 
| rdata1  = &nbsp;
 
| rdata2  = &nbsp;
 
| rdata3  = &nbsp;
 
| rdata4  = &nbsp;
 
| rdata5  = &nbsp;
 
| rdata6  = &nbsp;
 
| rdataclass2 = shaded
 
| rdataclass3 = shaded
 
| rdataclass4 = specialized skill
 
| rdataclass5 = focused skill
 
| rdataclass6 = trained skill
 
 
}}<!-- end section
 
}}<!-- end section
  
-->{{#arraydefine:modeArray|{{#ask: [[is a :: skill]] [[skill in mode :: Hemocrat||Space||Science]]
+
  TERMINOLOGY:
|?Name
+
  * Rank: position on the adjective ladder. May be divided into rankName and rankVal
|?Skill in mode=Mode
+
  * Level: skill level, i.e, untrained, trained, focused or specialized
| format=array
 
}}}}<!--
 
  
-->{{#hashdefine: modeHash | Hemocrat;, Space;, Science; }}<!--
+
-->{{#vardefine:modeGood|{{{mode good|Hemocrat}}}}}<!--
-->{{#hashdefine: skillModeHash}}<!--
+
-->{{#vardefine:modeFair|{{{mode fair|Space}}}}}<!--
-->{{#hashdefine: skillLevelHash}}<!--
+
-->{{#vardefine:modeAverage|{{{mode average|Science}}}}}<!--
-->{{#arrayprint: modeArray | , | @@@@ | <!--
+
 
  -->{{#vardefine:currentSkillPage| {{#explode:@@@@|<PROP>|0}} }}<!--
+
   Some initial arrays and hashes:
  -->{{#vardefine:currentSkillName| {{#explode:@@@@|<PROP>|1}} }}<!--
+
   * modeArray lists the three modes in ascending rank
   -->{{#arraydefine:currentSkillModes| {{#explode:@@@@|<PROP>|2}} |<MANY>}}<!--
+
  * levelArray lists all four levels in ascending order
   -->{{#arraysearch:currentSkillModes|Hemocrat|0| <!--
+
  * levelSubArray is like levelArray, without "untrained".
      -->{{#hashinclude:skillModeHash| {{#var:currentSkillName}}=Hemocrat}}<!--
+
  * modeHash is to be populated later. The eventual structure will be:
      -->{{#hashinclude:skillLevelHash| {{#var:currentSkillName}}=3}}<!--
+
    * keys are mode names
  -->|<!--
+
    * values are hashtables, defined as:
  -->}}<!--
+
      * keys are levels
  -->{{#arraysearch:currentSkillModes|Space|0| <!--
+
      * values are arrays of skill names
      -->{{#hashkeyexists:skillModeHash|{{#var:currentSkillName}}|<!--
+
 
        -->{{#hashinclude:skillLevelHash| {{#var:currentSkillName}}={{#eval:{{#hashvalue:skillLevelHash|{{#var:currentSkillName}}}}+1}}}}<!--
+
-->{{#arraydefine: modeArray | {{#var: modeFair}}, {{#var: modeAverage}}, {{#var: modeGood}} | , }}<!--
      -->|}}<!--
+
-->{{#arraydefine: levelArray | untrained, trained, focused, specialized | , }}<!--
      -->{{#hashinclude:skillModeHash| {{#var:currentSkillName}}=Space}}<!--
+
-->{{#arrayslice: levelSubarray | levelArray | 1 }}<!--
      -->{{#hashinclude:skillLevelHash| {{#var:currentSkillName}}=2}}<!--
+
-->{{#arraytohash: levelModeHash | modeArray | levelSubarray}}<!--
  -->|<!--
+
-->{{#arrayprint: modeArray | | <mode> | <!--
  -->}}<!--
+
  -->{{#hashinclude: modeHash  | <mode> = {{#arrayprint: levelSubArray | <LEVELSEP> | <level> | <level><LEVELVAL>}} }}<!--
  -->{{#arraysearch:currentSkillModes|Science|0| <!--
 
      -->{{#hashkeyexists:skillModeHash|{{#var:currentSkillName}}|<!--
 
        -->{{#hashinclude:skillLevelHash| {{#var:currentSkillName}}={{#eval:{{#hashvalue:skillLevelHash|{{#var:currentSkillName}}}}+1}}}}<!--
 
      -->|}}<!--
 
      -->{{#hashinclude:skillModeHash| {{#var:currentSkillName}}=Science}}<!--
 
      -->{{#hashinclude:skillLevelHash| {{#var:currentSkillName}}=1}}<!--
 
  -->|<!--
 
  -->}}<!--
 
 
-->}}<!--
 
-->}}<!--
  
-->{{#hashinclude: sectionParams
+
  Query all skills found belonging to our three modes.
| ldata1  = Hemocrat
+
-->{{#arraydefine:skillArray |
| ldata2  = &nbsp;
+
      {{#ask: [[is a :: skill]] [[skill in mode :: {{#arrayprint: modeArray | {{!}}{{!}} }}]]
| ldata3  = &nbsp;
+
      |?Name
| ldata4  = Culture/Tech<br/>Resources<br/>Contacts<br/>Deceive<br/>Systems
+
      |?Skill in mode=Mode
| ldata5  = &nbsp; <!-- {{#hashprint:skillModeHash}} -->
+
      | format=array
| ldata6  = &nbsp; <!-- {{#hashprint:skillLevelHash}} -->
+
      }}
| cdata1  = Space
+
  }}<!--
| cdata2  = &nbsp;
 
| cdata3  = &nbsp;
 
| cdata4  = &nbsp;
 
| cdata5  = Engineering<br/>EVA<br/>Gunnery<br/>Pilot<br/>Systems
 
| cdata6  = &nbsp;
 
| rdata1  = Science
 
| rdata2  = &nbsp;
 
| rdata3  = &nbsp;
 
| rdata4  = &nbsp;
 
| rdata5  = &nbsp;
 
| rdata6  = ''all sciences''
 
}}<!-- end section
 
  
-->{{#hashtotemplate:   Character sheet/section | sectionParams }}<!--
+
  Now iterate over all the skills returned from our query
 +
-->{{#arrayprint: skillArray | | <skill> | <!--
  
  Print the section footer, if required
+
  -->{{#hashdefine: currentSkill}}<!--
  
-->{{#vardefine:skillsused|0}}<!--
+
      Array items are page, name, mode(s)
-->{{#vardefine:skillsallowed|7}}<!--
+
  -->{{#vardefine: currentSkillPage      | {{#explode:<skill>|<PROP>|0}} }}<!--
-->{{Character sheet/section
+
  -->{{#vardefine: currentSkillName      | {{#explode:<skill>|<PROP>|1}} }}<!--
| 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
 
  
   end debug
+
      First we create an array containing all the modes the current skill
 +
      belongs to. Then we use that array as a filter so we end up with the
 +
      intersection of the skill's modes and the character's modes -- i.e, all
 +
      the character's modes that contain the current skill. This final array
 +
      is currentSkillModes.
 +
   -->{{#arraydefine: currentSkillAllModes  | {{#explode:<skill>|<PROP>|2}} |<MANY>}}<!--
 +
  -->{{#arraysearcharray: currentSkillModes | modeArray | /^{{#arrayprint: currentSkillAllModes | {{!}} }}$/ }}<!--
  
-->{{#vardefine: defaultskillclass | skill }}<!--
+
      Now the number of entries in currentSkillModes is the number of the
-->{{#vardefine: defaultskillranks | Average (+1) :: Decent (+2) :: Good (+3) :: Great (+4) :: Superb (+5) }}<!--
+
      character's modes the current skill appears in. This also happens to be
-->{{#vardefine: defaultskilltypes | }}<!--
+
      the bonus the skill has as a result of skill reinforcement [FSTK 30].
-->{{#vardefine: defaultskillmarks | }}<!--
+
      And the last element of currentSkillModes should be the character's
 +
      highest-ranked mode for this skill.
 +
  -->{{#vardefine: currentSkillPrimaryMode | {{#arrayindex: currentSkillModes | -1 }} }}<!--
 +
  -->{{#vardefine: currentSkillLevel      | {{#arrayindex: levelArray | {{#arraysize: currentSkillModes}} }} }}<!--
  
  Parse a list of skills and their attributes
+
      Hash of all the levels of the primary mode, keyed by level name. We're
-->{{#if: {{{skilllist|}}} |<!--
+
      going to append the current skill to it and then put it back in modeHash.
   -->{{#hashdefine:  skilllisthash }}<!--
+
   -->{{#hashdefine:  levelsOfPrimaryMode | {{#hashvalue: modeHash | {{#var: currentSkillPrimaryMode}} }} | <LEVELSEP> | <LEVELVAL> }}<!--
  -->{{#arraydefine: skillgroupsarray | {{{skilllist}}} | ;; }}<!--
+
      Array of the skills defined for the primary mode, at this level. Here we
  -->{{#arrayprint: skillgroupsarray | | $skilllistline$ | <!--
+
      append the current skill along with a separator. The first time we do
      -->{{#arraydefine: skillgrouparray | $skilllistline$ | :: }}<!--
+
      this for any given mode-level combination we'll get an empty element, so
       -->{{#vardefine:   skillgroupname  | {{#arrayindex: skillgrouparray | 0}} }}<!--
+
      we ensure that the elements are unique. We also sort them because
      -->{{#arrayslice: skillgrouparray | skillgrouparray | 1 }}<!--
+
      sorting is nice :)
       -->{{#arrayprint:  skillgrouparray | | $skillstring$ | <!--
+
  -->{{#arraydefine: modeSkillsAtLevel <!--
        -->{{#vardefine: skillname | {{#explode: $skillstring$ | // | 0 }} }}<!--
+
       -->| {{#hashvalue: modeLevelsHash | {{#var: currentSkillLevel }} }} <LEVELSKILL> {{#var: currentSkillName}} <!--
        -->{{#vardefine: skillattr | {{#explode: $skillstring$ | // | 1 }} }}<!--
+
       -->| <LEVELSKILL> | unique,sort=asc <!--
        -->{{#hashinclude: skilllisthash | {{$var:skillname}} = 0 }}<!--
+
  -->}}<!--
        -->{{#hashinclude:  skillhash-{{#var:skillname}}  
+
      Now we reassemble the original hash:
            | group = {{#var:skillgroupname}}
+
  -->{{#hashinclude: levelsOfCurrentMode | {{#var: currentSkillLevel }} = {{#arrayprint: modeSkillsAtLevel | <LEVELSKILL> }} }}<!--
            | attributes = {{#var:skillgroupattr}}
+
  -->{{#hashinclude: modeHash            | <!--
            }}<!--
+
      -->   {{#var: currentSkillPrimaryMode}} = {{#hashprint: levelsOfCurrentMode | <LEVELSEP> | <K> | <V> | <K><LEVELVAL><V> }} <!--
      -->}}<!--
 
 
   -->}}<!--
 
   -->}}<!--
 +
 
-->}}<!--
 
-->}}<!--
  
  Define the types of skills available. These each have their own class, too.
+
  Once the above loop is done modeHash should have the desired structure.
-->{{#vardefine:  skillClass    | {{{skillclass  |{{#var:defaultskillclass}} }}} }}<!--
 
-->{{#arraydefine: skilltypearray | {{{skilltypes  |{{#var:defaultskilltypes}} }}} | /\s+/ }}<!--
 
-->{{#arraytohash: classhash      | skilltypearray | skilltypearray }}<!--
 
  
  We may have custom skill ranks.
 
-->{{#arraydefine: skilllevelarray | {{{skillranks  |{{#var:defaultskillranks}} }}} | :: }}<!--
 
-->{{#arraymerge: skilllevelsreverse | skilllevelarray }}<!--
 
-->{{#arraysort:  skilllevelsreverse | reverse }}<!--
 
-->{{#vardefine:  numSkLvl    | {{#arraysize: skilllevelarray}} }}<!--
 
  
  There are various skill markers that may be defined -- these go into a hash.
+
  @todo: The next step is to apply spent skill points. We'll do some error-checking here.
-->{{#hashdefine: skillmarkerhash | {{{skillmarkers|{{#var:defaultskillmarks}} }}} | :: | /\/\// }}<!--
 
  
  Use a hash to store and then print the skills
 
-->{{#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.
+
   Process all three modes:
-->{{#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}}}  | ;; }}<!--
+
   Each element of modeLoopArray is composed of a rank name, the prefix of the
   -->{{#arrayslice: skillsbylevel | skillsbylevel | 0 }}<!--
+
  fields each mode should use, and the index of the field that should contain the
   -->{{#arraytohash: skillhash    | skillsbylevel | skilllevelsreverse }}<!--
+
  "trained" level skills.
   -->{{#arrayresetskillsbylevel}}<!--
+
-->{{#arraydefine: modeLoopArray | Good;ldata;4, Fair;cdata;5, Average;rdata;6}}<!--
-->|<!--
+
-->{{#arrayprint:  modeLoopArray | | <currentModeArray> |<!--
   No single skills section. We look for multiple sections: 'skills1', 'skills2', etc.
+
 
  There are several parameters: skills1, skill2, and so on. Each corresponds
+
  -->{{#vardefine: currentModeRank    | {{#explode: <currentModeArray> | ; | 0 }} }}<!--
   to a single skill rank, and each is of the form:
+
  -->{{#vardefine: currentFieldPrefix | {{#explode: <currentModeArray> | ; | 1 }} }}<!--
  | skillN = SkillName//OpType//OpModifier :: SkillName//OpType//OpModifier ...
+
  -->{{#vardefine: currentTrainedIndex | {{#explode: <currentModeArray> | ; | 2 }} }}<!--
  as in the previous form. We no longer assume that all skill lines are
+
   -->{{#vardefine: currentModeName    | {{#var: mode{{#var:currentModeRank}}  }} }}<!--
  present; gaps may be left if desired.
+
 
 
+
      Head each column with a mode name
  -->{{#forargs: skills | thelevel | theskilllist | <!--
+
  -->{{#hashinclude: sectionParams | {{#var: currentFieldPrefix}}1  = {{#var:currentModeName}} }}<!--
      -->{{#ifeq: {{#var:theskilllist}} | M_NUL ||<!--
+
 
         -->{{#rmatch: {{#var:thelevel}} | /^\d+$/ | <!--
+
      Create a hash, currentModeHash, to contain all the information we need about
             -->{{#hashinclude: skillhash | {{#var: thelevel}}={{#var:theskilllist}} }}<!--
+
      the current mode's skills.
 +
   -->{{#hashdefine: currentModeHash | {{#hashValue: modeHash | {{#var: currentModeName}} }} | <LEVELSEP> | <LEVELVAL> }}<!--
 +
    
 +
      Iterate over the indices of our parameter fields to populate our param
 +
      hash with skill names.
 +
  -->{{#loop: fieldIndex | 6 | -5 | <!--
 +
      -->{{#vardefine: fieldName | {{#var: currentFieldPrefix}}{{#var: fieldIndex}} }}<!--
 +
      -->{{#vardefine: fieldClass | {{#var: currentFieldPrefix}}class{{#var: fieldIndex}} }}<!--
 +
    
 +
        Map the elements of our list of levels onto the indices of our fields.  
 +
        This means that for the Good mode, trained skills will go in field 4,  
 +
        focused in field 3 and specialized in field 2.
 +
      -->{{#vardefine: currentLevelIndex | {{#expr: {{#var: currentTrainedIndex}} - {{#var: fieldIndex}} }} }}<!--
 +
      -->{{#vardefine: currentLevel | <!--
 +
        -->{{#ifexpr: ( {{#var: currentLevelIndex}} >= 0 ) and ( {{#var: currentLevelIndex}} < {{#arraysize: levelSubarray}}) <!--
 +
            -->| {{#arrayindex: levelSubarray | {{#var: currentLevelIndex}} }}<!--
 +
            -->| <!--
 +
        -->}}<!--
 +
      -->}}<!--
 +
    
 +
        By default, give all fields a non-breaking space for content and the  
 +
        "shaded" class:
 +
      -->{{#hashinclude: sectionParams | {{#var: fieldName}} = &nbsp; | {{#var: fieldClass}} = shaded }}<!--
 +
      -->{{#if: {{#var: currentLevel}} |<!--
 +
            Here the current loop index corresponds to a level. We set the
 +
            appropriate CSS class and look for skills at this level.
 +
        -->{{#hashinclude: sectionParams | {{#var: fieldClass}} = {{#var: currentLevel}} skill }}<!--
 +
            Now look for skills and print them, if any
 +
        -->{{#arraydefine: levelSkills | {{#hashvalue: currentModeHash | {{#var: currentLevel}} }} | <LEVELSKILL> }}<!--
 +
         -->{{#if: {{#vardefineecho: levelSkillList | {{#arrayprint: levelSkills}} }} |<!--
 +
              There are skills at this level. Save them to the param hash.
 +
             -->{{#hashinclude: sectionParams | {{#var: fieldName}} = {{#var: levelSkillList}} }}<!--
 
         -->}}<!--
 
         -->}}<!--
 
       -->}}<!--
 
       -->}}<!--
   -->}}<!--
+
   -->}}<!-- end loop
-->}}<!-- end if
+
 
 +
      End mode processing.
 +
 
 +
-->}}<!-- end arrayprint
  
  Get the keys of our skill hash:
 
-->{{#hashtoarray:|skillhash|skillhashkeys}}<!--
 
-->{{#arraysort:skillhashkeys|desc}}<!--
 
-->{{#arraydefine: skillpartkeys | name, marker}}<!--
 
  
  Print the section header
+
-->{{#hashtotemplate:  Character sheet/section | sectionParams }}<!--
-->
 
{{Character sheet/section  
 
| columns  = {{#var:cols}}
 
| subhead  = {{{label|Skills}}}
 
| righthead = {{#if:{{{skilltypes|}}}|<!--
 
  -->skill types: {{#hashprint: classhash | , | %%%% | @@@@ | <span class="{{#var:skillClass}} @@@@"> %%%%</span> }}<!--
 
  -->}}
 
}}<!-- end section
 
  
  Print the skill listings
 
-->{{#hashprint: skillhash || $skillrank$ | $skline$ | <!--
 
  -->{{#arraydefine: skilllineary | $skline$ | :: }}<!--
 
  -->{{#if: $skline$ |<!--
 
      -->{{Character sheet/section<!--
 
      -->| labelclass1 = label <!--
 
      -->| dataclass1  = {{#var: skillClass }} <!--
 
      -->| label1 = {{#arrayindex: skilllevelarray | {{#expr: $skillrank$ -1}} }}<!--
 
      -->| data1  = <!--
 
        -->{{#arrayprint: skilllineary | ,&nbsp; | $theskill$ | <!--
 
            -->{{#arraydefine: theskillarray | $theskill$ | /\/\// }}<!--
 
            -->{{#arraytohash: theskillhash | theskillarray | skillpartkeys }}<!--
 
            -->{{#vardefine: theskillname | {{#hashvalue: theskillhash | name}} }}<!--
 
            -->{{#vardefine: theskilltag  | {{lc:{{#replace:{{#var: theskillname}}||-}}}}}}<!--
 
  
            --><span class="{{#var:skillClass}} skill-{{#var:theskilltag}}"><!--
+
  Print the section footer. This contains a summary of advancement points available and spent.
            -->{{#var: theskillname }}<!--
 
            --></span> <!--
 
            -->{{#hashvalue: skillmarkerhash | {{#hashvalue: theskillhash | marker}} }}<!--
 
              Add SMW properties
 
            -->{{#if:{{#var:theskillname}}|<!--
 
              -->{{#set:
 
                  | skill/{{lc:{{#var:theskillname}}}}=$skillrank$
 
                  | has skill at rank $skillrank$={{#var:theskillname}}
 
                  }}<!--
 
            -->}}<!--
 
  
              Increment skill slot counter
+
-->{{#vardefine:skillsused|0}}<!--
            -->{{#vardefine: skillsused | {{#expr: {{#var:skillsused|0}} + $skillrank$}} }}<!--
+
-->{{#vardefine:skillsallowed|7}}<!--
 
+
-->{{Character sheet/section  
            -->{{#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}}
 
| columns  = {{#var:cols}}
 
| llabel1  = Points used  | ldata1    = {{#var:skillsused}}
 
| llabel1  = Points used  | ldata1    = {{#var:skillsused}}
Line 272: Line 184:
 
-->}}<!-- end if
 
-->}}<!-- end if
  
-->{{#hashreset: skillhash | skillmarkerhash | classhash }}<!--
+
  end debug
-->{{#arrayreset: skilltypearray, skilllevelarray, skilllevelsreverse, skillhashkeys, skillpartkeys }}<!--
+
 
  
 
--></onlyinclude>
 
--></onlyinclude>
 
|}
 
|}

Revision as of 15:13, 26 May 2014

[create]
Error creating thumbnail: File missing
Template documentation
Skill modes
  Hemocrat Space Science
Superb (+5)      
Great (+4)      
Good (+3)      
Fair (+2)      
Average (+1)      
Points used 0 remaining 7 total 7