From 0c7a0e413d4d9dcb4930c52d41fcc1934ce4b1e4 Mon Sep 17 00:00:00 2001
From: sladecraven <sylvain@lahiette.com>
Date: Fri, 5 Feb 2021 09:36:42 +0100
Subject: [PATCH] #87 Initiative premier round

---
 module/rdd-utility.js                | 37 ++++++++++++++--------------
 system.json                          |  4 +--
 template.json                        |  3 ++-
 templates/enum-initpremierround.html | 18 ++++++++++++++
 templates/item-arme-sheet.html       |  8 ++++++
 5 files changed, 49 insertions(+), 21 deletions(-)
 create mode 100644 templates/enum-initpremierround.html

diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index aecf6742..7a05c7a3 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -65,22 +65,23 @@ const tableCaracDerivee = {
 
   /* -------------------------------------------- */
   const premierRoundInit = [ 
-    { type: 'competence', pattern: 'hast', init: 3.90},
-    { type: 'competence', pattern: 'lance', init: 3.85},
-    { type: 'arme', pattern: 'bâton', init: 3.80},
-    { type: 'arme', pattern: 'double dragonne', init: 3.75},
-    { type: 'arme', pattern: 'esparlongue', init: 3.70},
-    { type: 'arme', pattern: 'pée dragonne', init: 3.65},
-    { type: 'arme', pattern: 'bâtarde', init: 3.60},
-    { type: 'arme', pattern: 'cyane', init: 3.55},
-    { type: 'arme', pattern: 'sorde', init: 3.50},
-    { type: 'arme', pattern: 'grande hache', init: 3.45},
-    { type: 'arme', pattern: 'bataille', init: 3.40},
-    { type: 'arme', pattern: 'gnome', init: 3.35},
-    { type: 'arme', pattern: 'masse', init: 3.30},
-    { type: 'arme', pattern: 'gourdin', init: 3.25},
-    { type: 'competence', pattern: 'fléau', init: 3.20},
-    { type: 'arme', pattern: 'dague', init: 3.15},
+    { pattern: 'hast', init: 3.90},
+    { pattern: 'lance', init: 3.85},
+    { pattern: 'baton', init: 3.80},
+    { pattern: 'doubledragonne', init: 3.75},
+    { pattern: 'esparlongue', init: 3.70},
+    { pattern: 'epeedragonne', init: 3.65},
+    { pattern: 'epeebatarde', init: 3.60},
+    { pattern: 'epeecyane', init: 3.55},
+    { pattern: 'epeesorde', init: 3.50},
+    { pattern: 'grandehache', init: 3.45},
+    { pattern: 'bataille', init: 3.40},
+    { pattern: 'epeegnome', init: 3.35},
+    { pattern: 'masse', init: 3.30},
+    { pattern: 'gourdin', init: 3.25},
+    { pattern: 'fléau', init: 3.20},
+    { pattern: 'dague', init: 3.15},
+    { pattern: 'autre', init: 3.10},
  ];
 
 /* -------------------------------------------- */
@@ -214,6 +215,7 @@ export class RdDUtility {
       'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html',
       'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-vehicule.html',
       'systems/foundryvtt-reve-de-dragon/templates/enum-competence.html',
+      'systems/foundryvtt-reve-de-dragon/templates/enum-initpremierround.html',
       'systems/foundryvtt-reve-de-dragon/templates/enum-rarete.html',
       'systems/foundryvtt-reve-de-dragon/templates/sort-draconic.html',
       'systems/foundryvtt-reve-de-dragon/templates/sort-tmr.html',
@@ -699,8 +701,7 @@ export class RdDUtility {
           //console.log("Parsed !!!", combatant, initDone, game.combat.current, arme);
           if ( arme && arme.type == "arme" ) {
             for (let initData of premierRoundInit) {
-              if ( ( initData == 'competence' && arme.data.competence.toLowerCase().includes(initData.pattern)) || 
-                    (arme.name.toLowerCase().includes(initData.pattern)) )  {
+              if ( arme.data.initpremierround.toLowerCase().includes(initData.pattern) ) {
                 let msg = `<h4>L'initiative de ${combatant.actor.name} a été modifiée !</h4>
                       <hr>
                       <div>
diff --git a/system.json b/system.json
index 4627eaaa..51b740bd 100644
--- a/system.json
+++ b/system.json
@@ -2,11 +2,11 @@
   "name": "foundryvtt-reve-de-dragon",
   "title": "Rêve de Dragon",
   "description": "Rêve de Dragon RPG for FoundryVTT",
-  "version": "1.3.14",
+  "version": "1.3.15",
   "manifestPlusVersion": "1.0.0",
   "minimumCoreVersion": "0.7.5",
   "compatibleCoreVersion": "0.7.9",
-  "templateVersion": 89,
+  "templateVersion": 90,
   "author": "LeRatierBretonnien",
   "authors": [
     { 
diff --git a/template.json b/template.json
index 681d182f..79ce365f 100644
--- a/template.json
+++ b/template.json
@@ -602,7 +602,8 @@
     "portee_extreme": 0,
     "rapide": false,
     "deuxmains": false,
-    "unemain": false
+    "unemain": false,
+    "initpremierround": ""
   },
   "munition": {
     "description": "",
diff --git a/templates/enum-initpremierround.html b/templates/enum-initpremierround.html
new file mode 100644
index 00000000..6408d711
--- /dev/null
+++ b/templates/enum-initpremierround.html
@@ -0,0 +1,18 @@
+<option value="hast">Armes d'Hast</option>
+<option value="lance">Lance</option>
+<option value="baton">Bâton</option>
+<option value="doubledragonne">Double Dragonne</option>
+<option value="esparlongue">Esparlongue</option>
+<option value="epeedragonne">Epée Dragonne</option>
+<option value="epeebatarde">Epée Bâtarde</option>
+<option value="epeecyane">Epée Cyane</option>
+<option value="epeesorde">Epée Sorde</option>
+<option value="grandehache">Grande Hache</option>
+<option value="hachebataille">Hache de Bataille</option>
+<option value="epeegnome">Epée Gnome</option>
+<option value="masse">Masse</option>
+<option value="gourdin">Gourdin</option>
+<option value="fleau">Fléaux</option>
+<option value="dague">Dague</option>
+<option value="armenaturelle">Armes Naturelles</option>
+<option value="autre">Autres</option>
diff --git a/templates/item-arme-sheet.html b/templates/item-arme-sheet.html
index 0fd1743e..3d5f9a69 100644
--- a/templates/item-arme-sheet.html
+++ b/templates/item-arme-sheet.html
@@ -84,6 +84,14 @@
         <label for="penetration">Nombre d'Ecailles d'Efficacité </label>
         <input class="attribute-value" type="text" name="data.ecaille_efficacite" value="{{data.ecaille_efficacite}}" data-dtype="Number"/>
       </div>
+      <div class="form-group">
+        <label for="penetration">Classe d'initiative au premier round (mêlée seulement) </label>
+        <select name="data.initpremierround" id="initpremierround" data-dtype="String">
+          {{#select data.initpremierround}}
+          {{>"systems/foundryvtt-reve-de-dragon/templates/enum-initpremierround.html"}}
+          {{/select}}
+        </select>
+      </div>      
       <div class="flexcol">
         <span><label>Description : </label></span>
         <div class="form-group editor">