Correction des updates multiples
Utilisation d'un render sur timer pour forcer le réaffichage
This commit is contained in:
310
module/actor.js
310
module/actor.js
@@ -418,7 +418,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
async _recupereMoralChateauDormant(message) {
|
||||
await this.update({ 'system.compteurs.bonmoments': [] }, { render: false })
|
||||
await this.update({ 'system.compteurs.bonmoments': [] })
|
||||
|
||||
if (!ReglesOptionnelles.isUsing("recuperation-moral")) { return }
|
||||
|
||||
@@ -498,14 +498,14 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async remiseANeuf() {
|
||||
await this.removeEffects(e => !e.statuses?.has(STATUSES.StatusDemiReve), { render: false })
|
||||
await this.supprimerBlessures(it => true, { render: false })
|
||||
await this.removeEffects(e => !e.statuses?.has(STATUSES.StatusDemiReve))
|
||||
await this.supprimerBlessures(it => true)
|
||||
await this.update({
|
||||
'system.sante.endurance.value': this.system.sante.endurance.max,
|
||||
'system.sante.vie.value': this.system.sante.vie.max,
|
||||
'system.sante.fatigue.value': 0,
|
||||
'system.compteurs.ethylisme': { value: 1, nb_doses: 0, jet_moral: false }
|
||||
}, { render: true })
|
||||
})
|
||||
await ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: 'Remise à neuf de ' + this.name
|
||||
@@ -689,8 +689,9 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
message.content += `<br>Vous n'avez bu que ${eauConsomme} doses de liquide pour une soif de ${sustNeeded}, vous avez soif!
|
||||
La soif devrait vous faire ${perte} points d'endurance non récupérables, notez le cumul de côté et ajustez l'endurance`;
|
||||
}
|
||||
await this.updateCompteurValue('sust', 0);
|
||||
await this.updateCompteurValue('eau', 0);
|
||||
|
||||
await this.update({ 'system.compteurs.sust.value': 0 });
|
||||
await this.update({ 'system.compteurs.eau.value': 0 });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -753,25 +754,25 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
updates[`system.compteurs.chance.value`] = to
|
||||
}
|
||||
}
|
||||
let selectedCarac = this.findCaracByName(caracName);
|
||||
let selectedCarac = this.findCaracByName(caracName)
|
||||
const from = selectedCarac.value
|
||||
updates[`system.carac.${caracName}.value`] = to;
|
||||
await this.update(updates, { noHook: true });
|
||||
await ExperienceLog.add(this, XP_TOPIC.CARAC, from, to, caracName);
|
||||
updates[`system.carac.${caracName}.value`] = to
|
||||
await this.update(updates, { noHook: true })
|
||||
await ExperienceLog.add(this, XP_TOPIC.CARAC, from, to, caracName)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCaracXP(caracName, to) {
|
||||
if (caracName == 'Taille') {
|
||||
return;
|
||||
return
|
||||
}
|
||||
let selectedCarac = this.findCaracByName(caracName);
|
||||
if (!selectedCarac.derivee) {
|
||||
const from = Number(selectedCarac.xp);
|
||||
await this.update({ [`system.carac.${caracName}.xp`]: to });
|
||||
await ExperienceLog.add(this, XP_TOPIC.XPCARAC, from, to, caracName);
|
||||
const from = Number(selectedCarac.xp)
|
||||
await this.update({ [`system.carac.${caracName}.xp`]: to })
|
||||
await ExperienceLog.add(this, XP_TOPIC.XPCARAC, from, to, caracName)
|
||||
}
|
||||
this.checkCaracXP(caracName);
|
||||
this.checkCaracXP(caracName)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -792,9 +793,9 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
carac.xp = toXp;
|
||||
carac.value = toValue;
|
||||
await this.update({ [`system.carac.${caracName}`]: carac });
|
||||
await ExperienceLog.add(this, XP_TOPIC.XPCARAC, fromXp, toXp, caracName);
|
||||
await ExperienceLog.add(this, XP_TOPIC.CARAC, fromValue, toValue, caracName);
|
||||
await this.update({ [`system.carac.${caracName}`]: carac })
|
||||
await ExperienceLog.add(this, XP_TOPIC.XPCARAC, fromXp, toXp, caracName)
|
||||
await ExperienceLog.add(this, XP_TOPIC.CARAC, fromValue, toValue, caracName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,7 +814,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
await competence.update({
|
||||
"system.xp": toXp,
|
||||
"system.niveau": toNiveau,
|
||||
}, { render: false })
|
||||
})
|
||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name);
|
||||
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name);
|
||||
}
|
||||
@@ -822,35 +823,35 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
async updateCompetenceStress(idOrName) {
|
||||
const competence = this.getCompetence(idOrName);
|
||||
if (!competence) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
const fromXp = competence.system.xp;
|
||||
const fromXpStress = this.system.compteurs.experience.value;
|
||||
const fromNiveau = Number(competence.system.niveau);
|
||||
const xpSuivant = RdDItemCompetence.getCompetenceNextXp(fromNiveau);
|
||||
const xpRequis = xpSuivant - fromXp;
|
||||
const fromXp = competence.system.xp
|
||||
const fromXpStress = this.system.compteurs.experience.value
|
||||
const fromNiveau = Number(competence.system.niveau)
|
||||
const xpSuivant = RdDItemCompetence.getCompetenceNextXp(fromNiveau)
|
||||
const xpRequis = xpSuivant - fromXp
|
||||
if (fromXpStress <= 0 || fromNiveau >= competence.system.niveau_archetype) {
|
||||
ui.notifications.info(`La compétence ne peut pas augmenter!
|
||||
stress disponible: ${fromXpStress}
|
||||
expérience requise: ${xpRequis}
|
||||
niveau : ${fromNiveau}
|
||||
archétype : ${competence.system.niveau_archetype}`);
|
||||
archétype : ${competence.system.niveau_archetype}`)
|
||||
return
|
||||
}
|
||||
const xpUtilise = Math.max(0, Math.min(fromXpStress, xpRequis));
|
||||
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0;
|
||||
const toNiveau = fromNiveau + gainNiveau;
|
||||
const newXp = gainNiveau > 0 ? Math.max(fromXp - xpSuivant, 0) : (fromXp + xpUtilise);
|
||||
const xpUtilise = Math.max(0, Math.min(fromXpStress, xpRequis))
|
||||
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0
|
||||
const toNiveau = fromNiveau + gainNiveau
|
||||
const newXp = gainNiveau > 0 ? Math.max(fromXp - xpSuivant, 0) : (fromXp + xpUtilise)
|
||||
await competence.update({
|
||||
"system.xp": newXp,
|
||||
"system.niveau": toNiveau,
|
||||
}, { render: false })
|
||||
const toXpStress = Math.max(0, fromXpStress - xpUtilise);
|
||||
await this.update({ "system.compteurs.experience.value": toXpStress });
|
||||
})
|
||||
const toXpStress = Math.max(0, fromXpStress - xpUtilise)
|
||||
await this.update({ "system.compteurs.experience.value": toXpStress })
|
||||
|
||||
await ExperienceLog.add(this, XP_TOPIC.TRANSFORM, fromXpStress, toXpStress, `Dépense stress`);
|
||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, newXp, competence.name);
|
||||
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name);
|
||||
await ExperienceLog.add(this, XP_TOPIC.TRANSFORM, fromXpStress, toXpStress, `Dépense stress`)
|
||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, newXp, competence.name)
|
||||
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -860,8 +861,8 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
const toNiveau = compValue ?? RdDItemCompetence.getNiveauBase(competence.system.categorie, competence.getCategories());
|
||||
this.notifyCompetencesTronc(competence, toNiveau);
|
||||
const fromNiveau = competence.system.niveau;
|
||||
await competence.update({ 'system.niveau': toNiveau }, { render: true })
|
||||
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name, true);
|
||||
await competence.update({ 'system.niveau': toNiveau })
|
||||
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,11 +883,13 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
async updateCompetenceXP(idOrName, toXp) {
|
||||
let competence = this.getCompetence(idOrName);
|
||||
if (competence) {
|
||||
if (isNaN(toXp) || typeof (toXp) != 'number') toXp = 0;
|
||||
const fromXp = competence.system.xp;
|
||||
this.checkCompetenceXP(idOrName, toXp);
|
||||
await competence.update({ 'system.xp': toXp }, { render: false })
|
||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true);
|
||||
if (isNaN(toXp) || typeof (toXp) != 'number') {
|
||||
toXp = 0
|
||||
}
|
||||
const fromXp = competence.system.xp
|
||||
this.checkCompetenceXP(idOrName, toXp)
|
||||
await competence.update({ 'system.xp': toXp })
|
||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true)
|
||||
if (toXp > fromXp) {
|
||||
RdDUtility.checkThanatosXP(competence)
|
||||
}
|
||||
@@ -897,10 +900,12 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
async updateCompetenceXPSort(idOrName, toXpSort) {
|
||||
let competence = this.getCompetence(idOrName);
|
||||
if (competence) {
|
||||
if (isNaN(toXpSort) || typeof (toXpSort) != 'number') toXpSort = 0;
|
||||
const fromXpSort = competence.system.xp_sort;
|
||||
await competence.update({ 'system.xp_sort': toXpSort }, { render: false })
|
||||
await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true);
|
||||
if (isNaN(toXpSort) || typeof (toXpSort) != 'number') {
|
||||
toXpSort = 0
|
||||
}
|
||||
const fromXpSort = competence.system.xp_sort
|
||||
await competence.update({ 'system.xp_sort': toXpSort })
|
||||
await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true)
|
||||
if (toXpSort > fromXpSort) {
|
||||
RdDUtility.checkThanatosXP(competence)
|
||||
}
|
||||
@@ -917,25 +922,25 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
async deleteExperienceLog(from, count) {
|
||||
if (from >= 0 && count > 0) {
|
||||
let expLog = foundry.utils.duplicate(this.system.experiencelog);
|
||||
expLog.splice(from, count);
|
||||
await this.update({ [`system.experiencelog`]: expLog });
|
||||
let expLog = foundry.utils.duplicate(this.system.experiencelog)
|
||||
expLog.splice(from, count)
|
||||
await this.update({ [`system.experiencelog`]: expLog })
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCompteurValue(fieldName, to) {
|
||||
const from = this.system.compteurs[fieldName].value
|
||||
await this.update({ [`system.compteurs.${fieldName}.value`]: to });
|
||||
await this.addStressExperienceLog(fieldName, from, to, fieldName, true);
|
||||
await this.update({ [`system.compteurs.${fieldName}.value`]: to })
|
||||
await this.addStressExperienceLog(fieldName, from, to, fieldName, true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addCompteurValue(fieldName, add, raison) {
|
||||
let from = this.system.compteurs[fieldName].value;
|
||||
const to = Number(from) + Number(add);
|
||||
await this.update({ [`system.compteurs.${fieldName}.value`]: to });
|
||||
await this.addStressExperienceLog(fieldName, from, to, raison);
|
||||
let from = this.system.compteurs[fieldName].value
|
||||
const to = Number(from) + Number(add)
|
||||
await this.update({ [`system.compteurs.${fieldName}.value`]: to })
|
||||
await this.addStressExperienceLog(fieldName, from, to, raison)
|
||||
}
|
||||
|
||||
async addStressExperienceLog(topic, from, to, raison, manuel) {
|
||||
@@ -948,35 +953,22 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async distribuerStress(compteur, stress, motif) {
|
||||
async distribuerStress(compteur, valeur, motif) {
|
||||
if (game.user.isGM && this.hasPlayerOwner) {
|
||||
switch (compteur) {
|
||||
case 'stress': case 'experience':
|
||||
await this.addCompteurValue(compteur, stress, motif);
|
||||
const message = `${this.name} a reçu ${stress} points ${compteur == 'stress' ? "de stress" : "d'expérience"} (raison : ${motif})`;
|
||||
ui.notifications.info(message);
|
||||
game.users.players.filter(player => player.active && player.character?.id == this.id)
|
||||
await this.addCompteurValue(compteur, valeur, motif);
|
||||
const message = `${this.name} a reçu ${valeur} points ${compteur == 'stress' ? "de stress" : "d'expérience"} (raison : ${motif})`;
|
||||
game.users.players.filter(player => this.testUserPermission(player, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER))
|
||||
.forEach(player => ChatUtility.notifyUser(player.id, 'info', message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateAttributeValue(fieldName, fieldValue) {
|
||||
await this.update({ [`system.attributs.${fieldName}.value`]: fieldValue });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
ethylisme() {
|
||||
return this.system.compteurs.ethylisme?.value ?? 1;
|
||||
}
|
||||
malusEthylisme() {
|
||||
return Math.min(0, this.ethylisme())
|
||||
}
|
||||
isAlcoolise() {
|
||||
return this.ethylisme() < 1
|
||||
}
|
||||
|
||||
ethylisme() { return this.system.compteurs.ethylisme?.value ?? 1 }
|
||||
malusEthylisme() { return Math.min(0, this.ethylisme()) }
|
||||
isAlcoolise() { return this.ethylisme() < 1 }
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async actionRefoulement(item) {
|
||||
@@ -997,15 +989,15 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async ajouterRefoulement(value = 1, refouler) {
|
||||
let refoulement = this.system.reve.refoulement.value + value;
|
||||
const roll = new Roll("1d20");
|
||||
await roll.evaluate();
|
||||
await roll.toMessage({ flavor: `${this.name} refoule ${refouler} pour ${value} points de refoulement (total: ${refoulement})` });
|
||||
let refoulement = this.system.reve.refoulement.value + value
|
||||
const roll = new Roll("1d20")
|
||||
await roll.evaluate()
|
||||
await roll.toMessage({ flavor: `${this.name} refoule ${refouler} pour ${value} points de refoulement (total: ${refoulement})` })
|
||||
if (roll.total <= refoulement) {
|
||||
refoulement = 0;
|
||||
await this.ajouterSouffle({ chat: true });
|
||||
refoulement = 0
|
||||
await this.ajouterSouffle({ chat: true })
|
||||
}
|
||||
await this.update({ "system.reve.refoulement.value": refoulement });
|
||||
await this.update({ "system.reve.refoulement.value": refoulement })
|
||||
return roll;
|
||||
}
|
||||
|
||||
@@ -1013,14 +1005,14 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
async ajouterSouffle(options = { chat: false }) {
|
||||
let souffle = await RdDRollTables.getSouffle()
|
||||
//souffle.id = undefined; //TBC
|
||||
await this.createEmbeddedDocuments('Item', [souffle]);
|
||||
await this.createEmbeddedDocuments('Item', [souffle])
|
||||
if (options.chat) {
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: this.name + " subit un Souffle de Dragon : " + souffle.name
|
||||
});
|
||||
})
|
||||
}
|
||||
return souffle;
|
||||
return souffle
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -1028,7 +1020,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
let queue;
|
||||
if (this.system.reve.reve.thanatosused) {
|
||||
queue = await RdDRollTables.getOmbre();
|
||||
await this.update({ "system.reve.reve.thanatosused": false });
|
||||
await this.update({ "system.reve.reve.thanatosused": false })
|
||||
}
|
||||
else {
|
||||
queue = await RdDRollTables.getQueue();
|
||||
@@ -1038,7 +1030,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: this.name + " subit une Queue de Dragon : " + queue.name
|
||||
});
|
||||
})
|
||||
}
|
||||
return queue;
|
||||
}
|
||||
@@ -1161,26 +1153,17 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async regainPointDeSeuil() {
|
||||
const seuil = Misc.toInt(this.system.reve.seuil.value);
|
||||
const seuilMax = Misc.toInt(this.system.carac.reve.value)
|
||||
async recuperationSeuilReve() {
|
||||
const value = Misc.toInt(this.system.reve.seuil.value);
|
||||
const max = Misc.toInt(this.system.carac.reve.value)
|
||||
+ 2 * EffetsDraconiques.countAugmentationSeuil(this);
|
||||
|
||||
if (seuil < seuilMax) {
|
||||
await this.setPointsDeSeuil(Math.min(seuil + 1, seuilMax));
|
||||
if (value < max) {
|
||||
const nouveauSeuil = Math.min(value + 1, max);
|
||||
await this.update({ "system.reve.seuil.value": nouveauSeuil });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setPointsDeSeuil(seuil) {
|
||||
await this.update({ "system.reve.seuil.value": seuil });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setPointsDeChance(chance) {
|
||||
await this.updateCompteurValue("chance", chance);
|
||||
}
|
||||
|
||||
async jetEndurance(resteEndurance = undefined) {
|
||||
const result = super.jetEndurance(resteEndurance);
|
||||
if (result.jetEndurance == 1) {
|
||||
@@ -1191,13 +1174,9 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSConst() { return RdDCarac.calculSConst(this.getConstitution()) }
|
||||
|
||||
async ajoutXpConstitution(xp) {
|
||||
await this.update({ "system.carac.constitution.xp": Misc.toInt(this.system.carac.constitution.xp) + xp });
|
||||
}
|
||||
|
||||
|
||||
async _gainXpConstitutionJetEndurance() {
|
||||
await this.ajoutXpConstitution(1); // +1 XP !
|
||||
await this.updateCaracXP('constitution', Misc.toInt(this.system.carac.constitution.xp) + 1)
|
||||
return `${this.name} a obtenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement.`;
|
||||
}
|
||||
|
||||
@@ -1234,27 +1213,25 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async moralIncDec(ajustementMoral, bonmoment = "") {
|
||||
if (ajustementMoral != 0) {
|
||||
if (ajustementMoral > 0 && bonmoment != "" && bonmoment != undefined) {
|
||||
const bonmoments = [...this.system.compteurs.bonmoments, bonmoment]
|
||||
await this.update({ 'system.compteurs.bonmoments': bonmoments }, { render: false })
|
||||
async moralIncDec(ajustement, bonmoment = "") {
|
||||
let moral = parseInt(this.system.compteurs.moral.value)
|
||||
if (ajustement != 0) {
|
||||
if (ajustement > 0 && bonmoment != "" && bonmoment != undefined) {
|
||||
await this.update({ 'system.compteurs.bonmoments': [...this.system.compteurs.bonmoments, bonmoment] })
|
||||
}
|
||||
const startMoral = parseInt(this.system.compteurs.moral.value)
|
||||
const moralTheorique = startMoral + ajustementMoral
|
||||
const moralTheorique = moral + ajustement
|
||||
if (moralTheorique > 3) { // exaltation
|
||||
const ajoutExaltation = moralTheorique - 3
|
||||
const exaltation = parseInt(this.system.compteurs.exaltation.value) + ajoutExaltation
|
||||
await this.updateCompteurValue('exaltation', exaltation)
|
||||
const exaltation = parseInt(this.system.compteurs.exaltation.value) + moralTheorique - 3
|
||||
await this.update({ 'system.compteurs.exaltation.value': exaltation })
|
||||
}
|
||||
if (moralTheorique < -3) { // dissolution
|
||||
const ajoutDissolution = -3 - moralTheorique
|
||||
const dissolution = parseInt(this.system.compteurs.dissolution.value) + ajoutDissolution
|
||||
await this.updateCompteurValue('dissolution', dissolution)
|
||||
const dissolution = parseInt(this.system.compteurs.dissolution.value) - 3 - moralTheorique
|
||||
await this.update({ 'system.compteurs.dissolution.value': dissolution })
|
||||
}
|
||||
await this.updateCompteurValue('moral', Math.max(-3, Math.min(moralTheorique, 3)));
|
||||
moral = Math.max(-3, Math.min(moralTheorique, 3));
|
||||
await this.update({ 'system.compteurs.moral.value': moral })
|
||||
}
|
||||
return this.system.compteurs.moral.value;
|
||||
return moral
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -1386,7 +1363,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||
const sust = item.system.sust
|
||||
if (sust > 0) {
|
||||
await this.updateCompteurValue('sust', RdDActor.$calculNewSust(this.system.compteurs.sust.value, sust, doses));
|
||||
await this.update({ 'system.compteurs.sust.value': RdDActor.$calculNewSust(this.system.compteurs.sust.value, sust, doses) })
|
||||
}
|
||||
await item.diminuerQuantite(doses, options);
|
||||
}
|
||||
@@ -1394,9 +1371,9 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async boire(item, doses, options = { diminuerQuantite: true }) {
|
||||
const desaltere = item.system.desaltere;
|
||||
if (desaltere > 0) {
|
||||
await this.updateCompteurValue('eau', RdDActor.$calculNewSust(this.system.compteurs.eau.value, desaltere, doses));
|
||||
const eau = item.system.desaltere
|
||||
if (eau > 0) {
|
||||
await this.update({ 'system.compteurs.eau.value': RdDActor.$calculNewSust(this.system.compteurs.eau.value, eau, doses) })
|
||||
}
|
||||
if (item.isAlcool()) {
|
||||
for (let i = 0; i < doses; i++) {
|
||||
@@ -1523,13 +1500,12 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
const toStress = Math.max(fromStress - stressRollData.perte - 1, 0);
|
||||
const fromXpSress = Number(this.system.compteurs.experience.value);
|
||||
const toXpStress = fromXpSress + Number(stressRollData.xp);
|
||||
const updates = {
|
||||
await this.update({
|
||||
"system.compteurs.stress.value": toStress,
|
||||
"system.compteurs.experience.value": toXpStress,
|
||||
"system.compteurs.dissolution.value": dissolution - perteDissolution,
|
||||
"system.compteurs.exaltation.value": 0
|
||||
}
|
||||
await this.update(updates);
|
||||
})
|
||||
await ExperienceLog.add(this, XP_TOPIC.STRESS, fromStress, toStress, 'Transformation')
|
||||
await ExperienceLog.add(this, XP_TOPIC.TRANSFORM, fromXpSress, toXpStress, 'Transformation')
|
||||
}
|
||||
@@ -1792,30 +1768,30 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _rollUnSortResult(rollData) {
|
||||
let rolled = rollData.rolled;
|
||||
let selectedSort = rollData.selectedSort;
|
||||
let rolled = rollData.rolled
|
||||
let selectedSort = rollData.selectedSort
|
||||
|
||||
rollData.isSortReserve = rollData.mettreEnReserve && !selectedSort.system.isrituel;
|
||||
rollData.isSortReserve = rollData.mettreEnReserve && !selectedSort.system.isrituel
|
||||
rollData.show = {}
|
||||
rollData.depenseReve = Number(selectedSort.system.ptreve_reel);
|
||||
rollData.depenseReve = Number(selectedSort.system.ptreve_reel)
|
||||
|
||||
if (rollData.competence.name.includes('Thanatos')) { // Si Thanatos
|
||||
await this.update({ "system.reve.reve.thanatosused": true });
|
||||
await this.update({ "system.reve.reve.thanatosused": true })
|
||||
}
|
||||
let reveActuel = parseInt(this.system.reve.reve.value)
|
||||
if (rolled.isSuccess) { // Réussite du sort !
|
||||
if (rolled.isPart) {
|
||||
rollData.depenseReve = Math.max(Math.floor(rollData.depenseReve / 2), 1);
|
||||
rollData.depenseReve = Math.max(Math.floor(rollData.depenseReve / 2), 1)
|
||||
}
|
||||
if (rollData.isSortReserve) {
|
||||
rollData.depenseReve++;
|
||||
rollData.depenseReve++
|
||||
}
|
||||
if (reveActuel > rollData.depenseReve) {
|
||||
// Incrémenter/gére le bonus de case
|
||||
RdDItemSort.incrementBonusCase(this, selectedSort, rollData.tmr.coord);
|
||||
RdDItemSort.incrementBonusCase(this, selectedSort, rollData.tmr.coord)
|
||||
|
||||
if (rollData.isSortReserve) {
|
||||
await this.sortMisEnReserve(selectedSort, rollData.competence, rollData.tmr.coord, Number(selectedSort.system.ptreve_reel));
|
||||
await this.sortMisEnReserve(selectedSort, rollData.competence, rollData.tmr.coord, Number(selectedSort.system.ptreve_reel))
|
||||
}
|
||||
else {
|
||||
console.log('lancement de sort', rollData.selectedSort)
|
||||
@@ -1840,16 +1816,15 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
}
|
||||
|
||||
reveActuel = Math.max(reveActuel - rollData.depenseReve, 0);
|
||||
await this.update({ "system.reve.reve.value": reveActuel });
|
||||
|
||||
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-sort.hbs');
|
||||
reveActuel = Math.max(reveActuel - rollData.depenseReve, 0)
|
||||
await this.update({ "system.reve.reve.value": reveActuel })
|
||||
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-sort.hbs')
|
||||
|
||||
if (reveActuel == 0) { // 0 points de reve
|
||||
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
|
||||
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" })
|
||||
}
|
||||
if (!rollData.isSortReserve || !rolled.isSuccess) {
|
||||
this.tmrApp?.close();
|
||||
this.tmrApp?.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2210,12 +2185,11 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
let destinee = this.system.compteurs.destinee?.value ?? 0;
|
||||
if (destinee > 0) {
|
||||
ChatMessage.create({ content: `<span class="rdd-roll-part">${this.name} a fait appel à la Destinée !</span>` });
|
||||
destinee--;
|
||||
await this.updateCompteurValue("destinee", destinee);
|
||||
onSuccess();
|
||||
await this.update({ 'system.compteurs.destinee.value ': destinee - 1 })
|
||||
onSuccess()
|
||||
}
|
||||
else {
|
||||
onEchec();
|
||||
onEchec()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2461,10 +2435,13 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
async quitterTMR(message, viewOnly, cumulFatigue) {
|
||||
if (this.tmrApp) {
|
||||
this.tmrApp = undefined
|
||||
const appliquerFatigue = ReglesOptionnelles.isUsing("appliquer-fatigue");
|
||||
await this.santeIncDec(
|
||||
appliquerFatigue ? "fatigue" : "endurance",
|
||||
(appliquerFatigue ? 1 : -1) * cumulFatigue)
|
||||
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
|
||||
await this.santeIncDec("fatigue", cumulFatigue)
|
||||
}
|
||||
else {
|
||||
await this.santeIncDec("endurance", - cumulFatigue)
|
||||
|
||||
}
|
||||
if (!viewOnly) {
|
||||
await this.supprimerSignesDraconiques(it => it.system.ephemere && it.system.duree == '1 round', { render: false })
|
||||
await this.setEffect(STATUSES.StatusDemiReve, false)
|
||||
@@ -2527,10 +2504,10 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
async equiperObjet(item) {
|
||||
if (item?.isEquipable()) {
|
||||
const isEquipe = !item.system.equipe;
|
||||
await item.update({ "system.equipe": isEquipe });
|
||||
await item.update({ "system.equipe": isEquipe })
|
||||
this.computeEncTotal()
|
||||
if (isEquipe)
|
||||
this.verifierForceMin(item);
|
||||
this.verifierForceMin(item)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2673,10 +2650,10 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
async setPointsCoeur(subActorId, coeurs, options = { immediat: false }) {
|
||||
const newSuivants = foundry.utils.duplicate(this.system.subacteurs.suivants)
|
||||
const amoureux = newSuivants.find(it => it.id == subActorId);
|
||||
const amoureux = newSuivants.find(it => it.id == subActorId)
|
||||
if (amoureux) {
|
||||
amoureux[options.immediat ? 'coeur' : 'prochainCoeur'] = coeurs
|
||||
await this.update({ 'system.subacteurs.suivants': newSuivants });
|
||||
await this.update({ 'system.subacteurs.suivants': newSuivants })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2730,9 +2707,9 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
let alreadyPresent = dataArray.find(attached => attached.id == subActor.id);
|
||||
if (!alreadyPresent) {
|
||||
let newArray = [...dataArray, subActor]
|
||||
await this.update({ [dataPath]: newArray });
|
||||
await this.update({ [dataPath]: newArray })
|
||||
} else {
|
||||
ui.notifications.warn(dataName + " est déja attaché à " + this.name);
|
||||
ui.notifications.warn(dataName + " est déja attaché à " + this.name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2754,18 +2731,19 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
async deleteSubActeur(actorId) {
|
||||
['vehicules', 'suivants', 'montures'].forEach(async type => {
|
||||
const subList = this.system.subacteurs[type];
|
||||
const subList = this.system.subacteurs[type]
|
||||
if (subList.find(it => it.id == actorId)) {
|
||||
let newList = subList.filter(it => it.id != actorId)
|
||||
await this.update({ [`system.subacteurs.${type}`]: newList }, { renderSheet: false });
|
||||
await this.update({ [`system.subacteurs.${type}`]: newList }, { render: false })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async buildPotionGuerisonList(pointsGuerison) {
|
||||
const pointsGuerisonInitial = pointsGuerison;
|
||||
const blessures = this.filterItems(it => it.system.gravite > 0, 'blessure').sort(Misc.descending(it => it.system.gravite))
|
||||
const pointsGuerisonInitial = pointsGuerison
|
||||
const blessures = this.filterItems(it => it.system.gravite > 0, 'blessure')
|
||||
.sort(Misc.descending(it => it.system.gravite))
|
||||
const ids = []
|
||||
const guerisonData = { list: [], pointsConsommes: 0 }
|
||||
for (let blessure of blessures) {
|
||||
@@ -2776,14 +2754,14 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
}
|
||||
if (ids.length > 0) {
|
||||
await this.supprimerBlessures(it => ids.includes(it.id), { render: blessures.length != ids.length })
|
||||
await this.supprimerBlessures(it => ids.includes(it.id))
|
||||
}
|
||||
if (blessures.length == ids.length) {
|
||||
let pvManquants = this.system.sante.vie.max - this.system.sante.vie.value;
|
||||
let pvSoignees = Math.min(pvManquants, Math.floor(pointsGuerison / 2));
|
||||
pointsGuerison -= pvSoignees * 2;
|
||||
guerisonData.list.push(pvSoignees + " Points de Vie soignés");
|
||||
await this.santeIncDec('vie', +pvSoignees, { render: true })
|
||||
await this.santeIncDec('vie', +pvSoignees)
|
||||
}
|
||||
guerisonData.pointsConsommes = pointsGuerisonInitial - pointsGuerison;
|
||||
return guerisonData;
|
||||
|
||||
Reference in New Issue
Block a user