#87 - Init du premier round
This commit is contained in:
		| @@ -63,6 +63,26 @@ const tableCaracDerivee = { | ||||
|   32: { xp: 180, poids: "1501-2000", plusdom:+11, sconst: 10, sust: 17 } | ||||
| } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   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}, | ||||
|  ]; | ||||
|  | ||||
| /* -------------------------------------------- */ | ||||
| function _buildAllSegmentsFatigue(max) { | ||||
|   const cycle = [5, 2, 4, 1, 3, 0]; | ||||
| @@ -665,6 +685,37 @@ export class RdDUtility { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static processPremierRoundInit() { | ||||
|     // Check if we have the whole init ! | ||||
|     if ( game.user.isGM) { | ||||
|       let initDone = true; | ||||
|       for( let combatant of game.combat.data.combatants) {  | ||||
|         if ( !combatant.initiative ) initDone = false; | ||||
|       } | ||||
|       if (initDone && game.combat.current.round == 1) { // Premier round ! | ||||
|         for( let combatant of game.combat.data.combatants) {  | ||||
|           let arme = combatant.initiativeData.arme; | ||||
|           //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)) )  { | ||||
|                 let msg = `<h4>L'initiative de ${combatant.actor.name} a été modifiée !</h4> | ||||
|                       <hr> | ||||
|                       <div> | ||||
|                         Etant donné son ${arme.name}, son initative pour ce premier round est désormais de ${initData.init}. | ||||
|                       </div>` | ||||
|                 ChatMessage.create( { content: msg } ); | ||||
|                 game.combat.setInitiative(combatant._id, initData.init);  | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|    | ||||
|   /* -------------------------------------------- */ | ||||
|   static rollInitiativeCompetence(combatantId, arme) { | ||||
|     const combatant = game.combat.getCombatant(combatantId); | ||||
| @@ -706,7 +757,9 @@ export class RdDUtility { | ||||
|     } | ||||
|     let malus = actor.getEtatGeneral(); // Prise en compte état général  | ||||
|     // Cas des créatures et entités vs personnages | ||||
|     let rollFormula = initOffset + "+ ( (" + RdDUtility.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)"; | ||||
|     let rollFormula = initOffset + "+ ( (" + RdDUtility.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)";     | ||||
|     // Garder la trace de l'arme/compétence utilisée pour l'iniative | ||||
|     combatant.initiativeData = { arme: arme } // pour reclasser l'init au round 0 | ||||
|     game.combat.rollInitiative(combatantId, rollFormula); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user