Gestion des signes draconiques #455
@@ -343,13 +343,11 @@ export class RdDActor extends Actor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  async _recupereChance() {
 | 
					  async _recupereChance() {
 | 
				
			||||||
    // On ne récupère un point de chance que si aucun appel à la chance dans la journée
 | 
					    // On ne récupère un point de chance que si aucun appel à la chance dans la journée
 | 
				
			||||||
    if (this.getFlag('foundryvtt-reve-de-dragon', 'utilisationChance')) {
 | 
					    if (this.getChanceActuel() < this.getChance() && !this.getFlag('foundryvtt-reve-de-dragon', 'utilisationChance')) {
 | 
				
			||||||
      // Nouveau jour, suppression du flag
 | 
					        await this.chanceActuelleIncDec(1);
 | 
				
			||||||
      await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
      await this.chanceActuelleIncDec(1);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    // Nouveau jour, suppression du flag
 | 
				
			||||||
 | 
					    await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* -------------------------------------------- */
 | 
					  /* -------------------------------------------- */
 | 
				
			||||||
@@ -651,14 +649,14 @@ export class RdDActor extends Actor {
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const actorData = Misc.data(this);
 | 
					    const tplData = Misc.templateData(this);
 | 
				
			||||||
    if (caracName == "reve") {
 | 
					    if (caracName == "reve") {
 | 
				
			||||||
      if (caracValue > Misc.toInt(actorData.data.reve.seuil.value)) {
 | 
					      if (caracValue > Misc.toInt(tplData.reve.seuil.value)) {
 | 
				
			||||||
        this.setPointsDeSeuil(caracValue);
 | 
					        this.setPointsDeSeuil(caracValue);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (caracName == "chance") {
 | 
					    if (caracName == "chance") {
 | 
				
			||||||
      if (caracValue > Misc.toInt(actorData.data.compteurs.chance.value)) {
 | 
					      if (caracValue > Misc.toInt(tplData.compteurs.chance.value)) {
 | 
				
			||||||
        this.setPointsDeChance(caracValue);
 | 
					        this.setPointsDeChance(caracValue);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -2260,9 +2258,6 @@ export class RdDActor extends Actor {
 | 
				
			|||||||
  /* -------------------------------------------- */
 | 
					  /* -------------------------------------------- */
 | 
				
			||||||
  async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
 | 
					  async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
 | 
				
			||||||
    // Stocke si utilisation de la chance
 | 
					    // Stocke si utilisation de la chance
 | 
				
			||||||
    await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance');
 | 
					 | 
				
			||||||
    await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
 | 
					    let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
 | 
				
			||||||
    const dialog = await RdDRoll.create(this, rollData,
 | 
					    const dialog = await RdDRoll.create(this, rollData,
 | 
				
			||||||
      { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
 | 
					      { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
 | 
				
			||||||
@@ -2282,6 +2277,7 @@ export class RdDActor extends Actor {
 | 
				
			|||||||
  async _appelChanceResult(rollData, onSuccess = () => { }, onEchec = () => { }) {
 | 
					  async _appelChanceResult(rollData, onSuccess = () => { }, onEchec = () => { }) {
 | 
				
			||||||
    await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
 | 
					    await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
 | 
				
			||||||
    if (rollData.rolled.isSuccess) {
 | 
					    if (rollData.rolled.isSuccess) {
 | 
				
			||||||
 | 
					      await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true);
 | 
				
			||||||
      await this.chanceActuelleIncDec(-1);
 | 
					      await this.chanceActuelleIncDec(-1);
 | 
				
			||||||
      onSuccess();
 | 
					      onSuccess();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -2291,11 +2287,8 @@ export class RdDActor extends Actor {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* -------------------------------------------- */
 | 
					  /* -------------------------------------------- */
 | 
				
			||||||
  async chanceActuelleIncDec(value, limit = true) {
 | 
					  async chanceActuelleIncDec(value) {
 | 
				
			||||||
    chance = Math.max(Misc.templateData(this).compteurs.chance.value + value, 0);
 | 
					    const chance = Math.min(this.getChance(), Math.max(this.getChanceActuel() + value, 0));
 | 
				
			||||||
    if (limit) {
 | 
					 | 
				
			||||||
      chance = Math.min(chance.value, this.getChance())
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    await this.updateCompteurValue("chance", chance);
 | 
					    await this.updateCompteurValue("chance", chance);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user