Fixes préparatoire à actor échoppe #599

Merged
uberwald merged 9 commits from VincentVk/foundryvtt-reve-de-dragon:v10 into v10 2022-12-30 09:35:02 +01:00
5 changed files with 66 additions and 52 deletions
Showing only changes of commit 454193490d - Show all commits

View File

@ -3073,32 +3073,30 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async ajouteNombreAstral(callData) { async ajouteNombreAstral(callData) {
// Gestion expérience (si existante)
callData.competence = this.getCompetence("astrologie")
callData.selectedCarac = this.system.carac["vue"];
this.appliquerAjoutExperience(callData, 'hide');
// Ajout du nombre astral // Ajout du nombre astral
const item = { const item = {
name: "Nombre Astral", type: "nombreastral", system: name: "Nombre Astral", type: "nombreastral", system:
{ value: callData.nbAstral, istrue: callData.isvalid, jourindex: Number(callData.date), jourlabel: game.system.rdd.calendrier.getDateFromIndex(Number(callData.date)) } { value: callData.nbAstral, istrue: callData.isvalid, jourindex: Number(callData.date), jourlabel: game.system.rdd.calendrier.getDateFromIndex(Number(callData.date)) }
}; };
await this.createEmbeddedDocuments("Item", [item]); await this.createEmbeddedDocuments("Item", [item]);
// Suppression des anciens nombres astraux
let toDelete = this.listItems('nombreastral').filter(it => it.system.jourindex < game.system.rdd.calendrier.getCurrentDayIndex());
const deletions = toDelete.map(it => it._id);
await this.deleteEmbeddedDocuments("Item", deletions);
// Affichage Dialog // Affichage Dialog
this.astrologieNombresAstraux(); this.astrologieNombresAstraux();
} }
async supprimerAnciensNombresAstraux() {
const toDelete = this.listItems('nombreastral')
.filter(it => it.system.jourindex < game.system.rdd.calendrier.getCurrentDayIndex())
.map(it => it._id);
await this.deleteEmbeddedDocuments("Item", toDelete);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async astrologieNombresAstraux() { async astrologieNombresAstraux() {
// Suppression des anciens nombres astraux
await this.supprimerAnciensNombresAstraux();
// Afficher l'interface spéciale // Afficher l'interface spéciale
const astrologieDialog = await RdDAstrologieJoueur.create(this, {}); await RdDAstrologieJoueur.create(this);
astrologieDialog.render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -10,7 +10,7 @@ import { SYSTEM_SOCKET_ID } from "./constants.js";
export class RdDAstrologieJoueur extends Dialog { export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async create(actor, dialogConfig) { static async create(actor) {
let dialogData = { let dialogData = {
nombres: this.organizeNombres(actor), nombres: this.organizeNombres(actor),
@ -20,15 +20,14 @@ export class RdDAstrologieJoueur extends Dialog {
astrologie: RdDItemCompetence.findCompetence(actor.items, 'Astrologie') astrologie: RdDItemCompetence.findCompetence(actor.items, 'Astrologie')
} }
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', dialogData); const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', dialogData);
let options = { classes: ["rdd-roll-dialog"], width: 600, height: 500, 'z-index': 99999 };
if (dialogConfig.options) { const options = { classes: ["rdd-roll-dialog"], width: 600, height: 'fit-content', 'z-index': 99999 };
mergeObject(options, dialogConfig.options, { overwrite: true }); const dialog = new RdDAstrologieJoueur(html, actor, dialogData, options);
} dialog.render(true);
return new RdDAstrologieJoueur(html, actor, dialogData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, actor, dialogData) { constructor(html, actor, dialogData, dialogOptions) {
const dialogConf = { const dialogConf = {
title: "Nombres Astraux", title: "Nombres Astraux",
content: html, content: html,
@ -37,7 +36,6 @@ export class RdDAstrologieJoueur extends Dialog {
saveButton: { label: "Fermer", callback: html => this.quitDialog() } saveButton: { label: "Fermer", callback: html => this.quitDialog() }
}, },
}; };
const dialogOptions = { classes: ["rdd-roll-dialog"], width: 600, height: 300, 'z-index': 99999 };
super(dialogConf, dialogOptions); super(dialogConf, dialogOptions);
this.actor = actor; this.actor = actor;
@ -49,9 +47,7 @@ export class RdDAstrologieJoueur extends Dialog {
super.activateListeners(html); super.activateListeners(html);
this.html = html; this.html = html;
this.html.find(function () {
this.html.find("[name='diffConditions']").val(0); this.html.find("[name='diffConditions']").val(0);
});
this.html.find('[name="jet-astrologie"]').click((event) => { this.html.find('[name="jet-astrologie"]').click((event) => {
this.requestJetAstrologie(); this.requestJetAstrologie();

View File

@ -351,7 +351,7 @@ export class RdDCalendrier extends Application {
ChatMessage.create({ content: `${actor.name} souffre d'un mal inconnu (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` }); ChatMessage.create({ content: `${actor.name} souffre d'un mal inconnu (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` });
} }
let itemMaladie = actor.getItem(maladie.id) let itemMaladie = actor.getItem(maladie.id)
itemMaladie.postItemToChat('gmroll'); itemMaladie.postItem('gmroll');
} }
} }
} }
@ -434,6 +434,7 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */ /* -------------------------------------------- */
async requestNombreAstral(request) { async requestNombreAstral(request) {
const actor = game.actors.get(request.id);
if (Misc.isUniqueConnectedGM()) { // Only once if (Misc.isUniqueConnectedGM()) { // Only once
console.log(request); console.log(request);
let jourDiff = this.getLectureAstrologieDifficulte(request.date); let jourDiff = this.getLectureAstrologieDifficulte(request.date);
@ -445,18 +446,26 @@ export class RdDCalendrier extends Application {
rollMode: "blindroll" rollMode: "blindroll"
}; };
await RdDResolutionTable.rollData(rollData); await RdDResolutionTable.rollData(rollData);
let nbAstral = this.getNombreAstral(request.date);
request.rolled = rollData.rolled; request.rolled = rollData.rolled;
request.isValid = true; request.isValid = request.rolled.isSuccess;
if (!request.rolled.isSuccess) { request.nbAstral = this.getNombreAstral(request.date);
request.isValid = false;
nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral, { rollMode: "selfroll" }); if (request.rolled.isSuccess) {
// Mise à jour des nombres astraux du joueur if (request.rolled.isPart){
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date); // Gestion expérience (si existante)
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstral }); request.competence = actor.getCompetence("astrologie")
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral); request.selectedCarac = actor.system.carac["vue"];
actor.appliquerAjoutExperience(request, 'hide');
} }
request.nbAstral = nbAstral; }
else {
request.nbAstral = await RdDDice.rollTotal("1dhr" + request.nbAstral, {
rollMode: "selfroll", showDice: HIDE_DICE
});
// Mise à jour des nombres astraux du joueur
this.addNbAstralIncorect(request.id, request.date, request.nbAstral);
}
if (Misc.getActiveUser(request.userId)?.isGM) { if (Misc.getActiveUser(request.userId)?.isGM) {
RdDUtility.responseNombreAstral(request); RdDUtility.responseNombreAstral(request);
} else { } else {
@ -468,6 +477,12 @@ export class RdDCalendrier extends Application {
} }
} }
addNbAstralIncorect(actorId, date, nbAstral) {
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == date);
astralData.valeursFausses.push({ actorId: actorId, nombreAstral: nbAstral });
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
findHeure(heure) { findHeure(heure) {
heure = Grammar.toLowerCaseNoAccentNoSpace(heure); heure = Grammar.toLowerCaseNoAccentNoSpace(heure);
@ -496,11 +511,15 @@ export class RdDCalendrier extends Application {
let hn = defHeure.heure; let hn = defHeure.heure;
let chiffreAstral = this.getCurrentNombreAstral() ?? 0; let chiffreAstral = this.getCurrentNombreAstral() ?? 0;
heuresChancesMalchances[0] = { value: "+4", heures: [this.getHeureNumber((hn + chiffreAstral) % RDD_HEURES_PAR_JOUR).label] }; heuresChancesMalchances[0] = { value: "+4", heures: [this.getHeureNumber((hn + chiffreAstral) % RDD_HEURES_PAR_JOUR).label] };
heuresChancesMalchances[1] = { value : "+2", heures: [this.getHeureNumber((hn + chiffreAstral+4) % RDD_HEURES_PAR_JOUR).label, heuresChancesMalchances[1] = {
this.getHeureNumber((hn + chiffreAstral + 8) % RDD_HEURES_PAR_JOUR).label ] }; value: "+2", heures: [this.getHeureNumber((hn + chiffreAstral + 4) % RDD_HEURES_PAR_JOUR).label,
this.getHeureNumber((hn + chiffreAstral + 8) % RDD_HEURES_PAR_JOUR).label]
};
heuresChancesMalchances[2] = { value: "-4", heures: [this.getHeureNumber((hn + chiffreAstral + 6) % RDD_HEURES_PAR_JOUR).label] }; heuresChancesMalchances[2] = { value: "-4", heures: [this.getHeureNumber((hn + chiffreAstral + 6) % RDD_HEURES_PAR_JOUR).label] };
heuresChancesMalchances[3] = { value : "-2", heures: [this.getHeureNumber((hn + chiffreAstral+3) % RDD_HEURES_PAR_JOUR).label, heuresChancesMalchances[3] = {
this.getHeureNumber((hn + chiffreAstral + 9) % RDD_HEURES_PAR_JOUR).label ]}; value: "-2", heures: [this.getHeureNumber((hn + chiffreAstral + 3) % RDD_HEURES_PAR_JOUR).label,
this.getHeureNumber((hn + chiffreAstral + 9) % RDD_HEURES_PAR_JOUR).label]
};
} }
return heuresChancesMalchances; return heuresChancesMalchances;
} }

View File

@ -97,6 +97,7 @@
{{#if options.isObserver}}{{!-- Connaissances Tab --}} {{#if options.isObserver}}{{!-- Connaissances Tab --}}
<div class="tab connaissances" data-group="primary" data-tab="connaissances"> <div class="tab connaissances" data-group="primary" data-tab="connaissances">
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/astrologie.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/taches.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/taches.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvres.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvres.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/jeux.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/jeux.html"}}