feature: Merge Spell classes
- Refactor merge for subclasses - Removed Artificer as class from PHB spells - Added Artificer spells to Eberron RftLW and UA - Validation for "sleight of hand" is now case insensitive for each first letter
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common">
|
||||
<xsl:output method="xml" indent="yes" />
|
||||
|
||||
|
||||
<!-- Merge the compendiums together -->
|
||||
<xsl:template match="collection">
|
||||
<compendium version="5" auto_indent="NO">
|
||||
@@ -14,86 +15,100 @@
|
||||
|
||||
<xsl:copy-of select="$compendium/feat" />
|
||||
<xsl:copy-of select="$compendium/background" />
|
||||
<xsl:copy-of select="$compendium/spell" />
|
||||
|
||||
<xsl:call-template name="spells-extendable" />
|
||||
|
||||
<xsl:copy-of select="$compendium/monster" />
|
||||
</compendium>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Template once a class is selected -->
|
||||
<xsl:template name="class">
|
||||
<xsl:copy-of select="hd" />
|
||||
<xsl:copy-of select="proficiency" />
|
||||
<xsl:copy-of select="spellAbility" />
|
||||
<xsl:copy-of select="numSkills" />
|
||||
<xsl:copy-of select="armor" />
|
||||
<xsl:copy-of select="weapons" />
|
||||
<xsl:copy-of select="tools" />
|
||||
<xsl:copy-of select="wealth" />
|
||||
<xsl:copy-of select="autolevel" />
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Merges subclasses into classes -->
|
||||
<xsl:template name="classes-with-subclasses">
|
||||
<xsl:variable name="compendium" select="document(doc/@href)/compendium" />
|
||||
<xsl:variable name="classes" select="$compendium/class" />
|
||||
|
||||
|
||||
<!-- Define class variables -->
|
||||
<xsl:variable name="Artificer" select="'Artificer'" />
|
||||
<xsl:variable name="Barbarian" select="'Barbarian'" />
|
||||
<xsl:variable name="Bard" select="'Bard'" />
|
||||
<xsl:variable name="Cleric" select="'Cleric'" />
|
||||
<xsl:variable name="Druid" select="'Druid'" />
|
||||
<xsl:variable name="Fighter" select="'Fighter'" />
|
||||
<xsl:variable name="Monk" select="'Monk'" />
|
||||
<xsl:variable name="Paladin" select="'Paladin'" />
|
||||
<xsl:variable name="Ranger" select="'Ranger'" />
|
||||
<xsl:variable name="Rogue" select="'Rogue'" />
|
||||
<xsl:variable name="Sorcerer" select="'Sorcerer'" />
|
||||
<xsl:variable name="Warlock" select="'Warlock'" />
|
||||
<xsl:variable name="Wizard" select="'Wizard'" />
|
||||
|
||||
<xsl:variable name="classes">
|
||||
<class><xsl:value-of select="$Artificer" /></class>
|
||||
<class><xsl:value-of select="$Barbarian" /></class>
|
||||
<class><xsl:value-of select="$Bard" /></class>
|
||||
<class><xsl:value-of select="$Cleric" /></class>
|
||||
<class><xsl:value-of select="$Druid" /></class>
|
||||
<class><xsl:value-of select="$Fighter" /></class>
|
||||
<class><xsl:value-of select="$Monk" /></class>
|
||||
<class><xsl:value-of select="$Paladin" /></class>
|
||||
<class><xsl:value-of select="$Ranger" /></class>
|
||||
<class><xsl:value-of select="$Rogue" /></class>
|
||||
<class><xsl:value-of select="$Sorcerer" /></class>
|
||||
<class><xsl:value-of select="$Warlock" /></class>
|
||||
<class><xsl:value-of select="$Wizard" /></class>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="class-array" select="exsl:node-set($classes)" />
|
||||
|
||||
|
||||
<!-- Loop through each class -->
|
||||
<xsl:for-each select="$class-array/class">
|
||||
<xsl:variable name="class" select="text()" />
|
||||
|
||||
<!-- If at least one of this class exists, create one class element for it -->
|
||||
<xsl:if test="$compendium/class/name/text()=$class">
|
||||
<class>
|
||||
<name><xsl:value-of select="$class" /></name>
|
||||
|
||||
<!-- For each one of this class, get the elements within the template -->
|
||||
<xsl:for-each select="$classes">
|
||||
<xsl:choose>
|
||||
<!-- Check if there's a duplicate -->
|
||||
<xsl:when test="count($classes[name = current()/name]) > 1">
|
||||
<!-- Use the original class that includes the "hd" element -->
|
||||
<!-- Important: Subclasses should only contain "name" and "autolevel" elements -->
|
||||
<xsl:for-each select="$compendium/class[name=$class]">
|
||||
<xsl:call-template name="class" />
|
||||
</xsl:for-each>
|
||||
</class>
|
||||
</xsl:if>
|
||||
<xsl:if test="hd">
|
||||
<class>
|
||||
<xsl:copy-of select="name" />
|
||||
<xsl:copy-of select="hd" />
|
||||
<xsl:copy-of select="proficiency" />
|
||||
<xsl:copy-of select="spellAbility" />
|
||||
<xsl:copy-of select="numSkills" />
|
||||
<xsl:copy-of select="armor" />
|
||||
<xsl:copy-of select="weapons" />
|
||||
<xsl:copy-of select="tools" />
|
||||
<xsl:copy-of select="wealth" />
|
||||
|
||||
<xsl:for-each select="$classes[name = current()/name]">
|
||||
<xsl:copy-of select="autolevel"/>
|
||||
</xsl:for-each>
|
||||
</class>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<!-- If no duplicate, copy in the whole class -->
|
||||
<xsl:otherwise>
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
|
||||
<!-- Get the remaining classes -->
|
||||
<xsl:copy-of select="$compendium/class[name!=$Artificer and name!=$Barbarian and name!=$Bard and name!=$Cleric and
|
||||
name!=$Druid and name!=$Fighter and name!=$Monk and name!=$Paladin and name!=$Ranger and
|
||||
name!=$Rogue and name!=$Sorcerer and name!=$Warlock and name!=$Wizard]" />
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- Merges spell classes -->
|
||||
<xsl:template name="spells-extendable">
|
||||
<xsl:variable name="compendium" select="document(doc/@href)/compendium" />
|
||||
<xsl:variable name="spells" select="$compendium/spell" />
|
||||
|
||||
<xsl:for-each select="$spells">
|
||||
<xsl:choose>
|
||||
<!-- Check if there's a duplicate -->
|
||||
<xsl:when test="count($spells[name = current()/name]) > 1">
|
||||
<!-- Use the original spell that includes the "level" element -->
|
||||
<!-- Important: Duplicate spells should only contain "name" and "classes" elements -->
|
||||
<xsl:if test="level">
|
||||
<spell>
|
||||
<xsl:copy-of select="name" />
|
||||
<!-- <count_dupes><xsl:value-of select="count($spells[name = current()/name])"/></count_dupes> -->
|
||||
|
||||
<xsl:copy-of select="level" />
|
||||
<xsl:copy-of select="school" />
|
||||
<xsl:copy-of select="ritual" />
|
||||
<xsl:copy-of select="time" />
|
||||
<xsl:copy-of select="range" />
|
||||
<xsl:copy-of select="components" />
|
||||
<xsl:copy-of select="duration" />
|
||||
|
||||
<!-- Merge classes into comma-separated list -->
|
||||
<classes>
|
||||
<xsl:for-each select="$spells[name = current()/name]">
|
||||
<xsl:value-of select="classes"/>
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</classes>
|
||||
|
||||
<xsl:copy-of select="source" />
|
||||
<xsl:copy-of select="text" />
|
||||
<xsl:copy-of select="roll" />
|
||||
</spell>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<!-- If no duplicate, copy in the whole spell -->
|
||||
<xsl:otherwise>
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:transform>
|
||||
|
||||
Reference in New Issue
Block a user