Fix: problème de nombre d'utilisations
This commit is contained in:
		| @@ -39,35 +39,31 @@ export class RdDCombatManager extends Combat { | ||||
|  | ||||
|   static init() { | ||||
|     /* -------------------------------------------- */ | ||||
|     Hooks.on("getCombatTrackerEntryContext", (html, options) => { | ||||
|       RdDCombatManager.pushInitiativeOptions(html, options); | ||||
|     }); | ||||
|     Hooks.on("preDeleteCombat", (combat, html, id) => { | ||||
|       combat.onPreDeleteCombat() | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   cleanItemUse() { | ||||
|     for (let turn of this.turns) { | ||||
|       turn.actor.resetItemUse() | ||||
|     } | ||||
|     Hooks.on("getCombatTrackerEntryContext", (html, options) => { RdDCombatManager.pushInitiativeOptions(html, options); }); | ||||
|     Hooks.on("updateCombat", (combat, change, options, userId) => { RdDCombat.onUpdateCombat(combat, change, options, userId) }); | ||||
|     Hooks.on("preDeleteCombat", (combat, html, id) => { combat.onPreDeleteCombat() }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async nextRound() { | ||||
|     this.cleanItemUse(); | ||||
|     await this.finDeRound(); | ||||
|     return await super.nextRound(); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async onPreDeleteCombat() { | ||||
|     await this.finDeRound({ terminer: true }); | ||||
|     if (Misc.isUniqueConnectedGM()) { | ||||
|       await this.finDeRound({ terminer: true }); | ||||
|       ChatUtility.removeChatMessageContaining(`<div data-combatid="${this.id}" data-combatmessage="actor-turn-summary">`) | ||||
|       game.messages.filter(m => ChatUtility.getMessageData(m, 'attacker-roll') != undefined && ChatUtility.getMessageData(m, 'defender-roll') != undefined) | ||||
|         .forEach(it => it.delete()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async finDeRound(options = { terminer: false }) { | ||||
|     this.turns.forEach(turn => turn.actor.resetItemUse()); | ||||
|  | ||||
|     for (let combatant of this.combatants) { | ||||
|       if (combatant.actor) { | ||||
|         await combatant.actor.finDeRound(options); | ||||
| @@ -144,9 +140,8 @@ export class RdDCombatManager extends Combat { | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static calculInitiative(niveau, caracValue, bonusEcaille = 0) { | ||||
|     let base = niveau + Math.floor(caracValue / 2); | ||||
|     base += bonusEcaille; | ||||
|   static calculInitiative(niveau, caracValue, bonus = 0) { | ||||
|     let base = niveau + Math.floor(caracValue / 2) + bonus; | ||||
|     return "1d6" + (base >= 0 ? "+" : "") + base; | ||||
|   } | ||||
|  | ||||
| @@ -420,18 +415,11 @@ export class RdDCombatManager extends Combat { | ||||
| /* -------------------------------------------- */ | ||||
| export class RdDCombat { | ||||
|  | ||||
|   static init() { | ||||
|     Hooks.on("updateCombat", (combat, change, options, userId) => { RdDCombat.onUpdateCombat(combat, change, options, userId) }); | ||||
|     Hooks.on("preDeleteCombat", (combat, options, userId) => { RdDCombat.onPreDeleteCombat(combat, options, userId); }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static onSocketMessage(sockmsg) { | ||||
|     switch (sockmsg.msg) { | ||||
|       case "msg_encaisser": | ||||
|         return RdDCombat.onMsgEncaisser(sockmsg.data); | ||||
|       case "msg_defense": | ||||
|         return RdDCombat.onMsgDefense(sockmsg.data); | ||||
|       case "msg_encaisser": return RdDCombat.onMsgEncaisser(sockmsg.data); | ||||
|       case "msg_defense": return RdDCombat.onMsgDefense(sockmsg.data); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -442,16 +430,6 @@ export class RdDCombat { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static onPreDeleteCombat(combat, options, userId) { | ||||
|     if (Misc.isUniqueConnectedGM()) { | ||||
|       combat.cleanItemUse(); | ||||
|       ChatUtility.removeChatMessageContaining(`<div data-combatid="${combat.id}" data-combatmessage="actor-turn-summary">`) | ||||
|       game.messages.filter(m => ChatUtility.getMessageData(m, 'attacker-roll') != undefined && ChatUtility.getMessageData(m, 'defender-roll') != undefined) | ||||
|         .forEach(it => it.delete()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static combatNouveauTour(combat) { | ||||
|     if (Misc.isUniqueConnectedGM()) { | ||||
| @@ -756,15 +734,6 @@ export class RdDCombat { | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async attaque(competence, arme) { | ||||
|     // const nonIncarnee = this.defender.isEntite([ENTITE_NONINCARNE]) | ||||
|     // const blurette = this.defender.isEntite([ENTITE_BLURETTE]) | ||||
|     // if (nonIncarnee || blurette) { | ||||
|     //   ChatMessage.create( { | ||||
|     //     content: `<strong>La cible est ${nonIncarnee ? 'non incarnée' : 'une blurette'}. | ||||
|     //       Il est impossible de l'atteindre.`, | ||||
|     //     whisper: ChatMessage.getWhisperRecipients("GM")}) | ||||
|     // } | ||||
|  | ||||
|     if (!await this.attacker.accorder(this.defender, 'avant-attaque')) { | ||||
|       return; | ||||
|     } | ||||
| @@ -970,9 +939,8 @@ export class RdDCombat { | ||||
|   /* -------------------------------------------- */ | ||||
|   _filterArmesParade(defender, competence) { | ||||
|     let items = defender.items.filter(it => RdDItemArme.isArmeUtilisable(it) || RdDItemCompetenceCreature.isCompetenceParade(it)) | ||||
|     for (let item of items) { | ||||
|       item.system.nbUsage = defender.getItemUse(item.id); // Ajout du # d'utilisation ce round   | ||||
|     } | ||||
|     items.forEach(item => item.system.nbUsage = defender.getItemUse(item.id)); // Ajout du # d'utilisation ce round   | ||||
|  | ||||
|     switch (competence.system.categorie) { | ||||
|       case 'tir': | ||||
|       case 'lancer': | ||||
|   | ||||
| @@ -180,7 +180,6 @@ export class SystemReveDeDragon { | ||||
|     RdDUtility.init(); | ||||
|     RdDDice.init(); | ||||
|     RdDCommands.init(); | ||||
|     RdDCombat.init(); | ||||
|     RdDCombatManager.init(); | ||||
|     RdDTokenHud.init(); | ||||
|     RdDBaseActor.init(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user