| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -31,8 +31,9 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  static async create(data, options) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    // Case of compendium global import
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (data instanceof Array)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (data instanceof Array) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return super.create(data, options);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    // If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (data.items) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return super.create(data, options);
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -126,15 +127,18 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async performRoll(rollData) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let rolled = await RdDResolutionTable.roll(rollData.caracValue, rollData.finalLevel);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    //rolled.isPart = true; // Pour tester le particulières
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    rollData.rolled = rolled; //  garder le résultat
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    //console.log("performRoll", rollData, rolled)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if ( !rollData.attackerRoll) // Store in the registry if not a defense roll
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      game.system.rdd.rollDataHandler[this.data._id] = rollData; 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async performRoll(rollData, attacker = undefined) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (rolled.isPart && rollData.arme && !rollData.attackerRoll) { // Réussite particulière avec attaque -> choix !
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    //  garder le résultat
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    rollData.rolled = await RdDResolutionTable.roll(rollData.caracValue, rollData.finalLevel);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    //console.log("performRoll", rollData)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if ( !rollData.attackerRoll) {// Store in the registry if not a defense roll
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      game.system.rdd.rollDataHandler[this.data._id] = rollData; 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (rollData.rolled.isPart && rollData.arme && !rollData.attackerRoll) { // Réussite particulière avec attaque -> choix !
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      let message = "<strong>Réussite particulière en attaque</strong>";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      message = message + "<br><a class='chat-card-button' id='particuliere-attaque' data-mode='force' data-attackerid='" + this.data._id + "'>Attaquer en Force</a>";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      // Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -144,19 +148,18 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      ChatMessage.create( {content : message, whisper: ChatMessage.getWhisperRecipients( this.name ) } );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    } else { 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      this.continueRoll(rollData);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      this.continueRoll(rollData, attacker);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async continueRoll(rollData) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async continueRoll(rollData, attacker = undefined) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let rolled = rollData.rolled;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let result = rolled.roll;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let quality = rolled.quality
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    // Manage weapon categories when parrying (cf. page 115 )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let need_resist = false; // Do we need to make resistance roll for defender ?
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (rollData.arme && rollData.attackerRoll) { // Manage parade depeding on weapon type, and change roll results
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (rollData.arme && rollData.attackerRoll) { // Manage parade depending on weapon type, and change roll results
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      let attCategory = RdDUtility.getArmeCategory(rollData.attackerRoll.arme);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      let defCategory = RdDUtility.getArmeCategory(rollData.arme);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      if (defCategory == "bouclier")
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -166,7 +169,7 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      if (attCategory.match("epee") && (defCategory == "hache" || defCategory == "lance"))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        need_resist = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (this.data.type != 'entite' && (this.data.data.sante.sonne.value || rollData.particuliereAttaque == "finesse")) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (!this.isEntiteCauchemar() && (this.data.data.sante.sonne.value || rollData.particuliereAttaque == "finesse")) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      rollData.needSignificative = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -183,18 +186,21 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      explications = ""
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				       // In case of fight, replace the message per dommages + localization. it indicates if result is OK or not
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      if (rollData.attackerRoll) { // Defense case !
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (rollData.needSignificative && rolled.isSign ) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          explications += "<br><strong>Attaque parée/esquivée !</strong>";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        } else if ( !rollData.needSignificative && rolled.isSuccess) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (rolled.isSign || (!rollData.needSignificative && rolled.isSuccess)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          explications += "<br><strong>Attaque parée/esquivée !</strong>";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        } else  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          explications += "<br><strong>Esquive/Parade échouée, encaissement !</strong>";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (rollData.needSignificative)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            explications += "Significative nécessaire!";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          encaisser = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            explications += " Significative nécessaire!";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        encaisser = rollData.needSignificative ? !rolled.isSign : !rolled.isSuccess;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      } else { // This is the attack roll!
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (rolled.isSuccess) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          let target = this.getTarget();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (await this.targetEntiteNonAccordee(target, 'avant-defense')) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          // Message spécial pour la rapidité, qui reste difficile à gérer automatiquement
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if ( rollData.particuliereAttaque == 'rapidite') {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            ChatMessage.create( { content: "Vous avez attaqué en Rapidité. Ce cas n'est pas géré autmatiquement, donc suivez les directives de votre MJ pour gérer ce cas.", 
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -203,14 +209,14 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          rollData.domArmePlusDom = this._calculBonusDommages(rollData.selectedCarac, rollData.arme, rollData.particuliereAttaque == 'force' );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          rollData.degats = new Roll("2d10").roll().total + rollData.domArmePlusDom;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          rollData.loc = RdDUtility.getLocalisation();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          for (let target of game.user.targets) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            rollData.mortalite = (rollData.mortalite) ? rollData.mortalite : "mortel";// Force default
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            rollData.mortalite = (target.actor.data.type == 'entite') ? "cauchemar" : rollData.mortalite;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            console.log("Mortalité : ", rollData.mortalite, target.actor.data.type);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (target)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            rollData.mortalite = RdDActor._calculMortaliteEncaissement(rollData, target);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            defenseMsg = RdDUtility.buildDefenseChatCard(this, target, rollData);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            explications += "<br><strong>Cible</strong> : " + target.actor.data.name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          explications += "<br>Dégâts : " + rollData.degats + "<br>Localisation : " + rollData.loc.label;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          explications += "<br>Encaissement : " + rollData.degats + "<br>Localisation : " + rollData.loc.label;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        } else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          explications = "<br>Echec ! Pas de dégâts";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -256,10 +262,16 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    // Get damages!
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (encaisser) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      this.encaisserDommages(rollData.attackerRoll);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      this.encaisserDommages(rollData.attackerRoll, attacker);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  static _calculMortaliteEncaissement(rollData, target) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    const mortalite = target.actor.isEntiteCauchemar() ? "cauchemar" : (rollData.mortalite ? rollData.mortalite : "mortel");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    console.log("Mortalité : ", mortalite, target.actor.data.type);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return mortalite;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  _calculBonusDommages(carac, arme, isForce=false) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if ( arme.name.toLowerCase() == "esquive") return 0; // Specific case management
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -919,6 +931,9 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async santeIncDec(name, inc, isCritique = false) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    const sante = duplicate(this.data.data.sante);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let data = sante[name];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (data==undefined) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let minValue = 0;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (this.type == 'personnage') {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      // TODO: les animaux/humanoïdes on théoriquement aussi un sconst, mais la SPA n'est pas passé par là
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -1221,7 +1236,7 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async rollCompetence( name, armeItem=undefined, attackerRoll=undefined ) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async rollCompetence( name, armeItem=undefined, attackerRoll=undefined, attacker = undefined) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let competence = RdDUtility.findCompetence( this.data.items, name);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    console.log("rollCompetence !!!", competence, armeItem, attackerRoll);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    // Common rollData values
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -1275,12 +1290,24 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (rollData.arme)  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      new RdDRollDialog("arme", html, rollData, this ).render(true);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      if (await this.targetEntiteNonAccordee(this.getTarget(), 'avant-attaque')) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      new RdDRollDialog("arme", html, rollData, this, attacker).render(true);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    } else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      new RdDRollDialog("competence", html, rollData, this ).render(true);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      new RdDRollDialog("competence", html, rollData, this, attacker).render(true);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  getTarget() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (game.user.targets && game.user.targets.size == 1) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      for (let target of game.user.targets) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return target;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return undefined;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async equiperObjet( itemID )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -1321,7 +1348,13 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async encaisserDommages( attackerRoll ) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async encaisserDommages( attackerRoll, attacker = undefined ) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    console.log("encaisserDommages", attackerRoll )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    const armure = this.computeArmure( attackerRoll.loc, attackerRoll.domArmePlusDom);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let degatsReel = attackerRoll.degats - armure;
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -1356,17 +1389,17 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  parerAttaque( attackerRoll, armeId )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  parerAttaque( attackerRoll, armeId, attacker = undefined )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let armeItem = this.getOwnedItem(armeId); // Item.data.data !
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    console.log("Going to PARY !!!!!!!!!", armeItem, attackerRoll.diffLibre);    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.rollCompetence(  armeItem.data.data.competence, armeItem.data, attackerRoll );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.rollCompetence(  armeItem.data.data.competence, armeItem.data, attackerRoll, attacker);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  esquiverAttaque( attackerRoll )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  esquiverAttaque( attackerRoll, attacker = undefined )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.rollCompetence( "esquive", undefined, attackerRoll );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.rollCompetence( "esquive", undefined, attackerRoll, attacker );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -------------------------------------------- */  
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -1377,6 +1410,72 @@ export class RdDActor extends Actor {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return data;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* -- entites -- */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  /* retourne true si on peut continuer, false si on ne peut pas continuer */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async targetEntiteNonAccordee(target, when='avant-encaissement')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (target)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return !await this.accorder(target.actor, when);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async accorder(entite, when = 'avant-encaissement')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (when != game.settings.get("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				     || !entite.isEntiteCauchemar()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				     || entite.isEntiteCauchemarAccordee(this)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let rolled = await RdDResolutionTable.roll( this.getReveActuel(), - Number(entite.data.data.carac.niveau.value));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let message = {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      content: "Jet de points actuels de rêve à " + rolled.finalLevel + RdDResolutionTable.explain(rolled) + "<br>",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      whisper: ChatMessage.getWhisperRecipients(this.name)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    };
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (rolled.isSuccess) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      await entite.setEntiteReveAccordee(this);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      message.content += this.name + " s'est accordé avec " + entite.name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      message.content+= this.name + " n'est pas accordé avec " + entite.name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    ChatMessage.create( message );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return rolled.isSuccess;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  isEntiteCauchemar()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return this.data.type == 'entite';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  isEntiteCauchemarAccordee(attaquant)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (!this.isEntiteCauchemar()) { return true; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let resonnance = this.data.data.sante.resonnance;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return (resonnance.actors.find(it => it == attaquant._id));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  async setEntiteReveAccordee(attaquant)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (!this.isEntiteCauchemar()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      ui.notifications.error("Impossible de s'accorder à " + this.name + ": ce n'est pas une entite de cauchemer/rêve");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let resonnance = duplicate(this.data.data.sante.resonnance);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (resonnance.actors.find(it => it == attaquant._id)){
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      // déjà accordé
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    resonnance.actors.push(attaquant._id);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    await this.update( {"data.sante.resonnance": resonnance});
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					
					| 
						 
							
							
							
						 
					 | 
				
			
			 | 
			 | 
			
				 
 |