Fix détermination nombre astral

fixé, déplacé dans les savoirs
This commit is contained in:
Vincent Vandemeulebrouck 2021-04-01 00:01:37 +02:00
parent 8a95ad6471
commit 6429eda2d6
3 changed files with 68 additions and 69 deletions

View File

@ -8,34 +8,35 @@ import { Misc } from "./misc.js";
*/ */
export class RdDAstrologieJoueur extends Dialog { export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async create(actor, dialogConfig) { static async create(actor, dialogConfig) {
let data = { nombres: this.organizeNombres( actor), let data = {
dates: game.system.rdd.calendrier.getJoursSuivants( 10 ), nombres: this.organizeNombres(actor),
etat: actor.getEtatGeneral(), dates: game.system.rdd.calendrier.getJoursSuivants(10),
ajustementsConditions: CONFIG.RDD.ajustementsConditions, etat: actor.getEtatGeneral(),
astrologie: RdDItemCompetence.findCompetence( actor.data.items, 'Astrologie') 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);
} }
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 ) { constructor(html, actor, data) {
let myButtons = { let myButtons = {
saveButton: { label: "Fermer", callback: html => this.quitDialog() } saveButton: { label: "Fermer", callback: html => this.quitDialog() }
}; };
// Get all n // Get all n
// Common conf // Common conf
let dialogConf = { content: html, title: "Nombres Astraux", buttons: myButtons, default: "saveButton" }; 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); super(dialogConf, dialogOptions);
this.actor = actor; this.actor = actor;
@ -44,14 +45,14 @@ export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static organizeNombres(actor) { static organizeNombres(actor) {
let itemNombres = actor.data.items.filter( (item) => item.type == 'nombreastral'); let itemNombres = actor.listItemsData('nombreastral');
let itemFiltered = {}; let itemFiltered = {};
for ( let item of itemNombres) { for (let item of itemNombres) {
if ( itemFiltered[item.data.jourindex] ) { if (itemFiltered[item.data.jourindex]) {
itemFiltered[item.data.jourindex].listValues.push(item.data.value); itemFiltered[item.data.jourindex].listValues.push(item.data.value);
} else { } else {
itemFiltered[item.data.jourindex] = { itemFiltered[item.data.jourindex] = {
listValues: [ item.data.value ], listValues: [item.data.value],
jourlabel: item.data.jourlabel jourlabel: item.data.jourlabel
} }
} }
@ -60,21 +61,22 @@ export class RdDAstrologieJoueur extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
requestJetAstrologie( ) { requestJetAstrologie() {
let data = { id: this.actor.data._id, let data = {
carac_vue: Misc.data(this.actor).data.carac['vue'].value, id: this.actor.data._id,
etat: this.dataNombreAstral.etat, carac_vue: Misc.data(this.actor).data.carac['vue'].value,
astrologie: this.dataNombreAstral.astrologie, etat: this.dataNombreAstral.etat,
conditions: $("#diffConditions").val(), astrologie: this.dataNombreAstral.astrologie,
date: $("#joursAstrologie").val() conditions: $("#diffConditions").val(),
} date: $("#joursAstrologie").val()
if ( game.user.isGM) { }
game.system.rdd.calendrier.requestNombreAstral( data ); if (game.user.isGM) {
game.system.rdd.calendrier.requestNombreAstral(data);
} else { } else {
game.socket.emit("system.foundryvtt-reve-de-dragon", { game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_request_nombre_astral", msg: "msg_request_nombre_astral",
data: data data: data
} ); });
} }
this.close(); this.close();
} }

View File

@ -247,21 +247,19 @@ export class RdDCalendrier extends Application {
console.log(request); console.log(request);
let jourDiff = this.getLectureAstrologieDifficulte(request.date); let jourDiff = this.getLectureAstrologieDifficulte(request.date);
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat); 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, caracValue: request.carac_vue,
finalLevel: niveau, finalLevel: niveau,
showDice: false showDice: false
}); };
await RdDResolutionTable.rollData(rollData);
let nbAstral = this.getNombreAstral(request.date); let nbAstral = this.getNombreAstral(request.date);
let nbAstralFaux = nbAstral; request.rolled = rollData.rolled;
request.isValid = true; request.isValid = true;
request.rolled = rolled; if (!request.rolled.isSuccess) {
if (!rolled.isSuccess) {
request.isValid = false; request.isValid = false;
while (nbAstralFaux == nbAstral) { let nbAstralFaux = new Roll("1d11").evaluate( { async: false} ).total;
nbAstralFaux = new Roll("1d12").evaluate( { async: false} ).total; nbAstral = nbAstral==nbAstralFaux ? 12 : nbAstralFaux;
}
nbAstral = nbAstralFaux;
// Mise à jour des nombres astraux du joueur // Mise à jour des nombres astraux du joueur
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date); let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstralFaux }); astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstralFaux });

View File

@ -461,8 +461,19 @@
{{!-- Connaissances Tab --}} {{!-- Connaissances Tab --}}
<div class="tab connaissances" data-group="primary" data-tab="connaissances"> <div class="tab connaissances" data-group="primary" data-tab="connaissances">
<span class="item-name"><a class="creer-une-oeuvre">Créer une oeuvre</a></span> <h3>Tâches</h3><a class='creer-tache'>Créer une nouvelle Tâche</a>
<h3>Oeuvres diverses :</h3> <ul class="item-list alterne-list">
{{#each taches as |tache id|}}
<li class="item flexrow list-item" data-item-id="{{tache._id}}"><span class="competence-title tache-label"><a>{{tache.name}} ({{tache.data.points_de_tache_courant}}/{{tache.data.points_de_tache}})</a></span>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
<hr>
<h3>Oeuvres diverses :</h3><a class="creer-une-oeuvre">Créer une oeuvre</a>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each chants as |chant id|}} {{#each chants as |chant id|}}
<li class="item flexrow list-item" data-item-id="{{chant._id}}"><span>Chant</span><span class="competence-title chant-label"><a>{{chant.name}} (niveau {{chant.data.niveau}})</a></span> <li class="item flexrow list-item" data-item-id="{{chant._id}}"><span>Chant</span><span class="competence-title chant-label"><a>{{chant.name}} (niveau {{chant.data.niveau}})</a></span>
@ -517,7 +528,7 @@
{{/each}} {{/each}}
</ul> </ul>
<h3>Recettes Alchimiques</h3> <h3>Recettes Alchimiques</h3>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each recettesAlchimiques as |recette id|}} {{#each recettesAlchimiques as |recette id|}}
<li class="item flexrow list-item" data-item-id="{{recette._id}}"><span class="competence-title recette-label item-edit"><a>{{recette.name}}</a></span> <li class="item flexrow list-item" data-item-id="{{recette._id}}"><span class="competence-title recette-label item-edit"><a>{{recette.name}}</a></span>
<div class="item-controls"> <div class="item-controls">
@ -526,19 +537,10 @@
</div> </div>
</li> </li>
{{/each}} {{/each}}
</ul> </ul>
<h3>Tâches</h3><a class='creer-tache'>Créer une nouvelle Tâche</a> <hr>
<ul class="item-list alterne-list"> <h3>Astrologie</h3>
{{#each taches as |tache id|}} <span class="astrologie-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span>
<li class="item flexrow list-item" data-item-id="{{tache._id}}"><span class="competence-title tache-label"><a>{{tache.name}} ({{tache.data.points_de_tache_courant}}/{{tache.data.points_de_tache}})</a></span>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
<hr>
</div> </div>
{{!-- hautreve Tab --}} {{!-- hautreve Tab --}}
@ -576,9 +578,6 @@
{{/if}} {{/if}}
</span> </span>
</li> </li>
<li class="item flexrow" >
<span class="astrologie-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span>
</li>
</ul> </ul>
</div> </div>
<hr> <hr>