diff --git a/module/actor.js b/module/actor.js index 777d20a7..e0d09e07 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1758,7 +1758,7 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async rollAppelChance( ) + async rollAppelChance( onSuccess = () => {}, onEchec= ()=>{}) { let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' }; const dialog = await RdDRoll.create(this, rollData, @@ -1768,7 +1768,9 @@ export class RdDActor extends Actor { label: 'Appel à la chance', callbacks: [ this.createCallbackExperience(), - { action: r => this._appelChanceResult(r) } + { action: r => this._appelChanceResult(r) }, + { condition: r=> r.rolled.isSuccess, action: r => onSuccess() }, + { condition: r=> r.rolled.isEchec, action: r => onEchec() } ] } ); @@ -1789,6 +1791,21 @@ export class RdDActor extends Actor { chance.value = Math.max(chance.value + value, 0); await this.update( {"data.compteurs.chance": chance } ); } + + /* -------------------------------------------- */ + async appelDestinee( onSuccess = () => {}, onEchec= ()=>{}) { + if (this.data.data.compteurs.destinee?.value ?? 0 >0 ) { + ChatMessage.create({content: `${this.name} a fait appel à la Destinée !` }); + let destinee = duplicate(this.data.data.compteurs.destinee); + destinee.value = destinee.value - 1; + await this.update( {"data.compteurs.destinee": destinee } ); + onSuccess(); + } + else { + onEchec(); + } + } + /* -------------------------------------------- */ ajustementAstrologique() {