Le coeur s'applique à ChâteauDormant

This commit is contained in:
2023-11-27 23:45:33 +01:00
parent 50db9ba709
commit 33ced5715d
9 changed files with 74 additions and 35 deletions

View File

@ -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']
@ -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}<br>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 });
}
}