Meilleure gestion des doublons/valeur à 0 des bonus de cases
This commit is contained in:
@ -65,12 +65,16 @@ export class RdDItemSort extends Item {
|
||||
static buildBonusCaseStringFromFormData( formData ) {
|
||||
if ( formData.bonusValue ) {
|
||||
let list = [];
|
||||
let caseCheck = {};
|
||||
for(let i=0; i<formData.bonusValue.length; i++) {
|
||||
let caseTMR = formData.caseValue[i] || 'A1';
|
||||
caseTMR = caseTMR.toUpperCase();
|
||||
if ( TMRUtility.verifyTMRCoord( caseTMR ) ) { // Sanity check
|
||||
let bonus = formData.bonusValue[i] || 0;
|
||||
list.push( caseTMR+":"+bonus );
|
||||
let bonus = formData.bonusValue[i] || 0;
|
||||
if ( bonus > 0 && caseCheck[caseTMR] == undefined ) {
|
||||
caseCheck[caseTMR] = bonus;
|
||||
list.push( caseTMR+":"+bonus );
|
||||
}
|
||||
}
|
||||
}
|
||||
formData.bonusValue = undefined;
|
||||
|
@ -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);
|
||||
} );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -129,6 +129,13 @@ Hooks.once("init", async function() {
|
||||
type: Object
|
||||
});
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "liste-nombre-astral", {
|
||||
name: "liste-nombre-astral",
|
||||
scope: "world",
|
||||
config: false,
|
||||
type: Object
|
||||
});
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "calendrier-pos", {
|
||||
name: "calendrierPos",
|
||||
scope: "world",
|
||||
|
Reference in New Issue
Block a user