Meilleure gestion des doublons/valeur à 0 des bonus de cases

This commit is contained in:
sladecraven 2020-12-08 23:12:43 +01:00
parent 399a7b2d30
commit aa97f16f3a
5 changed files with 53 additions and 9 deletions

View File

@ -65,14 +65,18 @@ export class RdDItemSort extends Item {
static buildBonusCaseStringFromFormData( formData ) { static buildBonusCaseStringFromFormData( formData ) {
if ( formData.bonusValue ) { if ( formData.bonusValue ) {
let list = []; let list = [];
let caseCheck = {};
for(let i=0; i<formData.bonusValue.length; i++) { for(let i=0; i<formData.bonusValue.length; i++) {
let caseTMR = formData.caseValue[i] || 'A1'; let caseTMR = formData.caseValue[i] || 'A1';
caseTMR = caseTMR.toUpperCase(); caseTMR = caseTMR.toUpperCase();
if ( TMRUtility.verifyTMRCoord( caseTMR ) ) { // Sanity check if ( TMRUtility.verifyTMRCoord( caseTMR ) ) { // Sanity check
let bonus = formData.bonusValue[i] || 0; let bonus = formData.bonusValue[i] || 0;
if ( bonus > 0 && caseCheck[caseTMR] == undefined ) {
caseCheck[caseTMR] = bonus;
list.push( caseTMR+":"+bonus ); list.push( caseTMR+":"+bonus );
} }
} }
}
formData.bonusValue = undefined; formData.bonusValue = undefined;
formData.caseValue = undefined; formData.caseValue = undefined;
formData['data.bonuscase'] = list.toString(); // Reset formData['data.bonuscase'] = list.toString(); // Reset

View File

@ -22,6 +22,7 @@ const saisonsDef = { "printemps": { label: "Printemps"},
"hiver": { label: "Hiver"} "hiver": { label: "Hiver"}
}; };
const RDD_JOUR_PAR_MOIS = 28; const RDD_JOUR_PAR_MOIS = 28;
const MAX_NOMBRE_ASTRAL = 30;
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDCalendrier extends Application { export class RdDCalendrier extends Application {
@ -50,9 +51,36 @@ export class RdDCalendrier extends Application {
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos ); 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); 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() { static get defaultOptions() {
const options = super.defaultOptions; const options = super.defaultOptions;
@ -83,6 +111,9 @@ export class RdDCalendrier extends Application {
if ( this.calendrier.jour <= 0) if ( this.calendrier.jour <= 0)
this.calendrier.jour = 1; this.calendrier.jour = 1;
this.calendrier.moisRdD += 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) ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier) );
// Notification aux joueurs // Notification aux joueurs
@ -90,8 +121,6 @@ export class RdDCalendrier extends Application {
msg: "msg_sync_time", msg: "msg_sync_time",
data: duplicate(this.calendrier) data: duplicate(this.calendrier)
} ); } );
//console.log(this.calendrier, heure, minute);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -129,6 +129,13 @@ Hooks.once("init", async function() {
type: Object 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", { game.settings.register("foundryvtt-reve-de-dragon", "calendrier-pos", {
name: "calendrierPos", name: "calendrierPos",
scope: "world", scope: "world",

View File

@ -2,10 +2,10 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.1.2", "version": "1.1.3",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.8", "compatibleCoreVersion": "0.7.8",
"templateVersion": 58, "templateVersion": 60,
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ], "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"], "styles": ["styles/simple.css"],

View File

@ -685,6 +685,10 @@
"aspect":"", "aspect":"",
"description": "" "description": ""
}, },
"nombreastral": {
"value": 0,
"jourindex": 1
},
"monnaie": { "monnaie": {
"quantite": "", "quantite": "",
"valeur_deniers":0, "valeur_deniers":0,