Meilleure gestion des doublons/valeur à 0 des bonus de cases
This commit is contained in:
parent
399a7b2d30
commit
aa97f16f3a
@ -65,14 +65,18 @@ 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;
|
||||
if ( bonus > 0 && caseCheck[caseTMR] == undefined ) {
|
||||
caseCheck[caseTMR] = bonus;
|
||||
list.push( caseTMR+":"+bonus );
|
||||
}
|
||||
}
|
||||
}
|
||||
formData.bonusValue = undefined;
|
||||
formData.caseValue = undefined;
|
||||
formData['data.bonuscase'] = list.toString(); // Reset
|
||||
|
@ -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,6 +111,9 @@ 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
|
||||
@ -90,8 +121,6 @@ export class RdDCalendrier extends Application {
|
||||
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",
|
||||
|
@ -2,10 +2,10 @@
|
||||
"name": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"description": "Rêve de Dragon RPG for FoundryVTT",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.8",
|
||||
"templateVersion": 58,
|
||||
"templateVersion": 60,
|
||||
"author": "LeRatierBretonnien",
|
||||
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
|
||||
"styles": ["styles/simple.css"],
|
||||
|
@ -685,11 +685,15 @@
|
||||
"aspect":"",
|
||||
"description": ""
|
||||
},
|
||||
"nombreastral": {
|
||||
"value": 0,
|
||||
"jourindex": 1
|
||||
},
|
||||
"monnaie": {
|
||||
"quantite": "",
|
||||
"valeur_deniers":0,
|
||||
"encombrement":0,
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user