diff --git a/changelog.md b/changelog.md
index 6ebec64d..90570f92 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,9 +1,13 @@
-# v11.2
-## v11.2.2 - Les tendres moments d'Akarlikarlikar
-- On peut maintenant avoir des points de cœur pour des suivants/compagnons
+# 11.2
+## 11.2.6 - Les réveils difficiles d'Akarlikarlikar
+- Les changements de points de Cœur sont temporaires jusqu'à fin Château Dormant
+- Fix: tous les petits fixes (feuille qui s'ouvre plus, compagnons animaux, potions qui bloquent Château Dormant, ...)
+
+## 11.2.2 - Les tendres moments d'Akarlikarlikar
+- On peut maintenant avoir des points de Cœur pour des suivants/compagnons
- diminuer les points de coeurs fait perdre du moral
- on peut proposer un tendre moment
- - les jets de volonté peuvent être ajustés selon les points de cœur
+ - les jets de volonté peuvent être ajustés selon les points de Cœur
- Fixes
- La résistance est de 1 par défaut pour les équipements
- Les armes de créatures sont de nouveau utilisables depuis les tokens
diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 029000a3..a252ab02 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -130,7 +130,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
this.html.find('.subacteur-coeur-toggle a').click(async event => {
const subActorIdactorId = RdDSheetUtility.getEventItemData(event, 'subactor-id')
- const coeurNombre = $(event.currentTarget).data('coeur-nombre')
+ const coeurNombre = $(event.currentTarget).data('numero-coeur')
RdDCoeur.toggleSubActeurCoeur(this.actor.id, subActorIdactorId, coeurNombre)
})
this.html.find('.subacteur-tendre-moment').click(async event => {
diff --git a/module/actor.js b/module/actor.js
index 548af358..2c4cfd7c 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -34,6 +34,7 @@ import { RdDEmpoignade } from "./rdd-empoignade.js";
import { ExperienceLog, XP_TOPIC } from "./actor/experience-log.js";
import { TYPES } from "./item.js";
import { RdDBaseActorSang } from "./actor/base-actor-sang.js";
+import { RdDCoeur } from "./coeur/rdd-coeur.js";
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
@@ -153,7 +154,7 @@ export class RdDActor extends RdDBaseActorSang {
let potions = this.itemTypes[TYPES.potion]
.filter(it => it.system.categorie.toLowerCase().includes('enchant') && !potion.system.prpermanent)
- const potionUpdates = Promise.all(potions.map(async potion => {
+ const potionUpdates = await Promise.all(potions.map(async potion => {
console.log(potion)
let nouveauReve = (potion.system.pr > 0) ? potion.system.pr - 1 : 0;
const message = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html`, {
@@ -270,6 +271,7 @@ export class RdDActor extends RdDBaseActorSang {
await this.setBonusPotionSoin(0);
await this.retourSust(message);
await this.$perteRevePotionsEnchantees();
+ await RdDCoeur.applyCoeurChateauDormant(this, message)
if (message.content != "") {
message.content = `A la fin Chateau Dormant, ${message.content}
Un nouveau jour se lève`;
ChatMessage.create(message);
@@ -2636,7 +2638,8 @@ export class RdDActor extends RdDBaseActorSang {
static $transformSubActeurSuivant = (suivant, link) => {
return mergeObject(RdDBaseActor.extractActorMin(suivant), {
ephemere: !suivant.prototypeToken.actorLink,
- coeur: link.coeur ?? 0
+ coeur: link.coeur ?? 0,
+ prochainCoeur: link.prochainCoeur ?? link.coeur ?? 0
})
};
@@ -2646,23 +2649,23 @@ export class RdDActor extends RdDBaseActorSang {
)
}
- getSuivant(actorId) {
- const suivant = this.system.subacteurs.suivants.find(it => it.id == actorId);
+ getSuivant(subActorId) {
+ const suivant = this.system.subacteurs.suivants.find(it => it.id == subActorId);
if (suivant) {
- return RdDActor.$transformSubActeurSuivant(game.actors.get(actorId), suivant);
+ return RdDActor.$transformSubActeurSuivant(game.actors.get(suivant.id), suivant);
}
return undefined
}
- getPointsCoeur(actorId) {
- return this.getSuivant(actorId)?.coeur ?? 0;
+ getPointsCoeur(subActorId) {
+ return this.getSuivant(subActorId)?.coeur ?? 0;
}
- async setPointsCoeur(actorId, coeur) {
- const amoureux = this.getSuivant(actorId);
+ async setPointsCoeur(subActorId, coeurs, options = { immediat: false }) {
+ const newSuivants = duplicate(this.system.subacteurs.suivants)
+ const amoureux = newSuivants.find(it => it.id == subActorId);
if (amoureux) {
- const suivants = this.system.subacteurs.suivants;
- let newSuivants = [...suivants.filter(it => it.id != actorId), { id: actorId, coeur: coeur }]
+ amoureux[options.immediat ? 'coeur' : 'prochainCoeur'] = coeurs
await this.update({ 'system.subacteurs.suivants': newSuivants });
}
}
diff --git a/module/coeur/rdd-coeur.js b/module/coeur/rdd-coeur.js
index 7fdf7f9c..e7940c91 100644
--- a/module/coeur/rdd-coeur.js
+++ b/module/coeur/rdd-coeur.js
@@ -53,22 +53,46 @@ export class RdDCoeur {
static async toggleSubActeurCoeur(actorId, subActorId, toggleCoeur) {
const actor = game.actors.get(actorId)
- if (ReglesOptionnelles.isUsing("chateau-dormant-gardien") && !actor.system.sommeil.nouveaujour) {
- ui.notifications.warn(`Les changements de points de coeur se font juste avant de gérer Château Dormant, juste avant de passer à un nouveau jour`)
- return
+ const amoureux = actor.getSuivant(subActorId)
+ if (toggleCoeur <= amoureux.coeur) {
+ if (toggleCoeur > amoureux.prochainCoeur) {
+ toggleCoeur = amoureux.coeur
+ }
+ else {
+ toggleCoeur = amoureux.coeur - 1
+ }
}
- const coeur = actor.getPointsCoeur(subActorId);
- if (toggleCoeur <= coeur) {
- // TODO: validation?
- await actor.moralIncDec(-4);
- actor.setPointsCoeur(subActorId, Math.max(0, coeur - 1));
- ChatMessage.create({
- whisper: ChatUtility.getWhisperRecipientsAndGMs(actor.name),
- content: `Perte de points de coeur arbitraire: ${actor.name} perd 4 points de moral, pour finir à ${actor.getMoralTotal()}.`
- });
+ else if (toggleCoeur <= amoureux.prochainCoeur) {
+ toggleCoeur = Math.max(amoureux.coeur, toggleCoeur - 1)
}
- else {
- actor.setPointsCoeur(subActorId, Math.min(4, toggleCoeur));
+ actor.setPointsCoeur(subActorId, Math.max(0, Math.min(toggleCoeur, 4)))
+ }
+
+ static async applyCoeurChateauDormant(actor, message) {
+ const newSuivants = 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++
+ }
+ }
+ )
+ if (count > 0) {
+ await actor.update({ 'system.subacteurs.suivants': newSuivants });
}
}
@@ -130,14 +154,13 @@ export class RdDCoeur {
? [infoCoeur.target, infoCoeur.source]
: [undefined, undefined]))
- const subActorId = partenaire?.actor.id;
if (amoureux.perteCoeur) {
- ui.notifications.warn(`Un point de coeur a déjà été perdu`)
+ ui.notifications.warn(`Le point de cœur a déjà été perdu`)
}
else if (amoureux.coeur > 0) {
const actor = game.actors.get(actorId)
if (actor.isOwner) {
- await actor.setPointsCoeur(subActorId, amoureux.coeur - 1)
+ await actor.setPointsCoeur(partenaire?.actor.id, amoureux.coeur - 1, { immediat: true })
amoureux.perteCoeur = true
RdDCoeur.addTagsInfoCoeur(infoCoeur)
}
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index 9f5a2170..e25a71d9 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -205,6 +205,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-type.html',
// Partials
'systems/foundryvtt-reve-de-dragon/templates/coeur/chat-effet-tendre-moment.hbs',
+ 'systems/foundryvtt-reve-de-dragon/templates/coeur/afficher-coeur.hbs',
'systems/foundryvtt-reve-de-dragon/templates/tirage/liste-resultats-recherche.hbs',
'systems/foundryvtt-reve-de-dragon/templates/time/horloge.hbs',
'systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs',
diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js
index 3484dc86..457c9153 100644
--- a/module/rolldata-ajustements.js
+++ b/module/rolldata-ajustements.js
@@ -83,7 +83,7 @@ export const referenceAjustements = {
coeur: {
isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isVolonte(rollData.selectedCarac),
isUsed: (rollData, actor) => rollData.use.coeur != undefined,
- getLabel: (rollData, actor) => 'Ajustement de coeur',
+ getLabel: (rollData, actor) => 'Ajustement de cœur',
getValue: (rollData, actor) => -2 * (rollData.use.coeur?.coeur ?? 0)
},
moralTotal: {
diff --git a/system.json b/system.json
index c117ba22..f17d000d 100644
--- a/system.json
+++ b/system.json
@@ -1,8 +1,8 @@
{
"id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
- "version": "11.2.5",
- "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-v11.2.5.zip",
+ "version": "11.2.6",
+ "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.2.6.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v11/system.json",
"changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md",
"compatibility": {
diff --git a/templates/actor/liens-suivants.hbs b/templates/actor/liens-suivants.hbs
index 540c1e13..1bccbdba 100644
--- a/templates/actor/liens-suivants.hbs
+++ b/templates/actor/liens-suivants.hbs
@@ -11,10 +11,10 @@
{{else}}
-
-
-
-
+ {{>'systems/foundryvtt-reve-de-dragon/templates/coeur/afficher-coeur.hbs' numero=1 courant=suivant.coeur prochain=suivant.prochainCoeur}}
+ {{>'systems/foundryvtt-reve-de-dragon/templates/coeur/afficher-coeur.hbs' numero=2 courant=suivant.coeur prochain=suivant.prochainCoeur}}
+ {{>'systems/foundryvtt-reve-de-dragon/templates/coeur/afficher-coeur.hbs' numero=3 courant=suivant.coeur prochain=suivant.prochainCoeur}}
+ {{>'systems/foundryvtt-reve-de-dragon/templates/coeur/afficher-coeur.hbs' numero=4 courant=suivant.coeur prochain=suivant.prochainCoeur}}
{{#if (gte suivant.coeur 1)}}
diff --git a/templates/coeur/afficher-coeur.hbs b/templates/coeur/afficher-coeur.hbs
new file mode 100644
index 00000000..9b6274ee
--- /dev/null
+++ b/templates/coeur/afficher-coeur.hbs
@@ -0,0 +1,12 @@
+{{log 'Cœur' numero courant prochain}}
+
+{{#if (and (lte numero courant) (lte numero prochain))}}
+
+{{else if (and (lte numero courant) (gt numero prochain))}}
+
+{{else if (and (gt numero courant) (lte numero prochain))}}
+
+{{else if (and (gt numero courant) (gt numero prochain))}}
+
+{{/if}}
+
diff --git a/templates/coeur/chat-effet-tendre-moment.hbs b/templates/coeur/chat-effet-tendre-moment.hbs
index 108d1123..bcaed8ae 100644
--- a/templates/coeur/chat-effet-tendre-moment.hbs
+++ b/templates/coeur/chat-effet-tendre-moment.hbs
@@ -4,7 +4,7 @@
{{#if (gt gainMoral 0)}}a apprécié ce tendre moment et gagné du moral
{{else}}n'a pas gagné de moral{{#if (gte coeur 1)}} et peut
- perdre un point de coeur
+ perdre un point de cœur
{{/if}}.
{{/if}}
diff --git a/templates/partial-roll-coeur.hbs b/templates/partial-roll-coeur.hbs
index 6c4c26fd..4b63c50b 100644
--- a/templates/partial-roll-coeur.hbs
+++ b/templates/partial-roll-coeur.hbs
@@ -1,5 +1,5 @@
-
+