diff --git a/module/rdd-astrologie-joueur.js b/module/rdd-astrologie-joueur.js index b1d6d45c..dd5ae006 100644 --- a/module/rdd-astrologie-joueur.js +++ b/module/rdd-astrologie-joueur.js @@ -8,50 +8,51 @@ import { Misc } from "./misc.js"; */ export class RdDAstrologieJoueur extends Dialog { - /* -------------------------------------------- */ - static async create(actor, dialogConfig) { - - let data = { nombres: this.organizeNombres( actor), - dates: game.system.rdd.calendrier.getJoursSuivants( 10 ), - etat: actor.getEtatGeneral(), - ajustementsConditions: CONFIG.RDD.ajustementsConditions, - astrologie: RdDItemCompetence.findCompetence( actor.data.items, 'Astrologie') - } - const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data); - let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 }; - if (dialogConfig.options) { - mergeObject(options, dialogConfig.options, { overwrite: true }); - } - return new RdDAstrologieJoueur(html, actor, data); - } - /* -------------------------------------------- */ - constructor(html, actor, data ) { + static async create(actor, dialogConfig) { + + let data = { + nombres: this.organizeNombres(actor), + dates: game.system.rdd.calendrier.getJoursSuivants(10), + etat: actor.getEtatGeneral(), + ajustementsConditions: CONFIG.RDD.ajustementsConditions, + astrologie: RdDItemCompetence.findCompetence(actor.data.items, 'Astrologie') + } + const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data); + let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 }; + if (dialogConfig.options) { + mergeObject(options, dialogConfig.options, { overwrite: true }); + } + return new RdDAstrologieJoueur(html, actor, data); + } + + /* -------------------------------------------- */ + constructor(html, actor, data) { let myButtons = { - saveButton: { label: "Fermer", callback: html => this.quitDialog() } - }; - + saveButton: { label: "Fermer", callback: html => this.quitDialog() } + }; + // Get all n // Common conf let dialogConf = { content: html, title: "Nombres Astraux", buttons: myButtons, default: "saveButton" }; - let dialogOptions = { classes: ["rdddialog"], width: 600, height: 300, 'z-index': 99999 } ; + let dialogOptions = { classes: ["rdddialog"], width: 600, height: 300, 'z-index': 99999 }; super(dialogConf, dialogOptions); - + this.actor = actor; this.dataNombreAstral = duplicate(data); } - + /* -------------------------------------------- */ static organizeNombres(actor) { - let itemNombres = actor.data.items.filter( (item) => item.type == 'nombreastral'); + let itemNombres = actor.listItemsData('nombreastral'); let itemFiltered = {}; - for ( let item of itemNombres) { - if ( itemFiltered[item.data.jourindex] ) { + for (let item of itemNombres) { + if (itemFiltered[item.data.jourindex]) { itemFiltered[item.data.jourindex].listValues.push(item.data.value); } else { itemFiltered[item.data.jourindex] = { - listValues: [ item.data.value ], + listValues: [item.data.value], jourlabel: item.data.jourlabel } } @@ -60,21 +61,22 @@ export class RdDAstrologieJoueur extends Dialog { } /* -------------------------------------------- */ - requestJetAstrologie( ) { - let data = { id: this.actor.data._id, - carac_vue: Misc.data(this.actor).data.carac['vue'].value, - etat: this.dataNombreAstral.etat, - astrologie: this.dataNombreAstral.astrologie, - conditions: $("#diffConditions").val(), - date: $("#joursAstrologie").val() - } - if ( game.user.isGM) { - game.system.rdd.calendrier.requestNombreAstral( data ); + requestJetAstrologie() { + let data = { + id: this.actor.data._id, + carac_vue: Misc.data(this.actor).data.carac['vue'].value, + etat: this.dataNombreAstral.etat, + astrologie: this.dataNombreAstral.astrologie, + conditions: $("#diffConditions").val(), + date: $("#joursAstrologie").val() + } + if (game.user.isGM) { + game.system.rdd.calendrier.requestNombreAstral(data); } else { game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_request_nombre_astral", - data: data - } ); + data: data + }); } this.close(); } @@ -87,7 +89,7 @@ export class RdDAstrologieJoueur extends Dialog { /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); - + $(function () { $("#diffConditions").val(0); }); diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 6ca2da0a..929c6f90 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -247,21 +247,19 @@ export class RdDCalendrier extends Application { console.log(request); let jourDiff = this.getLectureAstrologieDifficulte(request.date); let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat); - let rolled = await RdDResolutionTable.rollData({ + let rollData= { caracValue: request.carac_vue, finalLevel: niveau, showDice: false - }); + }; + await RdDResolutionTable.rollData(rollData); let nbAstral = this.getNombreAstral(request.date); - let nbAstralFaux = nbAstral; + request.rolled = rollData.rolled; request.isValid = true; - request.rolled = rolled; - if (!rolled.isSuccess) { + if (!request.rolled.isSuccess) { request.isValid = false; - while (nbAstralFaux == nbAstral) { - nbAstralFaux = new Roll("1d12").evaluate( { async: false} ).total; - } - nbAstral = nbAstralFaux; + let nbAstralFaux = new Roll("1d11").evaluate( { async: false} ).total; + nbAstral = nbAstral==nbAstralFaux ? 12 : nbAstralFaux; // Mise à jour des nombres astraux du joueur let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date); astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstralFaux }); diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 47bf86d4..149670f2 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -461,8 +461,19 @@ {{!-- Connaissances Tab --}}