Correction des updates multiples
Utilisation d'un render sur timer pour forcer le réaffichage
This commit is contained in:
@@ -279,7 +279,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
|
|||||||
|
|
||||||
// On pts de reve change
|
// On pts de reve change
|
||||||
this.html.find('.pointsreve-value').change(async event => await this.actor.update({ "system.reve.reve.value": event.currentTarget.value }))
|
this.html.find('.pointsreve-value').change(async event => await this.actor.update({ "system.reve.reve.value": event.currentTarget.value }))
|
||||||
this.html.find('.seuil-reve-value').change(async event => await this.actor.setPointsDeSeuil(event.currentTarget.value))
|
this.html.find('.seuil-reve-value').change(async event => await this.actor.update({ "system.reve.seuil.value": event.currentTarget.value }))
|
||||||
|
|
||||||
this.html.find('.stress-test').click(async event => await this.actor.transformerStress())
|
this.html.find('.stress-test').click(async event => await this.actor.transformerStress())
|
||||||
this.html.find('.moral-malheureux').click(async event => await this.actor.jetDeMoral(MORAL.MALHEUREUX))
|
this.html.find('.moral-malheureux').click(async event => await this.actor.jetDeMoral(MORAL.MALHEUREUX))
|
||||||
|
|||||||
+144
-166
@@ -418,7 +418,7 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _recupereMoralChateauDormant(message) {
|
async _recupereMoralChateauDormant(message) {
|
||||||
await this.update({ 'system.compteurs.bonmoments': [] }, { render: false })
|
await this.update({ 'system.compteurs.bonmoments': [] })
|
||||||
|
|
||||||
if (!ReglesOptionnelles.isUsing("recuperation-moral")) { return }
|
if (!ReglesOptionnelles.isUsing("recuperation-moral")) { return }
|
||||||
|
|
||||||
@@ -498,14 +498,14 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async remiseANeuf() {
|
async remiseANeuf() {
|
||||||
await this.removeEffects(e => !e.statuses?.has(STATUSES.StatusDemiReve), { render: false })
|
await this.removeEffects(e => !e.statuses?.has(STATUSES.StatusDemiReve))
|
||||||
await this.supprimerBlessures(it => true, { render: false })
|
await this.supprimerBlessures(it => true)
|
||||||
await this.update({
|
await this.update({
|
||||||
'system.sante.endurance.value': this.system.sante.endurance.max,
|
'system.sante.endurance.value': this.system.sante.endurance.max,
|
||||||
'system.sante.vie.value': this.system.sante.vie.max,
|
'system.sante.vie.value': this.system.sante.vie.max,
|
||||||
'system.sante.fatigue.value': 0,
|
'system.sante.fatigue.value': 0,
|
||||||
'system.compteurs.ethylisme': { value: 1, nb_doses: 0, jet_moral: false }
|
'system.compteurs.ethylisme': { value: 1, nb_doses: 0, jet_moral: false }
|
||||||
}, { render: true })
|
})
|
||||||
await ChatMessage.create({
|
await ChatMessage.create({
|
||||||
whisper: ChatUtility.getOwners(this),
|
whisper: ChatUtility.getOwners(this),
|
||||||
content: 'Remise à neuf de ' + this.name
|
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!
|
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`;
|
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
|
updates[`system.compteurs.chance.value`] = to
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let selectedCarac = this.findCaracByName(caracName);
|
let selectedCarac = this.findCaracByName(caracName)
|
||||||
const from = selectedCarac.value
|
const from = selectedCarac.value
|
||||||
updates[`system.carac.${caracName}.value`] = to;
|
updates[`system.carac.${caracName}.value`] = to
|
||||||
await this.update(updates, { noHook: true });
|
await this.update(updates, { noHook: true })
|
||||||
await ExperienceLog.add(this, XP_TOPIC.CARAC, from, to, caracName);
|
await ExperienceLog.add(this, XP_TOPIC.CARAC, from, to, caracName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCaracXP(caracName, to) {
|
async updateCaracXP(caracName, to) {
|
||||||
if (caracName == 'Taille') {
|
if (caracName == 'Taille') {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
let selectedCarac = this.findCaracByName(caracName);
|
let selectedCarac = this.findCaracByName(caracName);
|
||||||
if (!selectedCarac.derivee) {
|
if (!selectedCarac.derivee) {
|
||||||
const from = Number(selectedCarac.xp);
|
const from = Number(selectedCarac.xp)
|
||||||
await this.update({ [`system.carac.${caracName}.xp`]: to });
|
await this.update({ [`system.carac.${caracName}.xp`]: to })
|
||||||
await ExperienceLog.add(this, XP_TOPIC.XPCARAC, from, to, caracName);
|
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.xp = toXp;
|
||||||
carac.value = toValue;
|
carac.value = toValue;
|
||||||
await this.update({ [`system.carac.${caracName}`]: carac });
|
await this.update({ [`system.carac.${caracName}`]: carac })
|
||||||
await ExperienceLog.add(this, XP_TOPIC.XPCARAC, fromXp, toXp, caracName);
|
await ExperienceLog.add(this, XP_TOPIC.XPCARAC, fromXp, toXp, caracName)
|
||||||
await ExperienceLog.add(this, XP_TOPIC.CARAC, fromValue, toValue, caracName);
|
await ExperienceLog.add(this, XP_TOPIC.CARAC, fromValue, toValue, caracName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,7 +814,7 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
await competence.update({
|
await competence.update({
|
||||||
"system.xp": toXp,
|
"system.xp": toXp,
|
||||||
"system.niveau": toNiveau,
|
"system.niveau": toNiveau,
|
||||||
}, { render: false })
|
})
|
||||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name);
|
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name);
|
||||||
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, 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) {
|
async updateCompetenceStress(idOrName) {
|
||||||
const competence = this.getCompetence(idOrName);
|
const competence = this.getCompetence(idOrName);
|
||||||
if (!competence) {
|
if (!competence) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
const fromXp = competence.system.xp;
|
const fromXp = competence.system.xp
|
||||||
const fromXpStress = this.system.compteurs.experience.value;
|
const fromXpStress = this.system.compteurs.experience.value
|
||||||
const fromNiveau = Number(competence.system.niveau);
|
const fromNiveau = Number(competence.system.niveau)
|
||||||
const xpSuivant = RdDItemCompetence.getCompetenceNextXp(fromNiveau);
|
const xpSuivant = RdDItemCompetence.getCompetenceNextXp(fromNiveau)
|
||||||
const xpRequis = xpSuivant - fromXp;
|
const xpRequis = xpSuivant - fromXp
|
||||||
if (fromXpStress <= 0 || fromNiveau >= competence.system.niveau_archetype) {
|
if (fromXpStress <= 0 || fromNiveau >= competence.system.niveau_archetype) {
|
||||||
ui.notifications.info(`La compétence ne peut pas augmenter!
|
ui.notifications.info(`La compétence ne peut pas augmenter!
|
||||||
stress disponible: ${fromXpStress}
|
stress disponible: ${fromXpStress}
|
||||||
expérience requise: ${xpRequis}
|
expérience requise: ${xpRequis}
|
||||||
niveau : ${fromNiveau}
|
niveau : ${fromNiveau}
|
||||||
archétype : ${competence.system.niveau_archetype}`);
|
archétype : ${competence.system.niveau_archetype}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const xpUtilise = Math.max(0, Math.min(fromXpStress, xpRequis));
|
const xpUtilise = Math.max(0, Math.min(fromXpStress, xpRequis))
|
||||||
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0;
|
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0
|
||||||
const toNiveau = fromNiveau + gainNiveau;
|
const toNiveau = fromNiveau + gainNiveau
|
||||||
const newXp = gainNiveau > 0 ? Math.max(fromXp - xpSuivant, 0) : (fromXp + xpUtilise);
|
const newXp = gainNiveau > 0 ? Math.max(fromXp - xpSuivant, 0) : (fromXp + xpUtilise)
|
||||||
await competence.update({
|
await competence.update({
|
||||||
"system.xp": newXp,
|
"system.xp": newXp,
|
||||||
"system.niveau": toNiveau,
|
"system.niveau": toNiveau,
|
||||||
}, { render: false })
|
})
|
||||||
const toXpStress = Math.max(0, fromXpStress - xpUtilise);
|
const toXpStress = Math.max(0, fromXpStress - xpUtilise)
|
||||||
await this.update({ "system.compteurs.experience.value": toXpStress });
|
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.TRANSFORM, fromXpStress, toXpStress, `Dépense stress`)
|
||||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, newXp, competence.name);
|
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.NIVEAU, fromNiveau, toNiveau, competence.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@@ -860,8 +861,8 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
const toNiveau = compValue ?? RdDItemCompetence.getNiveauBase(competence.system.categorie, competence.getCategories());
|
const toNiveau = compValue ?? RdDItemCompetence.getNiveauBase(competence.system.categorie, competence.getCategories());
|
||||||
this.notifyCompetencesTronc(competence, toNiveau);
|
this.notifyCompetencesTronc(competence, toNiveau);
|
||||||
const fromNiveau = competence.system.niveau;
|
const fromNiveau = competence.system.niveau;
|
||||||
await competence.update({ 'system.niveau': toNiveau }, { render: true })
|
await competence.update({ 'system.niveau': toNiveau })
|
||||||
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name, true);
|
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) {
|
async updateCompetenceXP(idOrName, toXp) {
|
||||||
let competence = this.getCompetence(idOrName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (competence) {
|
if (competence) {
|
||||||
if (isNaN(toXp) || typeof (toXp) != 'number') toXp = 0;
|
if (isNaN(toXp) || typeof (toXp) != 'number') {
|
||||||
const fromXp = competence.system.xp;
|
toXp = 0
|
||||||
this.checkCompetenceXP(idOrName, toXp);
|
}
|
||||||
await competence.update({ 'system.xp': toXp }, { render: false })
|
const fromXp = competence.system.xp
|
||||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true);
|
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) {
|
if (toXp > fromXp) {
|
||||||
RdDUtility.checkThanatosXP(competence)
|
RdDUtility.checkThanatosXP(competence)
|
||||||
}
|
}
|
||||||
@@ -897,10 +900,12 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
async updateCompetenceXPSort(idOrName, toXpSort) {
|
async updateCompetenceXPSort(idOrName, toXpSort) {
|
||||||
let competence = this.getCompetence(idOrName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (competence) {
|
if (competence) {
|
||||||
if (isNaN(toXpSort) || typeof (toXpSort) != 'number') toXpSort = 0;
|
if (isNaN(toXpSort) || typeof (toXpSort) != 'number') {
|
||||||
const fromXpSort = competence.system.xp_sort;
|
toXpSort = 0
|
||||||
await competence.update({ 'system.xp_sort': toXpSort }, { render: false })
|
}
|
||||||
await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true);
|
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) {
|
if (toXpSort > fromXpSort) {
|
||||||
RdDUtility.checkThanatosXP(competence)
|
RdDUtility.checkThanatosXP(competence)
|
||||||
}
|
}
|
||||||
@@ -917,25 +922,25 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
async deleteExperienceLog(from, count) {
|
async deleteExperienceLog(from, count) {
|
||||||
if (from >= 0 && count > 0) {
|
if (from >= 0 && count > 0) {
|
||||||
let expLog = foundry.utils.duplicate(this.system.experiencelog);
|
let expLog = foundry.utils.duplicate(this.system.experiencelog)
|
||||||
expLog.splice(from, count);
|
expLog.splice(from, count)
|
||||||
await this.update({ [`system.experiencelog`]: expLog });
|
await this.update({ [`system.experiencelog`]: expLog })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCompteurValue(fieldName, to) {
|
async updateCompteurValue(fieldName, to) {
|
||||||
const from = this.system.compteurs[fieldName].value
|
const from = this.system.compteurs[fieldName].value
|
||||||
await this.update({ [`system.compteurs.${fieldName}.value`]: to });
|
await this.update({ [`system.compteurs.${fieldName}.value`]: to })
|
||||||
await this.addStressExperienceLog(fieldName, from, to, fieldName, true);
|
await this.addStressExperienceLog(fieldName, from, to, fieldName, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async addCompteurValue(fieldName, add, raison) {
|
async addCompteurValue(fieldName, add, raison) {
|
||||||
let from = this.system.compteurs[fieldName].value;
|
let from = this.system.compteurs[fieldName].value
|
||||||
const to = Number(from) + Number(add);
|
const to = Number(from) + Number(add)
|
||||||
await this.update({ [`system.compteurs.${fieldName}.value`]: to });
|
await this.update({ [`system.compteurs.${fieldName}.value`]: to })
|
||||||
await this.addStressExperienceLog(fieldName, from, to, raison);
|
await this.addStressExperienceLog(fieldName, from, to, raison)
|
||||||
}
|
}
|
||||||
|
|
||||||
async addStressExperienceLog(topic, from, to, raison, manuel) {
|
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) {
|
if (game.user.isGM && this.hasPlayerOwner) {
|
||||||
switch (compteur) {
|
switch (compteur) {
|
||||||
case 'stress': case 'experience':
|
case 'stress': case 'experience':
|
||||||
await this.addCompteurValue(compteur, stress, motif);
|
await this.addCompteurValue(compteur, valeur, motif);
|
||||||
const message = `${this.name} a reçu ${stress} points ${compteur == 'stress' ? "de stress" : "d'expérience"} (raison : ${motif})`;
|
const message = `${this.name} a reçu ${valeur} points ${compteur == 'stress' ? "de stress" : "d'expérience"} (raison : ${motif})`;
|
||||||
ui.notifications.info(message);
|
game.users.players.filter(player => this.testUserPermission(player, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER))
|
||||||
game.users.players.filter(player => player.active && player.character?.id == this.id)
|
|
||||||
.forEach(player => ChatUtility.notifyUser(player.id, 'info', message));
|
.forEach(player => ChatUtility.notifyUser(player.id, 'info', message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateAttributeValue(fieldName, fieldValue) {
|
ethylisme() { return this.system.compteurs.ethylisme?.value ?? 1 }
|
||||||
await this.update({ [`system.attributs.${fieldName}.value`]: fieldValue });
|
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) {
|
async actionRefoulement(item) {
|
||||||
@@ -997,15 +989,15 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async ajouterRefoulement(value = 1, refouler) {
|
async ajouterRefoulement(value = 1, refouler) {
|
||||||
let refoulement = this.system.reve.refoulement.value + value;
|
let refoulement = this.system.reve.refoulement.value + value
|
||||||
const roll = new Roll("1d20");
|
const roll = new Roll("1d20")
|
||||||
await roll.evaluate();
|
await roll.evaluate()
|
||||||
await roll.toMessage({ flavor: `${this.name} refoule ${refouler} pour ${value} points de refoulement (total: ${refoulement})` });
|
await roll.toMessage({ flavor: `${this.name} refoule ${refouler} pour ${value} points de refoulement (total: ${refoulement})` })
|
||||||
if (roll.total <= refoulement) {
|
if (roll.total <= refoulement) {
|
||||||
refoulement = 0;
|
refoulement = 0
|
||||||
await this.ajouterSouffle({ chat: true });
|
await this.ajouterSouffle({ chat: true })
|
||||||
}
|
}
|
||||||
await this.update({ "system.reve.refoulement.value": refoulement });
|
await this.update({ "system.reve.refoulement.value": refoulement })
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1013,14 +1005,14 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
async ajouterSouffle(options = { chat: false }) {
|
async ajouterSouffle(options = { chat: false }) {
|
||||||
let souffle = await RdDRollTables.getSouffle()
|
let souffle = await RdDRollTables.getSouffle()
|
||||||
//souffle.id = undefined; //TBC
|
//souffle.id = undefined; //TBC
|
||||||
await this.createEmbeddedDocuments('Item', [souffle]);
|
await this.createEmbeddedDocuments('Item', [souffle])
|
||||||
if (options.chat) {
|
if (options.chat) {
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
whisper: ChatUtility.getOwners(this),
|
whisper: ChatUtility.getOwners(this),
|
||||||
content: this.name + " subit un Souffle de Dragon : " + souffle.name
|
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;
|
let queue;
|
||||||
if (this.system.reve.reve.thanatosused) {
|
if (this.system.reve.reve.thanatosused) {
|
||||||
queue = await RdDRollTables.getOmbre();
|
queue = await RdDRollTables.getOmbre();
|
||||||
await this.update({ "system.reve.reve.thanatosused": false });
|
await this.update({ "system.reve.reve.thanatosused": false })
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
queue = await RdDRollTables.getQueue();
|
queue = await RdDRollTables.getQueue();
|
||||||
@@ -1038,7 +1030,7 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
whisper: ChatUtility.getOwners(this),
|
whisper: ChatUtility.getOwners(this),
|
||||||
content: this.name + " subit une Queue de Dragon : " + queue.name
|
content: this.name + " subit une Queue de Dragon : " + queue.name
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
@@ -1161,26 +1153,17 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async regainPointDeSeuil() {
|
async recuperationSeuilReve() {
|
||||||
const seuil = Misc.toInt(this.system.reve.seuil.value);
|
const value = Misc.toInt(this.system.reve.seuil.value);
|
||||||
const seuilMax = Misc.toInt(this.system.carac.reve.value)
|
const max = Misc.toInt(this.system.carac.reve.value)
|
||||||
+ 2 * EffetsDraconiques.countAugmentationSeuil(this);
|
+ 2 * EffetsDraconiques.countAugmentationSeuil(this);
|
||||||
|
|
||||||
if (seuil < seuilMax) {
|
if (value < max) {
|
||||||
await this.setPointsDeSeuil(Math.min(seuil + 1, seuilMax));
|
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) {
|
async jetEndurance(resteEndurance = undefined) {
|
||||||
const result = super.jetEndurance(resteEndurance);
|
const result = super.jetEndurance(resteEndurance);
|
||||||
if (result.jetEndurance == 1) {
|
if (result.jetEndurance == 1) {
|
||||||
@@ -1191,13 +1174,9 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSConst() { return RdDCarac.calculSConst(this.getConstitution()) }
|
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() {
|
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.`;
|
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 = "") {
|
async moralIncDec(ajustement, bonmoment = "") {
|
||||||
if (ajustementMoral != 0) {
|
let moral = parseInt(this.system.compteurs.moral.value)
|
||||||
if (ajustementMoral > 0 && bonmoment != "" && bonmoment != undefined) {
|
if (ajustement != 0) {
|
||||||
const bonmoments = [...this.system.compteurs.bonmoments, bonmoment]
|
if (ajustement > 0 && bonmoment != "" && bonmoment != undefined) {
|
||||||
await this.update({ 'system.compteurs.bonmoments': bonmoments }, { render: false })
|
await this.update({ 'system.compteurs.bonmoments': [...this.system.compteurs.bonmoments, bonmoment] })
|
||||||
}
|
}
|
||||||
const startMoral = parseInt(this.system.compteurs.moral.value)
|
const moralTheorique = moral + ajustement
|
||||||
const moralTheorique = startMoral + ajustementMoral
|
|
||||||
if (moralTheorique > 3) { // exaltation
|
if (moralTheorique > 3) { // exaltation
|
||||||
const ajoutExaltation = moralTheorique - 3
|
const exaltation = parseInt(this.system.compteurs.exaltation.value) + moralTheorique - 3
|
||||||
const exaltation = parseInt(this.system.compteurs.exaltation.value) + ajoutExaltation
|
await this.update({ 'system.compteurs.exaltation.value': exaltation })
|
||||||
await this.updateCompteurValue('exaltation', exaltation)
|
|
||||||
}
|
}
|
||||||
if (moralTheorique < -3) { // dissolution
|
if (moralTheorique < -3) { // dissolution
|
||||||
const ajoutDissolution = -3 - moralTheorique
|
const dissolution = parseInt(this.system.compteurs.dissolution.value) - 3 - moralTheorique
|
||||||
const dissolution = parseInt(this.system.compteurs.dissolution.value) + ajoutDissolution
|
await this.update({ 'system.compteurs.dissolution.value': dissolution })
|
||||||
await this.updateCompteurValue('dissolution', 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 }) {
|
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||||
const sust = item.system.sust
|
const sust = item.system.sust
|
||||||
if (sust > 0) {
|
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);
|
await item.diminuerQuantite(doses, options);
|
||||||
}
|
}
|
||||||
@@ -1394,9 +1371,9 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async boire(item, doses, options = { diminuerQuantite: true }) {
|
async boire(item, doses, options = { diminuerQuantite: true }) {
|
||||||
const desaltere = item.system.desaltere;
|
const eau = item.system.desaltere
|
||||||
if (desaltere > 0) {
|
if (eau > 0) {
|
||||||
await this.updateCompteurValue('eau', RdDActor.$calculNewSust(this.system.compteurs.eau.value, desaltere, doses));
|
await this.update({ 'system.compteurs.eau.value': RdDActor.$calculNewSust(this.system.compteurs.eau.value, eau, doses) })
|
||||||
}
|
}
|
||||||
if (item.isAlcool()) {
|
if (item.isAlcool()) {
|
||||||
for (let i = 0; i < doses; i++) {
|
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 toStress = Math.max(fromStress - stressRollData.perte - 1, 0);
|
||||||
const fromXpSress = Number(this.system.compteurs.experience.value);
|
const fromXpSress = Number(this.system.compteurs.experience.value);
|
||||||
const toXpStress = fromXpSress + Number(stressRollData.xp);
|
const toXpStress = fromXpSress + Number(stressRollData.xp);
|
||||||
const updates = {
|
await this.update({
|
||||||
"system.compteurs.stress.value": toStress,
|
"system.compteurs.stress.value": toStress,
|
||||||
"system.compteurs.experience.value": toXpStress,
|
"system.compteurs.experience.value": toXpStress,
|
||||||
"system.compteurs.dissolution.value": dissolution - perteDissolution,
|
"system.compteurs.dissolution.value": dissolution - perteDissolution,
|
||||||
"system.compteurs.exaltation.value": 0
|
"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.STRESS, fromStress, toStress, 'Transformation')
|
||||||
await ExperienceLog.add(this, XP_TOPIC.TRANSFORM, fromXpSress, toXpStress, 'Transformation')
|
await ExperienceLog.add(this, XP_TOPIC.TRANSFORM, fromXpSress, toXpStress, 'Transformation')
|
||||||
}
|
}
|
||||||
@@ -1792,30 +1768,30 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _rollUnSortResult(rollData) {
|
async _rollUnSortResult(rollData) {
|
||||||
let rolled = rollData.rolled;
|
let rolled = rollData.rolled
|
||||||
let selectedSort = rollData.selectedSort;
|
let selectedSort = rollData.selectedSort
|
||||||
|
|
||||||
rollData.isSortReserve = rollData.mettreEnReserve && !selectedSort.system.isrituel;
|
rollData.isSortReserve = rollData.mettreEnReserve && !selectedSort.system.isrituel
|
||||||
rollData.show = {}
|
rollData.show = {}
|
||||||
rollData.depenseReve = Number(selectedSort.system.ptreve_reel);
|
rollData.depenseReve = Number(selectedSort.system.ptreve_reel)
|
||||||
|
|
||||||
if (rollData.competence.name.includes('Thanatos')) { // Si Thanatos
|
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)
|
let reveActuel = parseInt(this.system.reve.reve.value)
|
||||||
if (rolled.isSuccess) { // Réussite du sort !
|
if (rolled.isSuccess) { // Réussite du sort !
|
||||||
if (rolled.isPart) {
|
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) {
|
if (rollData.isSortReserve) {
|
||||||
rollData.depenseReve++;
|
rollData.depenseReve++
|
||||||
}
|
}
|
||||||
if (reveActuel > rollData.depenseReve) {
|
if (reveActuel > rollData.depenseReve) {
|
||||||
// Incrémenter/gére le bonus de case
|
// 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) {
|
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 {
|
else {
|
||||||
console.log('lancement de sort', rollData.selectedSort)
|
console.log('lancement de sort', rollData.selectedSort)
|
||||||
@@ -1840,16 +1816,15 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reveActuel = Math.max(reveActuel - rollData.depenseReve, 0);
|
reveActuel = Math.max(reveActuel - rollData.depenseReve, 0)
|
||||||
await this.update({ "system.reve.reve.value": reveActuel });
|
await this.update({ "system.reve.reve.value": reveActuel })
|
||||||
|
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-sort.hbs')
|
||||||
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-sort.hbs');
|
|
||||||
|
|
||||||
if (reveActuel == 0) { // 0 points de reve
|
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) {
|
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;
|
let destinee = this.system.compteurs.destinee?.value ?? 0;
|
||||||
if (destinee > 0) {
|
if (destinee > 0) {
|
||||||
ChatMessage.create({ content: `<span class="rdd-roll-part">${this.name} a fait appel à la Destinée !</span>` });
|
ChatMessage.create({ content: `<span class="rdd-roll-part">${this.name} a fait appel à la Destinée !</span>` });
|
||||||
destinee--;
|
await this.update({ 'system.compteurs.destinee.value ': destinee - 1 })
|
||||||
await this.updateCompteurValue("destinee", destinee);
|
onSuccess()
|
||||||
onSuccess();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
onEchec();
|
onEchec()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2461,10 +2435,13 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
async quitterTMR(message, viewOnly, cumulFatigue) {
|
async quitterTMR(message, viewOnly, cumulFatigue) {
|
||||||
if (this.tmrApp) {
|
if (this.tmrApp) {
|
||||||
this.tmrApp = undefined
|
this.tmrApp = undefined
|
||||||
const appliquerFatigue = ReglesOptionnelles.isUsing("appliquer-fatigue");
|
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
|
||||||
await this.santeIncDec(
|
await this.santeIncDec("fatigue", cumulFatigue)
|
||||||
appliquerFatigue ? "fatigue" : "endurance",
|
}
|
||||||
(appliquerFatigue ? 1 : -1) * cumulFatigue)
|
else {
|
||||||
|
await this.santeIncDec("endurance", - cumulFatigue)
|
||||||
|
|
||||||
|
}
|
||||||
if (!viewOnly) {
|
if (!viewOnly) {
|
||||||
await this.supprimerSignesDraconiques(it => it.system.ephemere && it.system.duree == '1 round', { render: false })
|
await this.supprimerSignesDraconiques(it => it.system.ephemere && it.system.duree == '1 round', { render: false })
|
||||||
await this.setEffect(STATUSES.StatusDemiReve, false)
|
await this.setEffect(STATUSES.StatusDemiReve, false)
|
||||||
@@ -2527,10 +2504,10 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
async equiperObjet(item) {
|
async equiperObjet(item) {
|
||||||
if (item?.isEquipable()) {
|
if (item?.isEquipable()) {
|
||||||
const isEquipe = !item.system.equipe;
|
const isEquipe = !item.system.equipe;
|
||||||
await item.update({ "system.equipe": isEquipe });
|
await item.update({ "system.equipe": isEquipe })
|
||||||
this.computeEncTotal()
|
this.computeEncTotal()
|
||||||
if (isEquipe)
|
if (isEquipe)
|
||||||
this.verifierForceMin(item);
|
this.verifierForceMin(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2673,10 +2650,10 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
async setPointsCoeur(subActorId, coeurs, options = { immediat: false }) {
|
async setPointsCoeur(subActorId, coeurs, options = { immediat: false }) {
|
||||||
const newSuivants = foundry.utils.duplicate(this.system.subacteurs.suivants)
|
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) {
|
if (amoureux) {
|
||||||
amoureux[options.immediat ? 'coeur' : 'prochainCoeur'] = coeurs
|
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);
|
let alreadyPresent = dataArray.find(attached => attached.id == subActor.id);
|
||||||
if (!alreadyPresent) {
|
if (!alreadyPresent) {
|
||||||
let newArray = [...dataArray, subActor]
|
let newArray = [...dataArray, subActor]
|
||||||
await this.update({ [dataPath]: newArray });
|
await this.update({ [dataPath]: newArray })
|
||||||
} else {
|
} 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) {
|
async deleteSubActeur(actorId) {
|
||||||
['vehicules', 'suivants', 'montures'].forEach(async type => {
|
['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)) {
|
if (subList.find(it => it.id == actorId)) {
|
||||||
let newList = subList.filter(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) {
|
async buildPotionGuerisonList(pointsGuerison) {
|
||||||
const pointsGuerisonInitial = pointsGuerison;
|
const pointsGuerisonInitial = pointsGuerison
|
||||||
const blessures = this.filterItems(it => it.system.gravite > 0, 'blessure').sort(Misc.descending(it => it.system.gravite))
|
const blessures = this.filterItems(it => it.system.gravite > 0, 'blessure')
|
||||||
|
.sort(Misc.descending(it => it.system.gravite))
|
||||||
const ids = []
|
const ids = []
|
||||||
const guerisonData = { list: [], pointsConsommes: 0 }
|
const guerisonData = { list: [], pointsConsommes: 0 }
|
||||||
for (let blessure of blessures) {
|
for (let blessure of blessures) {
|
||||||
@@ -2776,14 +2754,14 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ids.length > 0) {
|
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) {
|
if (blessures.length == ids.length) {
|
||||||
let pvManquants = this.system.sante.vie.max - this.system.sante.vie.value;
|
let pvManquants = this.system.sante.vie.max - this.system.sante.vie.value;
|
||||||
let pvSoignees = Math.min(pvManquants, Math.floor(pointsGuerison / 2));
|
let pvSoignees = Math.min(pvManquants, Math.floor(pointsGuerison / 2));
|
||||||
pointsGuerison -= pvSoignees * 2;
|
pointsGuerison -= pvSoignees * 2;
|
||||||
guerisonData.list.push(pvSoignees + " Points de Vie soignés");
|
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;
|
guerisonData.pointsConsommes = pointsGuerisonInitial - pointsGuerison;
|
||||||
return guerisonData;
|
return guerisonData;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
|
|
||||||
computeResumeBlessure() { }
|
computeResumeBlessure() { }
|
||||||
countBlessures(filter = it => !it.isContusion()) { return 0 }
|
countBlessures(filter = it => !it.isContusion()) { return 0 }
|
||||||
async santeIncDec(name, inc, options = {}) { }
|
async santeIncDec(name, inc, isCritique) { }
|
||||||
|
|
||||||
async finDeRound(options = { terminer: false }) {
|
async finDeRound(options = { terminer: false }) {
|
||||||
await this.finDeRoundSuppressionEffetsTermines(options)
|
await this.finDeRoundSuppressionEffetsTermines(options)
|
||||||
@@ -255,15 +255,15 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
if (competence) {
|
if (competence) {
|
||||||
function getFieldPath(fieldName) {
|
function getFieldPath(fieldName) {
|
||||||
switch (fieldName) {
|
switch (fieldName) {
|
||||||
case "niveau": return 'system.niveau';
|
case "niveau": return 'system.niveau'
|
||||||
case "dommages": return 'system.dommages';
|
case "dommages": return 'system.dommages'
|
||||||
case "carac_value": return 'system.carac_value';
|
case "carac_value": return 'system.carac_value'
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
const path = getFieldPath(fieldName);
|
const path = getFieldPath(fieldName)
|
||||||
if (path) {
|
if (path) {
|
||||||
await competence.update({ [path]: value });
|
await competence.update({ [path]: value })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,10 +125,10 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
blessure.system.vie = blessure.system.vie
|
blessure.system.vie = blessure.system.vie
|
||||||
const rollPerteEndurance = new Roll(blessure.system.endurance)
|
const rollPerteEndurance = new Roll(blessure.system.endurance)
|
||||||
await rollPerteEndurance.evaluate()
|
await rollPerteEndurance.evaluate()
|
||||||
blessure.system.endurance =rollPerteEndurance.total
|
blessure.system.endurance = rollPerteEndurance.total
|
||||||
}
|
}
|
||||||
const isCritique = blessure.system.gravite >= 6;
|
const isCritique = blessure.system.gravite >= 6;
|
||||||
if (isCritique){
|
if (isCritique) {
|
||||||
blessure.system.endurance = this.getEnduranceActuelle()
|
blessure.system.endurance = this.getEnduranceActuelle()
|
||||||
}
|
}
|
||||||
// Will update the result table
|
// Will update the result table
|
||||||
@@ -137,8 +137,8 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
encaissement.mort = "à seconde blessure critique"
|
encaissement.mort = "à seconde blessure critique"
|
||||||
}
|
}
|
||||||
|
|
||||||
const perteVie = await this.santeIncDec("vie", -encaissement.vie, { render: false })
|
const perteVie = await this.santeIncDec("vie", -encaissement.vie)
|
||||||
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, { isCritique, render: false })
|
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, isCritique)
|
||||||
await this.createEmbeddedDocuments('Item', [blessure])
|
await this.createEmbeddedDocuments('Item', [blessure])
|
||||||
|
|
||||||
foundry.utils.mergeObject(encaissement, {
|
foundry.utils.mergeObject(encaissement, {
|
||||||
@@ -152,7 +152,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async santeIncDec(name, inc, options = {}) {
|
async santeIncDec(name, inc, isCritique = false) {
|
||||||
if (name == 'fatigue' && !ReglesOptionnelles.isUsing("appliquer-fatigue")) {
|
if (name == 'fatigue' && !ReglesOptionnelles.isUsing("appliquer-fatigue")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -164,16 +164,16 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
const result = { sonne: false }
|
const result = { sonne: false }
|
||||||
let perteEndurance = 0
|
let perteEndurance = 0
|
||||||
let minValue = name == "vie" ? -this.getSConst() - 1 : 0;
|
let minValue = name == "vie" ? -this.getSConst() - 1 : 0;
|
||||||
|
|
||||||
result.newValue = Math.max(minValue, Math.min(compteur.value + inc, compteur.max));
|
result.newValue = Math.max(minValue, Math.min(compteur.value + inc, compteur.max));
|
||||||
let fatigue = 0;
|
let fatigue = 0;
|
||||||
|
|
||||||
if (name == "endurance" && result.newValue == 0 && inc < 0 && !options.isCritique) { // perte endurance et endurance devient 0 (sauf critique) -> -1 vie
|
|
||||||
sante.vie.value--;
|
|
||||||
result.perteVie = true;
|
|
||||||
}
|
|
||||||
foundry.utils.mergeObject(options, { render: true }, { overwrite: false })
|
|
||||||
if (name == "endurance") {
|
if (name == "endurance") {
|
||||||
|
if (result.newValue == 0 && inc < 0 && !isCritique) {
|
||||||
|
// perte endurance et endurance devient 0 (sauf critique) -> -1 vie
|
||||||
|
sante.vie.value--
|
||||||
|
result.perteVie = true
|
||||||
|
}
|
||||||
result.newValue = Math.max(0, result.newValue);
|
result.newValue = Math.max(0, result.newValue);
|
||||||
if (inc > 0) { // le max d'endurance s'applique seulement à la récupération
|
if (inc > 0) { // le max d'endurance s'applique seulement à la récupération
|
||||||
result.newValue = Math.min(result.newValue, this._computeEnduranceMax())
|
result.newValue = Math.min(result.newValue, this._computeEnduranceMax())
|
||||||
@@ -189,17 +189,17 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
if (ReglesOptionnelles.isUsing("appliquer-fatigue") && sante.fatigue && fatigue > 0) {
|
if (ReglesOptionnelles.isUsing("appliquer-fatigue") && sante.fatigue && fatigue > 0) {
|
||||||
sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this.getFatigueMin());
|
sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this.getFatigueMin());
|
||||||
}
|
}
|
||||||
await this.update({ "system.sante": sante }, options)
|
await this.update({ "system.sante": sante })
|
||||||
|
|
||||||
if (perteEndurance > 1) {
|
if (perteEndurance > 1) {
|
||||||
// Peut-être sonné si 2 points d'endurance perdus d'un coup
|
// Peut-être sonné si 2 points d'endurance perdus d'un coup
|
||||||
foundry.utils.mergeObject(result, await this.jetEndurance(result.newValue, options));
|
foundry.utils.mergeObject(result, await this.jetEndurance(result.newValue));
|
||||||
} else if (name == "endurance" && inc > 0) {
|
} else if (name == "endurance" && inc > 0) {
|
||||||
await this.setSonne(false, options)
|
await this.setSonne(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isDead()) {
|
if (this.isDead()) {
|
||||||
await this.setEffect(STATUSES.StatusComma, true, options)
|
await this.setEffect(STATUSES.StatusComma, true)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -349,10 +349,10 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async supprimerBlessures(filterToDelete, options = { render: true}) {
|
async supprimerBlessures(filterToDelete) {
|
||||||
const toDelete = this.filterItems(filterToDelete, ITEM_TYPES.blessure)
|
const toDelete = this.filterItems(filterToDelete, ITEM_TYPES.blessure)
|
||||||
.map(it => it.id)
|
.map(it => it.id)
|
||||||
await this.deleteEmbeddedDocuments('Item', toDelete, options)
|
await this.deleteEmbeddedDocuments('Item', toDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
countBlessures(filter = it => !it.isContusion()) {
|
countBlessures(filter = it => !it.isContusion()) {
|
||||||
@@ -369,7 +369,6 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const jetDeVie = await RdDDice.roll("1d20");
|
const jetDeVie = await RdDDice.roll("1d20");
|
||||||
|
|
||||||
const sConst = this.getSConst();
|
const sConst = this.getSConst();
|
||||||
const vie = this.system.sante.vie.value;
|
const vie = this.system.sante.vie.value;
|
||||||
const isCritique = this.nbBlessuresCritiques() > 0;
|
const isCritique = this.nbBlessuresCritiques() > 0;
|
||||||
@@ -395,15 +394,15 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
content: msgText,
|
content: msgText,
|
||||||
whisper: ChatUtility.getOwners(this)
|
whisper: ChatUtility.getOwners(this)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async jetEndurance(resteEndurance = undefined, options) {
|
async jetEndurance(resteEndurance = undefined) {
|
||||||
const jetEndurance = (await RdDDice.roll("1d20")).total;
|
const jetEndurance = (await RdDDice.roll("1d20")).total;
|
||||||
const sonne = jetEndurance == 20 || jetEndurance > (resteEndurance ?? this.system.sante.endurance.value)
|
const sonne = jetEndurance == 20 || jetEndurance > (resteEndurance ?? this.system.sante.endurance.value)
|
||||||
if (sonne) {
|
if (sonne) {
|
||||||
await this.setSonne(true, options)
|
await this.setSonne(true)
|
||||||
}
|
}
|
||||||
return { jetEndurance, sonne }
|
return { jetEndurance, sonne }
|
||||||
}
|
}
|
||||||
@@ -417,13 +416,13 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSonne(sonne = true, options = {}) {
|
async setSonne(sonne = true) {
|
||||||
if (!game.combat && sonne) {
|
if (!game.combat && sonne) {
|
||||||
// TODO: vérifier si comportement toujours valable
|
// TODO: vérifier si comportement toujours valable
|
||||||
ui.notifications.info(`${this.getAlias()} est hors combat, il ne reste donc pas sonné`);
|
ui.notifications.info(`${this.getAlias()} est hors combat, il ne reste donc pas sonné`);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await this.setEffect(STATUSES.StatusStunned, sonne, options)
|
await this.setEffect(STATUSES.StatusStunned, sonne)
|
||||||
}
|
}
|
||||||
|
|
||||||
isSonne() {
|
isSonne() {
|
||||||
|
|||||||
+46
-15
@@ -97,16 +97,7 @@ export class RdDBaseActor extends Actor {
|
|||||||
return actor ?? game.actors.get(actorId)
|
return actor ?? game.actors.get(actorId)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAlias() {
|
static extractActorMin(actor) { return { id: actor?.id, type: actor?.type, name: actor?.name, img: actor?.img } }
|
||||||
if (this.token?.name != null && this.token != this.prototypeToken) {
|
|
||||||
return this.token.name
|
|
||||||
}
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
isPersonnageJoueur() { return false }
|
|
||||||
|
|
||||||
static extractActorMin = (actor) => { return { id: actor?.id, type: actor?.type, name: actor?.name, img: actor?.img }; };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cette methode surcharge Actor.create() pour ajouter si besoin des Items par défaut:
|
* Cette methode surcharge Actor.create() pour ajouter si besoin des Items par défaut:
|
||||||
@@ -151,6 +142,15 @@ export class RdDBaseActor extends Actor {
|
|||||||
super(docData, context);
|
super(docData, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAlias() {
|
||||||
|
if (this.token?.name != null && this.token != this.prototypeToken) {
|
||||||
|
return this.token.name
|
||||||
|
}
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
isPersonnageJoueur() { return false }
|
||||||
|
|
||||||
getCarac() {
|
getCarac() {
|
||||||
return foundry.utils.duplicate(this.system.carac)
|
return foundry.utils.duplicate(this.system.carac)
|
||||||
}
|
}
|
||||||
@@ -216,6 +216,41 @@ export class RdDBaseActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _preUpdate(changed, options, user) {
|
||||||
|
const updatedCarac = changed?.system?.carac
|
||||||
|
if (updatedCarac && (updatedCarac.force || updatedCarac.reve || updatedCarac.taille)) {
|
||||||
|
await this.setEffect(STATUSES.StatusSurEnc, this.isSurenc())
|
||||||
|
}
|
||||||
|
await this.delayedRenderSheet('_preUpdate', changed, options)
|
||||||
|
return super._preUpdate(changed, options, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
_onUpdate(changed, options, userId) {
|
||||||
|
super._onUpdate(changed, options, userId)
|
||||||
|
if (userId == game.user.id){
|
||||||
|
this.delayedRenderSheet('_onUpdate', changed, options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async delayedRenderSheet(caller, data, options) {
|
||||||
|
this.refreshDelayCounter = (this.refreshDelayCounter ?? 0)+1
|
||||||
|
if (this.refreshDelayCounter == 1) {
|
||||||
|
this.renderAfterDelay(this.refreshDelayCounter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderAfterDelay(currentCounter) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
if (currentCounter == this.refreshDelayCounter) {
|
||||||
|
this.sheet?.render(true)
|
||||||
|
this.refreshDelayCounter = 0
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.renderAfterDelay(this.refreshDelayCounter)
|
||||||
|
}
|
||||||
|
}, 30)
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
prepareData() {
|
prepareData() {
|
||||||
super.prepareData()
|
super.prepareData()
|
||||||
@@ -228,6 +263,7 @@ export class RdDBaseActor extends Actor {
|
|||||||
prepareActorData() { }
|
prepareActorData() { }
|
||||||
|
|
||||||
async computeEtatGeneral() { }
|
async computeEtatGeneral() { }
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
findPlayer() {
|
findPlayer() {
|
||||||
return game.users.players.find(player => player.active && player.character?.id == this.id);
|
return game.users.players.find(player => player.active && player.character?.id == this.id);
|
||||||
@@ -322,11 +358,6 @@ export class RdDBaseActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onUpdateActor(change, options, actorId) {
|
async onUpdateActor(change, options, actorId) {
|
||||||
const updatedCarac = change?.system?.carac
|
|
||||||
if (updatedCarac && (updatedCarac.force || updatedCarac.reve || updatedCarac.taille)) {
|
|
||||||
console.log(' onUpdateActor', change, options, actorId)
|
|
||||||
await this.setEffect(STATUSES.StatusSurEnc, this.isSurenc())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ export class RdDCreature extends RdDBaseActorSang {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async remiseANeuf() {
|
async remiseANeuf() {
|
||||||
await this.removeEffects(e => true, { render: false })
|
await this.removeEffects(e => true)
|
||||||
await this.supprimerBlessures(it => true, { render: false })
|
await this.supprimerBlessures(it => true)
|
||||||
await this.update({
|
await this.update({
|
||||||
'system.sante.endurance.value': this.system.sante.endurance.max,
|
'system.sante.endurance.value': this.system.sante.endurance.max,
|
||||||
'system.sante.vie.value': this.system.sante.vie.max,
|
'system.sante.vie.value': this.system.sante.vie.max,
|
||||||
'system.sante.fatigue.value': 0
|
'system.sante.fatigue.value': 0
|
||||||
}, { render: true });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async finDeRoundBlessures() {
|
async finDeRoundBlessures() {
|
||||||
|
|||||||
@@ -76,6 +76,6 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet {
|
|||||||
async resonanceDelete(actorId) {
|
async resonanceDelete(actorId) {
|
||||||
console.log('Delete : ', actorId);
|
console.log('Delete : ', actorId);
|
||||||
let newResonances = this.actor.system.sante.resonnance.actors.filter(id => id != actorId);
|
let newResonances = this.actor.system.sante.resonnance.actors.filter(id => id != actorId);
|
||||||
await this.actor.update({ 'system.sante.resonnance.actors': newResonances }, { renderSheet: false });
|
await this.actor.update({ 'system.sante.resonnance.actors': newResonances }, { render: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ export class RdDEntite extends RdDBaseActorReve {
|
|||||||
|
|
||||||
async remiseANeuf() {
|
async remiseANeuf() {
|
||||||
if (!this.isEntiteNonIncarnee()) {
|
if (!this.isEntiteNonIncarnee()) {
|
||||||
await this.update({
|
await this.update({ 'system.sante.endurance.value': this.system.sante.endurance.max })
|
||||||
'system.sante.endurance.value': this.system.sante.endurance.max
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
await this.removeEffects(e => true)
|
await this.removeEffects(e => true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
export class RdDActiveEffect extends ActiveEffect {
|
||||||
|
|
||||||
|
async _preCreate(data, options, user) {
|
||||||
|
await this.parent?.delayedRenderSheet('_preCreateEffect', data, options)
|
||||||
|
return super._preCreate(data, options, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
async _preUpdate(changed, options, user) {
|
||||||
|
await this.parent?.delayedRenderSheet('_preUpdateEffect', changed, options)
|
||||||
|
return super._preUpdate(changed, options, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
async _preDelete(options, user) {
|
||||||
|
await this.parent?.delayedRenderSheet('_preDeleteEffect', { id: this.id }, options)
|
||||||
|
return super._preDelete(options, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+15
-1
@@ -116,7 +116,6 @@ export class RdDItem extends Item {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static itemTypePluriel(type) {
|
static itemTypePluriel(type) {
|
||||||
if (ITEM_TYPES[type]) {
|
if (ITEM_TYPES[type]) {
|
||||||
return ITEM_TYPES_PLURIEL[type] ?? (type + 's')
|
return ITEM_TYPES_PLURIEL[type] ?? (type + 's')
|
||||||
@@ -175,6 +174,21 @@ export class RdDItem extends Item {
|
|||||||
super(docData, context);
|
super(docData, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _preCreate(data, options, user) {
|
||||||
|
await this.parent?.delayedRenderSheet('_preCreateItem', data, options)
|
||||||
|
return super._preCreate(data, options, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
async _preUpdate(changed, options, user) {
|
||||||
|
await this.parent?.delayedRenderSheet('_preUpdateItem', changed, options)
|
||||||
|
return super._preUpdate(changed, options, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
async _preDelete(options, user) {
|
||||||
|
await this.parent?.delayedRenderSheet('_preDeleteItem', { id: this.id }, options)
|
||||||
|
return super._preDelete(options, user)
|
||||||
|
}
|
||||||
|
|
||||||
getUniteQuantite() {
|
getUniteQuantite() {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case ITEM_TYPES.monnaie: return "(Pièces)"
|
case ITEM_TYPES.monnaie: return "(Pièces)"
|
||||||
|
|||||||
@@ -106,11 +106,9 @@ export class RdDItemBlessure extends RdDItem {
|
|||||||
async updateTacheSoinBlessure(tache) {
|
async updateTacheSoinBlessure(tache) {
|
||||||
if (tache) {
|
if (tache) {
|
||||||
await tache.update({
|
await tache.update({
|
||||||
system: {
|
'system.itemId': this.id,
|
||||||
itemId: this.id,
|
'system.difficulte': Math.min(this.system.difficulte, tache.system.difficulte),
|
||||||
difficulte: Math.min(this.system.difficulte, tache.system.difficulte),
|
'system.points_de_tache_courant': Math.max(0, this.system.premierssoins.tache)
|
||||||
points_de_tache_courant: Math.max(0, this.system.premierssoins.tache)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +160,7 @@ export class RdDItemBlessure extends RdDItem {
|
|||||||
message.content += ` -- une blessure ${label} reste stable`;
|
message.content += ` -- une blessure ${label} reste stable`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.update(update);
|
await this.update(update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,41 +77,41 @@ export class RdDInventaireItemSheet extends RdDItemSheetV1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onAddMilieu(event) {
|
async onAddMilieu(event) {
|
||||||
const milieu = this.html.find('input.input-selection-milieu').val();
|
const milieu = this.html.find('input.input-selection-milieu').val()
|
||||||
if (!milieu) {
|
if (!milieu) {
|
||||||
ui.notifications.warn(`Choisissez le milieu dans lequel se trouve le/la ${this.item.name}`);
|
ui.notifications.warn(`Choisissez le milieu dans lequel se trouve le/la ${this.item.name}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const list = this.item.getEnvironnements();
|
const list = this.item.getEnvironnements()
|
||||||
const exists = list.find(it => it.milieu == milieu);
|
const exists = list.find(it => it.milieu == milieu)
|
||||||
if (exists) {
|
if (exists) {
|
||||||
ui.notifications.warn(`${this.item.name} a déjà une rareté ${exists.rarete} en ${milieu} (fréquence: ${exists.frequence})`);
|
ui.notifications.warn(`${this.item.name} a déjà une rareté ${exists.rarete} en ${milieu} (fréquence: ${exists.frequence})`);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const rarete = RdDRaretes.rareteFrequente();
|
const rarete = RdDRaretes.rareteFrequente()
|
||||||
const added = { milieu, rarete: rarete.code, frequence: rarete.frequence };
|
const added = { milieu, rarete: rarete.code, frequence: rarete.frequence }
|
||||||
const newList = [added, ...list].sort(Misc.ascending(it => it.milieu))
|
const newList = [added, ...list].sort(Misc.ascending(it => it.milieu))
|
||||||
await this.item.update({ 'system.environnement': newList })
|
await this.item.update({ 'system.environnement': newList })
|
||||||
}
|
}
|
||||||
|
|
||||||
async onDeleteMilieu(event) {
|
async onDeleteMilieu(event) {
|
||||||
const milieu = this.$getEventMilieu(event);
|
const milieu = this.$getEventMilieu(event)
|
||||||
if (milieu != undefined) {
|
if (milieu != undefined) {
|
||||||
const newList = this.item.getEnvironnements().filter(it => it.milieu != milieu)
|
const newList = this.item.getEnvironnements().filter(it => it.milieu != milieu)
|
||||||
.sort(Misc.ascending(it => it.milieu));
|
.sort(Misc.ascending(it => it.milieu))
|
||||||
await this.item.update({ 'system.environnement': newList });
|
await this.item.update({ 'system.environnement': newList })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onChange(event, doMutation) {
|
async onChange(event, doMutation) {
|
||||||
const list = this.item.system.environnement;
|
const list = this.item.system.environnement
|
||||||
const milieu = this.$getEventMilieu(event);
|
const milieu = this.$getEventMilieu(event)
|
||||||
const updated = list.find(it => it.milieu == milieu);
|
const updated = list.find(it => it.milieu == milieu)
|
||||||
if (updated) {
|
if (updated) {
|
||||||
doMutation(updated);
|
doMutation(updated)
|
||||||
const newList = [...list.filter(it => it.milieu != milieu), updated]
|
const newList = [...list.filter(it => it.milieu != milieu), updated]
|
||||||
.sort(Misc.ascending(it => it.milieu));
|
.sort(Misc.ascending(it => it.milieu))
|
||||||
await this.item.update({ 'system.environnement': newList });
|
await this.item.update({ 'system.environnement': newList })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export class RdDFauneItemSheet extends RdDInventaireItemSheet {
|
|||||||
'system.actor.pack': linkedActor.pack,
|
'system.actor.pack': linkedActor.pack,
|
||||||
'system.actor.id': linkedActor._id,
|
'system.actor.id': linkedActor._id,
|
||||||
'system.actor.name': linkedActor.name
|
'system.actor.name': linkedActor.name
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui.notifications.warn(`${linkedActor.name} ne provient pas d'un compendium.
|
ui.notifications.warn(`${linkedActor.name} ne provient pas d'un compendium.
|
||||||
@@ -32,7 +32,7 @@ export class RdDFauneItemSheet extends RdDInventaireItemSheet {
|
|||||||
'system.actor.pack': '',
|
'system.actor.pack': '',
|
||||||
'system.actor.id': '',
|
'system.actor.id': '',
|
||||||
'system.actor.name': ''
|
'system.actor.name': ''
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ import ChatRollResult from "./roll/chat-roll-result.mjs"
|
|||||||
import ExportPdf from "./actor/export-pdf/export-pdf.mjs"
|
import ExportPdf from "./actor/export-pdf/export-pdf.mjs"
|
||||||
import { DialogFlushByDate } from "./chat/dialog-flush-by-date.mjs"
|
import { DialogFlushByDate } from "./chat/dialog-flush-by-date.mjs"
|
||||||
import { Remote } from "./remote.mjs"
|
import { Remote } from "./remote.mjs"
|
||||||
|
import { RdDActiveEffect } from "./effect/base-active-effect.js"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RdD system
|
* RdD system
|
||||||
@@ -199,6 +200,7 @@ export class SystemReveDeDragon {
|
|||||||
// Define custom Entity classes
|
// Define custom Entity classes
|
||||||
console.log(`Initializing Reve de Dragon Documents`)
|
console.log(`Initializing Reve de Dragon Documents`)
|
||||||
CONFIG.Actor.documentClass = RdDBaseActor
|
CONFIG.Actor.documentClass = RdDBaseActor
|
||||||
|
CONFIG.ActiveEffect.documentClass = RdDActiveEffect
|
||||||
CONFIG.Item.documentClass = RdDItem
|
CONFIG.Item.documentClass = RdDItem
|
||||||
CONFIG.Item.dataModels = {
|
CONFIG.Item.dataModels = {
|
||||||
monnaie: models.RdDModelMonnaie,
|
monnaie: models.RdDModelMonnaie,
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ export class EffetsRencontre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static regain_seuil = async (dialog, context) => {
|
static regain_seuil = async (dialog, context) => {
|
||||||
await context.actor.regainPointDeSeuil()
|
await context.actor.recuperationSeuilReve()
|
||||||
}
|
}
|
||||||
|
|
||||||
static async $reinsertion(dialog, actor, filter) {
|
static async $reinsertion(dialog, actor, filter) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{{#if system.reve.reve.thanatosused}}
|
{{#if system.reve.reve.thanatosused}}
|
||||||
<li class="item flexrow" >
|
<li class="item flexrow" >
|
||||||
<span class="generic-label">La prochaine queue est une Ombre</span>
|
<span class="generic-label">La prochaine queue est une Ombre de thanatos</span>
|
||||||
<span>
|
<span>
|
||||||
<img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/competence_thanatos.webp"/>
|
<img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/competence_thanatos.webp"/>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user