Merge pull request 'v10.6.15' (#626) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10
Reviewed-on: #626
This commit is contained in:
commit
f229537206
193
module/actor.js
193
module/actor.js
@ -360,31 +360,19 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
dialog.render(true);
|
dialog.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async prepareChateauDormant(finChateauDormant, consignes) {
|
async prepareChateauDormant(consigne) {
|
||||||
if (consignes.ignorer) {
|
if (consigne.ignorer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (consignes.stress.valeur > 0) {
|
if (consigne.stress.valeur > 0) {
|
||||||
await this.distribuerStress('stress', consignes.stress.valeur, consignes.stress.motif);
|
await this.distribuerStress('stress', consigne.stress.valeur, consigne.stress.motif);
|
||||||
}
|
|
||||||
if (!consignes.sommeil?.insomnie) {
|
|
||||||
await this.update({
|
|
||||||
"system.sommeil": {
|
|
||||||
nouveaujour: true,
|
|
||||||
date: finChateauDormant,
|
|
||||||
moral: consignes.sommeil?.moral ?? 'neutre',
|
|
||||||
heures: consignes.sommeil?.heures ?? 4
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
await this.update({ 'system.sommeil': consigne.sommeil })
|
||||||
}
|
}
|
||||||
|
|
||||||
async onTimeChanging(oldTimestamp, newTimestamp) {
|
async onTimeChanging(oldTimestamp, newTimestamp) {
|
||||||
await super.onTimeChanging(oldTimestamp, newTimestamp);
|
await super.onTimeChanging(oldTimestamp, newTimestamp);
|
||||||
const insomnie = EffetsDraconiques.isSujetInsomnie(this);
|
await this.setInfoSommeilInsomnie();
|
||||||
if (!this.system.sommeil || this.system.sommeil.insomnie || insomnie) {
|
|
||||||
await this.update({ 'system.sommeil.insomnie': insomnie });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async repos() {
|
async repos() {
|
||||||
@ -409,22 +397,15 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
await this.transformerStress();
|
await this.transformerStress();
|
||||||
this.bonusRecuperationPotion = 0; // Reset potion
|
this.bonusRecuperationPotion = 0; // Reset potion
|
||||||
}
|
}
|
||||||
await this.update({
|
await this.resetInfoSommeil()
|
||||||
"system.sommeil": {
|
|
||||||
nouveaujour: false,
|
|
||||||
moral: "neutre",
|
|
||||||
heures: 0
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
ChatMessage.create(message);
|
ChatMessage.create(message);
|
||||||
this.sheet.render(true);
|
this.sheet.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _recuperationSante(message) {
|
async _recuperationSante(message) {
|
||||||
const maladiesPoisons = this._maladiePoisons(message);
|
const maladiesPoisons = this._maladiePoisons(message);
|
||||||
this._messageRecuperationMaladiePoisons(maladiesPoisons, message);
|
|
||||||
const isMaladeEmpoisonne = maladiesPoisons.length > 0;
|
const isMaladeEmpoisonne = maladiesPoisons.length > 0;
|
||||||
|
this._messageRecuperationMaladiePoisons(maladiesPoisons, message);
|
||||||
const blessures = duplicate(this.system.blessures);
|
const blessures = duplicate(this.system.blessures);
|
||||||
await this._recupererBlessures(message, "legere", blessures.legeres.liste.filter(b => b.active), [], isMaladeEmpoisonne);
|
await this._recupererBlessures(message, "legere", blessures.legeres.liste.filter(b => b.active), [], isMaladeEmpoisonne);
|
||||||
await this._recupererBlessures(message, "grave", blessures.graves.liste.filter(b => b.active), blessures.legeres.liste, isMaladeEmpoisonne);
|
await this._recupererBlessures(message, "grave", blessures.graves.liste.filter(b => b.active), blessures.legeres.liste, isMaladeEmpoisonne);
|
||||||
@ -438,10 +419,10 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
return actifs;
|
return actifs;
|
||||||
}
|
}
|
||||||
|
|
||||||
_messageRecuperationMaladiePoisons(actifs, message) {
|
_messageRecuperationMaladiePoisons(maladiesPoisons, message) {
|
||||||
if (actifs.length > 0) {
|
if (maladiesPoisons.length > 0) {
|
||||||
const identifies = actifs.filter(it => it.system.identifie);
|
const identifies = maladiesPoisons.filter(it => it.system.identifie);
|
||||||
const nonIdentifies = actifs.filter(it => !it.system.identifie);
|
const nonIdentifies = maladiesPoisons.filter(it => !it.system.identifie);
|
||||||
message.content += 'Vous souffrez';
|
message.content += 'Vous souffrez';
|
||||||
switch (nonIdentifies.length) {
|
switch (nonIdentifies.length) {
|
||||||
case 0: break;
|
case 0: break;
|
||||||
@ -460,7 +441,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async dormirChateauDormant() {
|
async dormirChateauDormant() {
|
||||||
if (!ReglesOptionelles.isUsing("chateau-dormant-gardien") || !this.system.sommeil || this.system.sommeil?.nouveaujour) {
|
if (!ReglesOptionelles.isUsing("chateau-dormant-gardien") || !this.system.sommeil || this.system.sommeil.nouveaujour) {
|
||||||
const message = {
|
const message = {
|
||||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
||||||
content: ""
|
content: ""
|
||||||
@ -469,9 +450,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
await this._recuperationSante(message)
|
await this._recuperationSante(message)
|
||||||
await this._jetDeMoralChateauDormant(message);
|
await this._jetDeMoralChateauDormant(message);
|
||||||
await this._recupereChance();
|
await this._recupereChance();
|
||||||
if (!this.system.sommeil?.insomnie) {
|
await this.transformerStress();
|
||||||
await this.transformerStress();
|
|
||||||
}
|
|
||||||
await this.retourSeuilDeReve(message);
|
await this.retourSeuilDeReve(message);
|
||||||
this.bonusRecuperationPotion = 0; // Reset potion
|
this.bonusRecuperationPotion = 0; // Reset potion
|
||||||
await this.retourSust(message);
|
await this.retourSust(message);
|
||||||
@ -480,17 +459,31 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
||||||
ChatMessage.create(message);
|
ChatMessage.create(message);
|
||||||
}
|
}
|
||||||
await this.update({
|
await this.resetInfoSommeil();
|
||||||
"system.sommeil": {
|
|
||||||
nouveaujour: false,
|
|
||||||
moral: "neutre",
|
|
||||||
heures: 0
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.sheet.render(true);
|
this.sheet.render(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async resetInfoSommeil() {
|
||||||
|
await this.update({
|
||||||
|
'system.sommeil': {
|
||||||
|
nouveaujour: false,
|
||||||
|
date: game.system.rdd.calendrier.getTimestamp(),
|
||||||
|
moral: "neutre",
|
||||||
|
heures: 0,
|
||||||
|
insomnie: EffetsDraconiques.isSujetInsomnie(this)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async setInfoSommeilInsomnie() {
|
||||||
|
await this.update({ 'system.sommeil.insomnie': EffetsDraconiques.isSujetInsomnie(this) });
|
||||||
|
}
|
||||||
|
|
||||||
|
async setInfoSommeilMoral(situationMoral) {
|
||||||
|
await this.update({ 'system.sommeil.moral': situationMoral });
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _recupereChance() {
|
async _recupereChance() {
|
||||||
// On ne récupère un point de chance que si aucun appel à la chance dans la journée
|
// On ne récupère un point de chance que si aucun appel à la chance dans la journée
|
||||||
@ -639,50 +632,32 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async dormir(sommeilHeures, options = { grisReve: false, chateauDormant: false }) {
|
async dormir(heures, options = { grisReve: false, chateauDormant: false }) {
|
||||||
const sommeil = !this.system.sommeil?.insomnie || options.grisReve;
|
|
||||||
const message = {
|
const message = {
|
||||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
||||||
content: ""
|
content: this.name + ': '
|
||||||
};
|
};
|
||||||
await this.recupereEndurance(message);
|
await this.recupereEndurance(message);
|
||||||
let sep = ""
|
if (this.system.sommeil?.insomnie || heures == 0) {
|
||||||
let recuperationReve = "";
|
message.content += 'Vous ne trouvez pas le sommeil';
|
||||||
let heuresDormies = 0;
|
|
||||||
for (; heuresDormies < sommeilHeures; heuresDormies++) {
|
|
||||||
await this._recupererEthylisme(message);
|
|
||||||
if (sommeil) {
|
|
||||||
await this.recupererFatigue(message);
|
|
||||||
if (!options.grisReve) {
|
|
||||||
if (sommeil) {
|
|
||||||
let r = await this.recuperationReve(message);
|
|
||||||
if (r >= 0) {
|
|
||||||
recuperationReve += sep + r;
|
|
||||||
sep = "+";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r >= 0 && EffetsDraconiques.isDonDoubleReve(this)) {
|
|
||||||
r = await this.recuperationReve(message);
|
|
||||||
if (r >= 0) {
|
|
||||||
recuperationReve += sep + r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r < 0) {
|
|
||||||
heuresDormies++;// rêve de dragon pendant l'heure en cours
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
let jetsReve = [];
|
||||||
|
let dormi = await this.dormirDesHeures(jetsReve, message, heures, options);
|
||||||
|
message.content += `Vous dormez ${dormi.heures <= 1 ? 'une heure' : (dormi.heures + ' heures')}. `;
|
||||||
|
if (jetsReve.length > 0) {
|
||||||
|
message.content += `Vous récupérez ${jetsReve.filter(it => it >= 0).reduce(Misc.joining("+"))} Points de rêve. `;
|
||||||
|
}
|
||||||
|
if (dormi.etat == 'eveil') {
|
||||||
|
message.content += 'Vous êtes réveillé par un Rêve de Dragon.'
|
||||||
|
}
|
||||||
|
options.chateauDormant = options.chateauDormant && dormi.heures == heures;
|
||||||
|
}
|
||||||
|
|
||||||
if (!options.grisReve) {
|
if (!options.grisReve) {
|
||||||
const repos = this.system.sommeil?.insomnie ? "vous reposez" : "dormez"
|
|
||||||
message.content = `${this.name}: Vous ${repos} ${heuresDormies <= 1 ? 'une heure' : (heuresDormies + ' heures')}. `
|
|
||||||
+ (recuperationReve == "" ? "" : `Vous récupérez ${recuperationReve} Points de rêve. `)
|
|
||||||
+ message.content;
|
|
||||||
ChatMessage.create(message);
|
ChatMessage.create(message);
|
||||||
}
|
}
|
||||||
if (options.chateauDormant && heuresDormies == sommeilHeures) {
|
if (options.chateauDormant) {
|
||||||
await this.dormirChateauDormant();
|
await this.dormirChateauDormant();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -690,6 +665,43 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async dormirDesHeures(jetsReve, message, heures, options) {
|
||||||
|
const dormi = { heures: 1, etat: 'dort' };
|
||||||
|
for (; dormi.heures <= heures && dormi.etat == 'dort'; dormi.heures++) {
|
||||||
|
await this._recupererEthylisme(message);
|
||||||
|
if (options.grisReve) {
|
||||||
|
await this.recupererFatigue(message);
|
||||||
|
}
|
||||||
|
else if (!this.system.sommeil?.insomnie) {
|
||||||
|
await this.recupererFatigue(message);
|
||||||
|
dormi.etat = await this.jetRecuperationReve(jetsReve, message);
|
||||||
|
if (dormi.etat == 'dort' && EffetsDraconiques.isDonDoubleReve(this)) {
|
||||||
|
dormi.etat = await this.jetRecuperationReve(jetsReve, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dormi;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async jetRecuperationReve(jetsReve, message) {
|
||||||
|
if (this.getReveActuel() < this.system.reve.seuil.value) {
|
||||||
|
let reve = await RdDDice.rollTotal("1dr");
|
||||||
|
if (reve >= 7) {
|
||||||
|
// Rêve de Dragon !
|
||||||
|
message.content += `Vous faites un <strong>Rêve de Dragon</strong> de ${reve} Points de rêve qui vous réveille! `;
|
||||||
|
await this.combattreReveDeDragon(reve);
|
||||||
|
jetsReve.push(-1);
|
||||||
|
return 'eveil';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await this.reveActuelIncDec(reve);
|
||||||
|
jetsReve.push(reve);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'dort';
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _recupererEthylisme(message) {
|
async _recupererEthylisme(message) {
|
||||||
let value = Math.min(Number.parseInt(this.system.compteurs.ethylisme.value) + 1, 1);
|
let value = Math.min(Number.parseInt(this.system.compteurs.ethylisme.value) + 1, 1);
|
||||||
@ -750,27 +762,6 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
return cumul;
|
return cumul;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async recuperationReve(message) {
|
|
||||||
const seuil = this.system.reve.seuil.value;
|
|
||||||
const reveActuel = this.getReveActuel();
|
|
||||||
if (reveActuel < seuil) {
|
|
||||||
let deRecuperation = await RdDDice.rollTotal("1dr");
|
|
||||||
console.log("recuperationReve", deRecuperation);
|
|
||||||
if (deRecuperation >= 7) {
|
|
||||||
// Rêve de Dragon !
|
|
||||||
message.content += `Vous faites un <strong>Rêve de Dragon</strong> de ${deRecuperation} Points de rêve qui vous réveille! `;
|
|
||||||
await this.combattreReveDeDragon(deRecuperation);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await this.reveActuelIncDec(deRecuperation);
|
|
||||||
return deRecuperation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async retourSeuilDeReve(message) {
|
async retourSeuilDeReve(message) {
|
||||||
const seuil = this.system.reve.seuil.value;
|
const seuil = this.system.reve.seuil.value;
|
||||||
@ -1922,7 +1913,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async transformerStress() {
|
async transformerStress() {
|
||||||
const stress = Number(this.system.compteurs.stress.value);
|
const stress = Number(this.system.compteurs.stress.value);
|
||||||
if (stress <= 0) {
|
if (this.system.sommeil?.insomnie || stress <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3841,7 +3832,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
await draconique.onActorCreateOwned(this, item)
|
await draconique.onActorCreateOwned(this, item)
|
||||||
this.notifyGestionTeteSouffleQueue(item, draconique.manualMessage());
|
this.notifyGestionTeteSouffleQueue(item, draconique.manualMessage());
|
||||||
}
|
}
|
||||||
await this.update({ 'system.sommeil.insomnie': EffetsDraconiques.isSujetInsomnie(this) });
|
await this.setInfoSommeilInsomnie();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
||||||
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
|
||||||
this._appliquerRechercheObjets(formData.objets, formData.conteneurs);
|
this._appliquerRechercheObjets(formData.objets, formData.conteneurs);
|
||||||
|
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +170,9 @@ export class RdDCalendrier extends Application {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getCurrentMinute() { return this.timestamp.indexMinute; }
|
getCurrentMinute() { return this.timestamp.indexMinute; }
|
||||||
|
|
||||||
|
getTimestamp() {
|
||||||
|
return this.timestamp;
|
||||||
|
}
|
||||||
getTimestampFinChateauDormant(nbJours = 0) {
|
getTimestampFinChateauDormant(nbJours = 0) {
|
||||||
return this.timestamp.nouveauJour().addJours(nbJours);
|
return this.timestamp.nouveauJour().addJours(nbJours);
|
||||||
}
|
}
|
||||||
@ -260,7 +263,7 @@ export class RdDCalendrier extends Application {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async setNewTimestamp(newTimestamp) {
|
async setNewTimestamp(newTimestamp) {
|
||||||
const oldTimestamp = this.timestamp;
|
const oldTimestamp = this.timestamp;
|
||||||
game.actors.forEach(actor => actor.onTimeChanging(oldTimestamp, newTimestamp));
|
await Promise.all(game.actors.map(async actor => await actor.onTimeChanging(oldTimestamp, newTimestamp)));
|
||||||
RdDTimestamp.setWorldTime(newTimestamp);
|
RdDTimestamp.setWorldTime(newTimestamp);
|
||||||
if (oldTimestamp.indexDate + 1 == newTimestamp.indexDate && ReglesOptionelles.isUsing("chateau-dormant-gardien")) {
|
if (oldTimestamp.indexDate + 1 == newTimestamp.indexDate && ReglesOptionelles.isUsing("chateau-dormant-gardien")) {
|
||||||
await DialogChateauDormant.create();
|
await DialogChateauDormant.create();
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
|
import { EffetsDraconiques } from "../tmr/effets-draconiques.js";
|
||||||
|
|
||||||
export class DialogChateauDormant extends Dialog {
|
export class DialogChateauDormant extends Dialog {
|
||||||
|
|
||||||
static async create() {
|
static async create() {
|
||||||
const date = game.system.rdd.calendrier.dateCourante();
|
const date = game.system.rdd.calendrier.dateCourante();
|
||||||
const actorsSettings = game.actors.filter(actor => actor.hasPlayerOwner && actor.isPersonnage())
|
const actors = game.actors.filter(actor => actor.hasPlayerOwner && actor.isPersonnage());
|
||||||
.map(actor => ({
|
|
||||||
actor: actor,
|
|
||||||
insomnie: actor.system.sommeil?.insomnie,
|
|
||||||
moral: 'neutre'
|
|
||||||
}));
|
|
||||||
|
|
||||||
const dialogData = {
|
const dialogData = {
|
||||||
actorsSettings,
|
actors: actors,
|
||||||
date: date,
|
date: date,
|
||||||
motifStress: `Nuit du ${date}`,
|
motifStress: `Nuit du ${date}`,
|
||||||
finChateauDormant: game.system.rdd.calendrier.getTimestampFinChateauDormant()
|
finChateauDormant: game.system.rdd.calendrier.getTimestampFinChateauDormant()
|
||||||
@ -65,44 +62,42 @@ export class DialogChateauDormant extends Dialog {
|
|||||||
const selected = this.html.find(event.currentTarget);
|
const selected = this.html.find(event.currentTarget);
|
||||||
const actorRow = selected.parents('.set-sommeil-actor');
|
const actorRow = selected.parents('.set-sommeil-actor');
|
||||||
const actorId = actorRow.data('actor-id');
|
const actorId = actorRow.data('actor-id');
|
||||||
const actorSetting = this.getActorSetting(actorId);
|
const actor = this.getActor(actorId);
|
||||||
if (actorSetting) {
|
actor.system.sommeil.moral = selected.data('moral');
|
||||||
actorSetting.moral = selected.data('moral');
|
const htmlMoral = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs', actor.system.sommeil)
|
||||||
const htmlMoral = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs', actorSetting)
|
actorRow.find('.sommeil-actor-moral').html(htmlMoral);
|
||||||
actorRow.find('.sommeil-actor-moral').html(htmlMoral);
|
// re-attach listeners for actor row
|
||||||
// re-attach listeners for actor row
|
this._activateListenerOnActorMoral(actorRow);
|
||||||
this._activateListenerOnActorMoral(actorRow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getActorSetting(actorId) {
|
getActor(actorId) {
|
||||||
return this.dialogData.actorsSettings.find(it => it.actor.id == actorId);
|
return this.dialogData.actors.find(it => it.id == actorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onChateauDormant() {
|
async onChateauDormant() {
|
||||||
const motifStress = this.html.find("form input[name='motifStress']").val();
|
const motifStress = this.html.find("form input[name='motifStress']").val();
|
||||||
const sommeilActors = jQuery.map(this.html.find('li.set-sommeil-actor'), it => {
|
const consignesChateauDormant = jQuery.map(this.html.find('li.set-sommeil-actor'), it => {
|
||||||
const actorRow = this.html.find(it);
|
const actorRow = this.html.find(it);
|
||||||
const actorId = actorRow.data('actor-id');
|
const actorId = actorRow.data('actor-id');
|
||||||
const actorSetting = this.getActorSetting(actorId);
|
const actor = this.getActor(actorId);
|
||||||
|
const insomnie = actorRow.find('input.sommeil-insomnie').is(':checked');
|
||||||
return {
|
return {
|
||||||
actorId,
|
actor,
|
||||||
ignorer: actorRow.find('input.sommeil-ignorer').is(':checked'),
|
ignorer: actorRow.find('input.sommeil-ignorer').is(':checked'),
|
||||||
stress: {
|
stress: {
|
||||||
motif: motifStress,
|
motif: motifStress,
|
||||||
valeur: Number.parseInt(actorRow.find('input.sommeil-stress').val()),
|
valeur: Number.parseInt(actorRow.find('input.sommeil-stress').val()),
|
||||||
},
|
},
|
||||||
sommeil: {
|
sommeil: {
|
||||||
insomnie: actorRow.find('input.sommeil-insomnie').is(':checked'),
|
nouveaujour: true,
|
||||||
heures: Number.parseInt(actorRow.find('input.sommeil-heures').val()),
|
date: this.dialogData.finChateauDormant,
|
||||||
moral: actorSetting.moral,
|
insomnie: insomnie,
|
||||||
|
heures: insomnie ? 0 : Number.parseInt(actorRow.find('input.sommeil-heures').val()),
|
||||||
|
moral: actor.moral,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await Promise.all(
|
consignesChateauDormant.forEach(async consigne => await consigne.actor.prepareChateauDormant(consigne))
|
||||||
sommeilActors.filter(it => !it.ignorer)
|
|
||||||
.map(async it => await game.actors.get(it.actorId)?.prepareChateauDormant(this.dialogData.finChateauDormant, it))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import { ReglesOptionelles } from "../settings/regles-optionelles.js";
|
import { ReglesOptionelles } from "../settings/regles-optionelles.js";
|
||||||
|
import { EffetsDraconiques } from "../tmr/effets-draconiques.js";
|
||||||
|
|
||||||
export class DialogRepos extends Dialog {
|
export class DialogRepos extends Dialog {
|
||||||
|
|
||||||
@ -6,7 +7,7 @@ export class DialogRepos extends Dialog {
|
|||||||
if (!ReglesOptionelles.isUsing("chateau-dormant-gardien")) {
|
if (!ReglesOptionelles.isUsing("chateau-dormant-gardien")) {
|
||||||
actor.system.sommeil = {
|
actor.system.sommeil = {
|
||||||
"nouveaujour": true,
|
"nouveaujour": true,
|
||||||
"insomnie": false,
|
"insomnie": EffetsDraconiques.isSujetInsomnie(actor),
|
||||||
"moral": "neutre",
|
"moral": "neutre",
|
||||||
"heures": 4
|
"heures": 4
|
||||||
}
|
}
|
||||||
@ -58,7 +59,8 @@ export class DialogRepos extends Dialog {
|
|||||||
|
|
||||||
async nuit() {
|
async nuit() {
|
||||||
await this.html.find("[name='sommeil.heures']").change();
|
await this.html.find("[name='sommeil.heures']").change();
|
||||||
const sommeilHeures = Number.parseInt(await this.html.find("[name='sommeil.heures']").val());
|
const val = await this.html.find("[name='sommeil.heures']").val();
|
||||||
|
const sommeilHeures = Number.parseInt(val ?? '0');
|
||||||
await this.actor.dormir(sommeilHeures, { chateauDormant: true });
|
await this.actor.dormir(sommeilHeures, { chateauDormant: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ export class DialogRepos extends Dialog {
|
|||||||
const selected = this.html.find(event.currentTarget);
|
const selected = this.html.find(event.currentTarget);
|
||||||
const parentDiv = selected.parents().find('.sommeil-actor-moral');
|
const parentDiv = selected.parents().find('.sommeil-actor-moral');
|
||||||
const situationMoral = selected.data('moral');
|
const situationMoral = selected.data('moral');
|
||||||
await this.actor.update({"system.sommeil.moral": situationMoral});
|
await this.actor.setInfoSommeilMoral(situationMoral);
|
||||||
const htmlMoral = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs', {
|
const htmlMoral = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs', {
|
||||||
moral: situationMoral
|
moral: situationMoral
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"id": "foundryvtt-reve-de-dragon",
|
"id": "foundryvtt-reve-de-dragon",
|
||||||
"title": "Rêve de Dragon",
|
"title": "Rêve de Dragon",
|
||||||
"version": "10.6.14",
|
"version": "10.6.15",
|
||||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.14.zip",
|
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.15.zip",
|
||||||
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
|
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "10",
|
"minimum": "10",
|
||||||
|
@ -14,29 +14,29 @@
|
|||||||
<span class="flex-grow-1">Moral</span>
|
<span class="flex-grow-1">Moral</span>
|
||||||
<span class="flex-shrink">Ignorer</span>
|
<span class="flex-shrink">Ignorer</span>
|
||||||
</li>
|
</li>
|
||||||
{{#each actorsSettings as |actorSetting|}}
|
{{#each actors as |actor|}}
|
||||||
<li class="item flexrow list-item set-sommeil-actor" data-actor-id="{{actorSetting.actor.id}}">
|
<li class="item flexrow list-item set-sommeil-actor" data-actor-id="{{actor.id}}">
|
||||||
<span class="flex-grow-3">
|
<span class="flex-grow-3">
|
||||||
<label>
|
<label>
|
||||||
<img class="chat-icon" src="{{actorSetting.actor.img}}" title="{{actorSetting.actor.name}}" />
|
<img class="chat-icon" src="{{actor.img}}" title="{{actor.name}}" />
|
||||||
<span>{{actorSetting.actor.name}}</span>
|
<span>{{actor.name}}</span>
|
||||||
</label>
|
</label>
|
||||||
</span>
|
</span>
|
||||||
<span class="flex-shrink">
|
<span class="flex-shrink">
|
||||||
<input type="checkbox" class="sommeil-insomnie" {{#if actorSetting.insomnie}}checked{{/if}}>
|
<input type="checkbox" class="sommeil-insomnie" {{#if actor.system.sommeil.insomnie}}checked{{/if}}>
|
||||||
</span>
|
</span>
|
||||||
<span class="flex-grow-1">
|
<span class="flex-grow-1">
|
||||||
<input type="number" class="number-x sommeil-heures" data-dtype="Number"
|
<input type="number" class="number-x sommeil-heures" data-dtype="Number"
|
||||||
value="{{#if actorSetting.insomnie}}0{{else}}4{{/if}}"
|
value="{{#if actor.system.sommeil.insomnie}}0{{else}}4{{/if}}"
|
||||||
min="0" max="{{#if actorSetting.insomnie}}0{{else}}12{{/if}}"
|
min="0" max="{{#if actor.system.sommeil.insomnie}}0{{else}}12{{/if}}"
|
||||||
{{#if actorSetting.insomnie}}disabled{{/if}}/>
|
{{#if actor.system.sommeil.insomnie}}disabled{{/if}}/>
|
||||||
h
|
h
|
||||||
</span>
|
</span>
|
||||||
<span class="flex-shrink">
|
<span class="flex-shrink">
|
||||||
<input type="number" class="number-x2 sommeil-stress" value="0" data-dtype="Number" min="0" max="200"/>
|
<input type="number" class="number-x2 sommeil-stress" value="0" data-dtype="Number" min="0" max="200"/>
|
||||||
</span>
|
</span>
|
||||||
<span class="flex-grow-1 flexrow sommeil-actor-moral">
|
<span class="flex-grow-1 flexrow sommeil-actor-moral">
|
||||||
{{> "systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs" actorSetting}}
|
{{> "systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs" actor.system.sommeil}}
|
||||||
</span>
|
</span>
|
||||||
<span class="flex-shrink">
|
<span class="flex-shrink">
|
||||||
<input type="checkbox" class="sommeil-ignorer">
|
<input type="checkbox" class="sommeil-ignorer">
|
||||||
|
@ -4,41 +4,39 @@
|
|||||||
<div class="flexrow"><span>
|
<div class="flexrow"><span>
|
||||||
<h2>{{name}} se repose</h2>
|
<h2>{{name}} se repose</h2>
|
||||||
</span></div>
|
</span></div>
|
||||||
{{#if system.sommeil.insomnie}}
|
<div class="flexrow"><span>
|
||||||
<div class="flexrow"><span>
|
<input class type="radio" name="repos" id="sieste" value="sieste">
|
||||||
Insomnie, impossible de dormir
|
<label for="sieste">Sieste de
|
||||||
</span></div>
|
<input type="number" name="sieste.heures" value="1" data-dtype="Number" />
|
||||||
|
heures</label>
|
||||||
|
</span></div>
|
||||||
|
<div class="flexrow"><span><hr></span></div>
|
||||||
|
{{#if system.sommeil.nouveaujour}}
|
||||||
|
<div class="flexrow"><span>
|
||||||
|
<input type="radio" name="repos" id="chateau-dormant" value="chateau-dormant">
|
||||||
|
<label for="chateau-dormant">Juste château Dormant</label>
|
||||||
|
</span></div>
|
||||||
|
<div class="flexrow"><span>
|
||||||
|
<input type="radio" name="repos" id="nuit" value="nuit" checked>
|
||||||
|
{{#if system.sommeil.insomnie}}
|
||||||
|
<label>Insomnie cette nuit</label>
|
||||||
|
{{else}}
|
||||||
|
<label for="nuit">Dormir
|
||||||
|
<input type="number" name="sommeil.heures" value="{{system.sommeil.heures}}" data-dtype="Number" />
|
||||||
|
heures cette nuit
|
||||||
|
</label>
|
||||||
|
{{/if}}
|
||||||
|
</span></div>
|
||||||
|
<div class="flexrow">
|
||||||
|
<label for="moral">Moral</label>
|
||||||
|
<div class="sommeil-actor-moral">
|
||||||
|
{{> "systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs" system.sommeil}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="flexrow"><span>
|
<div class="flexrow"><span>
|
||||||
<input class type="radio" name="repos" id="sieste" value="sieste">
|
Le gardien des rêves doit faire passer Chateau Dormant
|
||||||
<label for="sieste">Sieste de
|
|
||||||
<input type="number" name="sieste.heures" value="1" data-dtype="Number" />
|
|
||||||
heures</label>
|
|
||||||
</span></div>
|
</span></div>
|
||||||
<div class="flexrow"><span><hr></span></div>
|
|
||||||
{{#if system.sommeil.nouveaujour}}
|
|
||||||
<div class="flexrow"><span>
|
|
||||||
<input type="radio" name="repos" id="chateau-dormant" value="chateau-dormant">
|
|
||||||
<label for="chateau-dormant">Juste château Dormant</label>
|
|
||||||
</span></div>
|
|
||||||
<div class="flexrow"><span>
|
|
||||||
<input type="radio" name="repos" id="nuit" value="nuit" checked>
|
|
||||||
<label for="nuit">Dormir
|
|
||||||
<input type="number" name="sommeil.heures" value="{{system.sommeil.heures}}" data-dtype="Number" />
|
|
||||||
heures cette nuit
|
|
||||||
</label>
|
|
||||||
</span></div>
|
|
||||||
<div class="flexrow">
|
|
||||||
<label for="moral">Moral</label>
|
|
||||||
<div class="sommeil-actor-moral">
|
|
||||||
{{> "systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs" system.sommeil}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{else}}
|
|
||||||
<div class="flexrow"><span>
|
|
||||||
Le gardien des rêves doit faire passer Chateau Dormant
|
|
||||||
</span></div>
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="flexrow"><span><hr></span></div>
|
<div class="flexrow"><span><hr></span></div>
|
||||||
<div class="flexrow"><span>
|
<div class="flexrow"><span>
|
||||||
|
Loading…
Reference in New Issue
Block a user