Fix astrologie joueur
This commit is contained in:
parent
c79298b60a
commit
454193490d
@ -3073,32 +3073,30 @@ export class RdDActor extends RdDBaseActor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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
|
||||
const item = {
|
||||
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)) }
|
||||
};
|
||||
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
|
||||
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() {
|
||||
// Suppression des anciens nombres astraux
|
||||
await this.supprimerAnciensNombresAstraux();
|
||||
|
||||
// Afficher l'interface spéciale
|
||||
const astrologieDialog = await RdDAstrologieJoueur.create(this, {});
|
||||
astrologieDialog.render(true);
|
||||
await RdDAstrologieJoueur.create(this);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -10,7 +10,7 @@ import { SYSTEM_SOCKET_ID } from "./constants.js";
|
||||
export class RdDAstrologieJoueur extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async create(actor, dialogConfig) {
|
||||
static async create(actor) {
|
||||
|
||||
let dialogData = {
|
||||
nombres: this.organizeNombres(actor),
|
||||
@ -20,15 +20,14 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
astrologie: RdDItemCompetence.findCompetence(actor.items, 'Astrologie')
|
||||
}
|
||||
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) {
|
||||
mergeObject(options, dialogConfig.options, { overwrite: true });
|
||||
}
|
||||
return new RdDAstrologieJoueur(html, actor, dialogData);
|
||||
|
||||
const options = { classes: ["rdd-roll-dialog"], width: 600, height: 'fit-content', 'z-index': 99999 };
|
||||
const dialog = new RdDAstrologieJoueur(html, actor, dialogData, options);
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(html, actor, dialogData) {
|
||||
constructor(html, actor, dialogData, dialogOptions) {
|
||||
const dialogConf = {
|
||||
title: "Nombres Astraux",
|
||||
content: html,
|
||||
@ -37,7 +36,6 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
saveButton: { label: "Fermer", callback: html => this.quitDialog() }
|
||||
},
|
||||
};
|
||||
const dialogOptions = { classes: ["rdd-roll-dialog"], width: 600, height: 300, 'z-index': 99999 };
|
||||
super(dialogConf, dialogOptions);
|
||||
|
||||
this.actor = actor;
|
||||
@ -49,9 +47,7 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
super.activateListeners(html);
|
||||
this.html = html;
|
||||
|
||||
this.html.find(function () {
|
||||
this.html.find("[name='diffConditions']").val(0);
|
||||
});
|
||||
|
||||
this.html.find('[name="jet-astrologie"]').click((event) => {
|
||||
this.requestJetAstrologie();
|
||||
|
@ -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 !` });
|
||||
}
|
||||
let itemMaladie = actor.getItem(maladie.id)
|
||||
itemMaladie.postItemToChat('gmroll');
|
||||
itemMaladie.postItem('gmroll');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -434,6 +434,7 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async requestNombreAstral(request) {
|
||||
const actor = game.actors.get(request.id);
|
||||
if (Misc.isUniqueConnectedGM()) { // Only once
|
||||
console.log(request);
|
||||
let jourDiff = this.getLectureAstrologieDifficulte(request.date);
|
||||
@ -445,18 +446,26 @@ export class RdDCalendrier extends Application {
|
||||
rollMode: "blindroll"
|
||||
};
|
||||
await RdDResolutionTable.rollData(rollData);
|
||||
let nbAstral = this.getNombreAstral(request.date);
|
||||
request.rolled = rollData.rolled;
|
||||
request.isValid = true;
|
||||
if (!request.rolled.isSuccess) {
|
||||
request.isValid = false;
|
||||
nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral, { rollMode: "selfroll" });
|
||||
// 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: nbAstral });
|
||||
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
|
||||
request.isValid = request.rolled.isSuccess;
|
||||
request.nbAstral = this.getNombreAstral(request.date);
|
||||
|
||||
if (request.rolled.isSuccess) {
|
||||
if (request.rolled.isPart){
|
||||
// Gestion expérience (si existante)
|
||||
request.competence = actor.getCompetence("astrologie")
|
||||
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) {
|
||||
RdDUtility.responseNombreAstral(request);
|
||||
} 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) {
|
||||
heure = Grammar.toLowerCaseNoAccentNoSpace(heure);
|
||||
@ -496,11 +511,15 @@ export class RdDCalendrier extends Application {
|
||||
let hn = defHeure.heure;
|
||||
let chiffreAstral = this.getCurrentNombreAstral() ?? 0;
|
||||
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,
|
||||
this.getHeureNumber((hn + chiffreAstral + 8) % RDD_HEURES_PAR_JOUR).label ] };
|
||||
heuresChancesMalchances[1] = {
|
||||
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[3] = { value : "-2", heures: [this.getHeureNumber((hn + chiffreAstral+3) % RDD_HEURES_PAR_JOUR).label,
|
||||
this.getHeureNumber((hn + chiffreAstral + 9) % RDD_HEURES_PAR_JOUR).label ]};
|
||||
heuresChancesMalchances[3] = {
|
||||
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;
|
||||
}
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
{{#if options.isObserver}}{{!-- Connaissances Tab --}}
|
||||
<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/oeuvres.html"}}
|
||||
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/jeux.html"}}
|
||||
|
Loading…
Reference in New Issue
Block a user