From 2bc7b03323a95f60c57ea2a006e8a0b3985067ed Mon Sep 17 00:00:00 2001
From: Johannes Loher <johannes.loher@fg4f.de>
Date: Thu, 13 May 2021 16:41:16 +0200
Subject: [PATCH] Add functionality to track the minimum levels of spells for
 each mage class

---
 src/lang/de.json                               |  6 ++++++
 src/lang/en.json                               |  6 ++++++
 src/module/item/item-data.ts                   |  5 +++++
 src/system.json                                |  2 +-
 src/template.json                              |  5 +++++
 src/templates/sheets/item/spell-sheet.hbs      | 15 +++++++++++++++
 src/templates/sheets/item/tabs/description.hbs |  6 +++---
 src/templates/sheets/item/tabs/effects.hbs     |  4 ++--
 8 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/src/lang/de.json b/src/lang/de.json
index 28d765d..4cc4b57 100644
--- a/src/lang/de.json
+++ b/src/lang/de.json
@@ -113,6 +113,12 @@
     "DS4.SpellEffectRadius": "Effektradius",
     "DS4.SpellDuration": "Wirkdauer",
     "DS4.SpellCooldownDuration": "Abklingzeit",
+    "DS4.SpellMinimumLevelsHealer": "Zugangsstufe für Heiler",
+    "DS4.SpellMinimumLevelsHealerAbbr": "Zugangsstufe Hei",
+    "DS4.SpellMinimumLevelsWizard": "Zugangsstufe für Zauberer",
+    "DS4.SpellMinimumLevelsWizardAbbr": "Zugangsstufe Zau",
+    "DS4.SpellMinimumLevelsSorcerer": "Zugangsstufe für Schwarzmagier",
+    "DS4.SpellMinimumLevelsSorcererAbbr": "Zugangsstufe Sch",
     "DS4.SpellScrollPriceGold": "Schriftrollenpreis (Gold)",
     "DS4.ActorTypeCharacter": "Charakter",
     "DS4.ActorTypeCreature": "Kreatur",
diff --git a/src/lang/en.json b/src/lang/en.json
index 02598f8..29cb7eb 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -113,6 +113,12 @@
     "DS4.SpellEffectRadius": "Radius",
     "DS4.SpellDuration": "Duration",
     "DS4.SpellCooldownDuration": "Cooldown",
+    "DS4.SpellMinimumLevelsHealer": "Minimum level for Healers",
+    "DS4.SpellMinimumLevelsHealerAbbr": "Min lvl HEA",
+    "DS4.SpellMinimumLevelsWizard": "Minimum level for Wizards",
+    "DS4.SpellMinimumLevelsWizardAbbr": "Min lvl WIZ",
+    "DS4.SpellMinimumLevelsSorcerer": "Minimum level for Sorcerers",
+    "DS4.SpellMinimumLevelsSorcererAbbr": "Min lvl SRC",
     "DS4.SpellScrollPriceGold": "Scroll Price (Gold)",
     "DS4.ActorTypeCharacter": "Character",
     "DS4.ActorTypeCreature": "Creature",
diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts
index 7fa85fa..8e90673 100644
--- a/src/module/item/item-data.ts
+++ b/src/module/item/item-data.ts
@@ -107,6 +107,11 @@ export interface DS4SpellDataData extends DS4ItemDataDataBase, DS4ItemDataDataEq
     effectRadius: UnitData<DistanceUnit>;
     duration: UnitData<TemporalUnit>;
     cooldownDuration: UnitData<TemporalUnit>;
+    minimumLevels: {
+        healer: number | null;
+        wizard: number | null;
+        sorcerer: number | null;
+    };
     scrollPrice: number;
 }
 
diff --git a/src/system.json b/src/system.json
index b02807e..8ab132a 100644
--- a/src/system.json
+++ b/src/system.json
@@ -5,7 +5,7 @@
     "version": "0.6.0",
     "minimumCoreVersion": "0.7.9",
     "compatibleCoreVersion": "0.7.9",
-    "templateVersion": 4,
+    "templateVersion": 5,
     "author": "Johannes Loher, Gesina Schwalbe, Oliver Rümpelein, Siegfried Krug",
     "authors": [
         {
diff --git a/src/template.json b/src/template.json
index 29e9ca6..7a15b4a 100644
--- a/src/template.json
+++ b/src/template.json
@@ -214,6 +214,11 @@
                 "value": "",
                 "unit": "custom"
             },
+            "minimumLevels": {
+                "healer": null,
+                "wizard": null,
+                "sorcerer": null
+            },
             "scrollPrice": 0
         },
         "specialCreatureAbility": {
diff --git a/src/templates/sheets/item/spell-sheet.hbs b/src/templates/sheets/item/spell-sheet.hbs
index 2c3a0db..25e87f9 100644
--- a/src/templates/sheets/item/spell-sheet.hbs
+++ b/src/templates/sheets/item/spell-sheet.hbs
@@ -65,6 +65,21 @@
     {{> unitDatum data=data property='duration' localizeString='DS4.SpellDuration' unitType='temporal' }}
     {{> unitDatum data=data property='cooldownDuration' localizeString='DS4.SpellCooldownDuration' unitType='temporal'
     }}
+    <div class="side-property" title="{{localize 'DS4.SpellMinimumLevelsHealer'}}">
+        <label for="data.minimumLevels.healer">{{localize "DS4.SpellMinimumLevelsHealerAbbr"}}</label>
+        <input type="number" min="0" step="1" data-dtype="Number" name="data.minimumLevels.healer"
+            id="data.minimumLevels.healer" value="{{data.minimumLevels.healer}}" />
+    </div>
+    <div class="side-property" title="{{localize 'DS4.SpellMinimumLevelsWizard'}}">
+        <label for="data.minimumLevels.wizard">{{localize "DS4.SpellMinimumLevelsWizardAbbr"}}</label>
+        <input type="number" min="0" step="1" data-dtype="Number" name="data.minimumLevels.wizard"
+            id="data.minimumLevels.wizard" value="{{data.minimumLevels.wizard}}" />
+    </div>
+    <div class="side-property" title="{{localize 'DS4.SpellMinimumLevelsSorcerer'}}">
+        <label for="data.minimumLevels.sorcerer">{{localize "DS4.SpellMinimumLevelsSorcererAbbr"}}</label>
+        <input type="number" min="0" step="1" data-dtype="Number" name="data.minimumLevels.sorcerer"
+            id="data.minimumLevels.sorcerer" value="{{data.minimumLevels.sorcerer}}" />
+    </div>
     <div class="side-property">
         <label for="data.scrollPrice">{{localize "DS4.SpellScrollPriceGold"}}</label>
         <input type="number" min="0" max="9999" step="0.01" data-dtype="Number" name="data.scrollPrice"
diff --git a/src/templates/sheets/item/tabs/description.hbs b/src/templates/sheets/item/tabs/description.hbs
index b713938..9182122 100644
--- a/src/templates/sheets/item/tabs/description.hbs
+++ b/src/templates/sheets/item/tabs/description.hbs
@@ -1,9 +1,9 @@
-{{!-- 
+{{!--
 Render a description tab.
 Additional elements of the side-properties div can be handed over via the @partial-block.
 --}}
 
-<div class="tab flexrow" data-group="primary" data-tab="description">
+<div class="tab flexrow description" data-group="primary" data-tab="description">
     <div class="side-properties">
         {{#if isOwned}}
         {{#if (ne data.equipped undefined)}}<div class="side-property">
@@ -34,4 +34,4 @@ Additional elements of the side-properties div can be handed over via the @parti
     <div class="description" title="{{localize 'DS4.HeadingDescription'}}">
         {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
     </div>
-</div>
\ No newline at end of file
+</div>
diff --git a/src/templates/sheets/item/tabs/effects.hbs b/src/templates/sheets/item/tabs/effects.hbs
index a064313..03b99df 100644
--- a/src/templates/sheets/item/tabs/effects.hbs
+++ b/src/templates/sheets/item/tabs/effects.hbs
@@ -1,5 +1,5 @@
 {{!-- Tab for the items view to manage effects --}}
-<div class="tab details" data-group="primary" data-tab="effects">
+<div class="tab effects" data-group="primary" data-tab="effects">
     <ol class="effects-list">
         <li class="effect flexrow effect-header">
             <div class="effect-image"></div>
@@ -21,4 +21,4 @@
         </li>
         {{/each}}
     </ol>
-</div>
\ No newline at end of file
+</div>