diff --git a/changelog.md b/changelog.md
index 7f655cd3..9c75d290 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,6 +3,7 @@
## 13.0.36 - Le bonheur des zyglutes d'Illisys
- Les bon moments sont affichés en tooltip sur le moral
+- Les modifications de coeurs fonctionnent de nouveau
## 13.0.36 - Les rêveries d'Illisys
diff --git a/module/coeur/rdd-coeur.js b/module/coeur/rdd-coeur.js
index 5321adcb..36b41161 100644
--- a/module/coeur/rdd-coeur.js
+++ b/module/coeur/rdd-coeur.js
@@ -71,28 +71,32 @@ export class RdDCoeur {
}
static async applyCoeurChateauDormant(actor, message) {
- const newSuivants = foundry.utils.duplicate(actor.system.subacteurs.suivants)
let count = 0
- newSuivants.forEach(async link => {
- const suivant = game.actors.get(link.id)
- const prochainCoeur = link.prochainCoeur ?? 0;
- const coeurCourant = link.coeur ?? 0;
- const diff = prochainCoeur - coeurCourant
- if (diff < 0) {
- await actor.moralIncDec(-4);
- link.coeur = Math.max(0, coeurCourant - 1)
- link.prochainCoeur = link.coeur
- message.content += `
Votre cœur brisé pour ${suivant.name} vous fait perdre 4 points de moral, il vous reste ${link.coeur} points de Cœur.`
- count++
- }
- else if (diff > 0) {
- link.coeur = Math.min(prochainCoeur, 4)
- message.content += `
Votre cœur bat fort, vous avez maintenant ${link.coeur} points de Cœur pour ${suivant.name}.`
- link.prochainCoeur = link.coeur
- count++
- }
+ let ajustMoral = 0
+ const newSuivants = actor.system.subacteurs.suivants.filter(link => game.actors.get(link.id) != undefined)
+ .map(link => {
+ const suivant = game.actors.get(link.id)
+ const prochainCoeur = link.prochainCoeur ?? 0
+ const coeurCourant = link.coeur ?? 0
+ const diff = prochainCoeur - coeurCourant
+ if (diff < 0) {
+ ajustMoral -= 4
+ link.coeur = Math.max(0, coeurCourant - 1)
+ link.prochainCoeur = link.coeur
+ message.content += `
Votre cœur brisé pour ${suivant.name} vous fait perdre 4 points de moral, il vous reste ${link.coeur} points de Cœur.`
+ count++
+ }
+ if (diff > 0) {
+ link.coeur = Math.min(prochainCoeur, 4)
+ message.content += `
Votre cœur bat fort, vous avez maintenant ${link.coeur} points de Cœur pour ${suivant.name}.`
+ link.prochainCoeur = link.coeur
+ count++
+ }
+ return foundry.utils.duplicate(link)
+ })
+ if (ajustMoral != 0) {
+ await actor.moralIncDec(ajustMoral, 'Coeur')
}
- )
if (count > 0) {
await actor.update({ 'system.subacteurs.suivants': newSuivants });
}