Gestion de la périodicité/temporalité
This commit is contained in:
@ -44,7 +44,7 @@ export class RdDCalendrier extends Application {
|
||||
this.listeNombreAstral = this.getListeNombreAstral();
|
||||
this.rebuildListeNombreAstral(HIDE_DICE); // Ensure always up-to-date
|
||||
}
|
||||
console.log('RdDCalendrier.constructor()', this.timestamp, this.timestamp.toOldCalendrier(), this.calendrierPos, this.listeNombreAstral);
|
||||
console.log('RdDCalendrier.constructor()', this.timestamp, this.timestamp.toCalendrier(), this.calendrierPos, this.listeNombreAstral);
|
||||
Hooks.on('updateSetting', async (setting, update, options, id) => this.onUpdateSetting(setting, update, options, id));
|
||||
}
|
||||
|
||||
@ -253,65 +253,13 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setNewTimestamp(newTimestamp) {
|
||||
this.checkMaladiePoison(this.timestamp, newTimestamp);
|
||||
|
||||
this.checkMaladie("round");
|
||||
this.checkMaladie("minute");
|
||||
if (this.timestamp.heure != newTimestamp.heure || this.timestamp.indexDate != newTimestamp.indexDate) {
|
||||
this.checkMaladie("heure");
|
||||
}
|
||||
if (this.timestamp.indexDate != newTimestamp.indexDate) {
|
||||
this.checkMaladie("jour");
|
||||
}
|
||||
|
||||
game.actors.forEach(actor => actor.onTimeChanging(this.timestamp, newTimestamp));
|
||||
RdDTimestamp.setWorldTime(newTimestamp);
|
||||
this.timestamp = newTimestamp;
|
||||
await this.rebuildListeNombreAstral();
|
||||
this.updateDisplay();
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
checkMaladie(periode) {
|
||||
for (let actor of game.actors) {
|
||||
if (actor.type == 'personnage') {
|
||||
let maladies = actor.items.filter(item => (item.type == 'maladie' || (item.type == 'poison' && item.system.active)) && item.system.periodicite.toLowerCase().includes(periode));
|
||||
for (let maladie of maladies) {
|
||||
if (maladie.system.identifie) {
|
||||
ChatMessage.create({ content: `${actor.name} souffre de ${maladie.name} (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
||||
} else {
|
||||
ChatMessage.create({ content: `${actor.name} souffre d'un mal inconnu (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
||||
}
|
||||
let itemMaladie = actor.getItem(maladie.id)
|
||||
itemMaladie.postItemToChat('gmroll');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkMaladiePoison(oldTimestamp, newTimestamp) {
|
||||
// TODO
|
||||
const isInPeriod = maladie => {
|
||||
//TODO: utiliser les timestamp
|
||||
return false;
|
||||
}
|
||||
|
||||
game.actors.filter(it => it.type == 'personnage')
|
||||
.forEach(actor => {
|
||||
actor.items.filter(it => it.type == 'maladie' || (it.type == 'poison' && it.system.active))
|
||||
.filter(m => isInPeriod(m))
|
||||
.forEach(m => {
|
||||
if (m.system.identifie) {
|
||||
ChatMessage.create({ content: `${actor.name} souffre de ${m.name} (${m.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
||||
} else {
|
||||
ChatMessage.create({ content: `${actor.name} souffre d'un mal inconnu (${m.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
||||
}
|
||||
let itemMaladie = actor.getItem(m.id)
|
||||
itemMaladie.postItemToChat('gmroll');
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async onCalendarButton(ev) {
|
||||
ev.preventDefault();
|
||||
@ -343,30 +291,8 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
fillCalendrierData(formData = {}) {
|
||||
const mois = RdDTimestamp.definition(this.timestamp.mois);
|
||||
const heure = RdDTimestamp.definition(this.timestamp.heure);
|
||||
|
||||
formData.timestamp = this.timestamp;
|
||||
formData.annee = this.timestamp.annee;
|
||||
formData.mois = mois;
|
||||
formData.jourDuMois = this.timestamp.jour + 1;
|
||||
formData.jour = this.timestamp.jour;
|
||||
formData.heure = heure;
|
||||
formData.minute = this.timestamp.minute;
|
||||
|
||||
// formData.nomMois = mois.label; // heures et mois nommés identiques
|
||||
// formData.iconMois = mois.icon;
|
||||
|
||||
// formData.heureKey = heure.key;
|
||||
// formData.heureRdD = formData.heure.heure;
|
||||
// formData.nomHeure = heure.label;
|
||||
// formData.iconHeure = heure.icon;
|
||||
|
||||
// formData.minutes = this.timestamp.minute;
|
||||
|
||||
mergeObject(formData, this.timestamp.toCalendrier());
|
||||
formData.isGM = game.user.isGM;
|
||||
|
||||
console.log('fillCalendrierData', this.timestamp, mois, heure, formData);
|
||||
return formData;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user