Meilleure gestion des doublons/valeur à 0 des bonus de cases
This commit is contained in:
@ -22,6 +22,7 @@ const saisonsDef = { "printemps": { label: "Printemps"},
|
||||
"hiver": { label: "Hiver"}
|
||||
};
|
||||
const RDD_JOUR_PAR_MOIS = 28;
|
||||
const MAX_NOMBRE_ASTRAL = 30;
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDCalendrier extends Application {
|
||||
@ -50,10 +51,37 @@ export class RdDCalendrier extends Application {
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos );
|
||||
}
|
||||
}
|
||||
// nombre astral
|
||||
if ( game.user.isGM) {
|
||||
this.listeNombreAstral = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral"));
|
||||
if ( this.listeNombreAstral == undefined ) {
|
||||
let start = this.getCurrentDayIndex();
|
||||
let dayList = {}
|
||||
for(let index=start; index<=start+MAX_NOMBRE_ASTRAL; index++) { // Construction des nombres astraux pour les prochains jours
|
||||
dayList[index] = this.ajouterNombreAstral();
|
||||
}
|
||||
this.listeNombreAstral = dayList;
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral );
|
||||
}
|
||||
}
|
||||
console.log(this.calendrier, this.calendrierPos);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
ajouterNombreAstral(index) {
|
||||
return {
|
||||
nombreAstral: new Roll("1d12").roll().total,
|
||||
valeursFausses: [],
|
||||
index: index
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* -------------------------------------------- */
|
||||
getCurrentDayIndex( ) {
|
||||
return (this.calendrier.moisRdD * 28) + this.calendrier.jour;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static get defaultOptions() {
|
||||
const options = super.defaultOptions;
|
||||
options.template = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html";
|
||||
@ -83,15 +111,16 @@ export class RdDCalendrier extends Application {
|
||||
if ( this.calendrier.jour <= 0)
|
||||
this.calendrier.jour = 1;
|
||||
this.calendrier.moisRdD += 1;
|
||||
// Ajouter un nouveau nombre astral
|
||||
let index = this.getCurrentDayIndex();
|
||||
this.listeNombreAstral[index] = this.ajouterNombreAstral();
|
||||
}
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier) );
|
||||
// Notification aux joueurs
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
msg: "msg_sync_time",
|
||||
data: duplicate(this.calendrier)
|
||||
} );
|
||||
|
||||
//console.log(this.calendrier, heure, minute);
|
||||
} );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user