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='diffConditions']").val(0);
|
||||
|
||||
this.html.find('[name="jet-astrologie"]').click((event) => {
|
||||
this.requestJetAstrologie();
|
||||
|
@ -14,7 +14,7 @@ import { DialogChronologie } from "./dialog-chronologie.js";
|
||||
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
||||
const heuresList = ["vaisseau", "sirene", "faucon", "couronne", "dragon", "epees", "lyre", "serpent", "poissonacrobate", "araignee", "roseau", "chateaudormant"];
|
||||
const heuresDef = {
|
||||
"vaisseau": {key: "vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "printemps", heure: 0, icon: 'hd01.svg' },
|
||||
"vaisseau": { key: "vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "printemps", heure: 0, icon: 'hd01.svg' },
|
||||
"sirene": { key: "sirene", label: "Sirène", lettreFont: 'i', saison: "printemps", heure: 1, icon: 'hd02.svg' },
|
||||
"faucon": { key: "faucon", label: "Faucon", lettreFont: 'f', saison: "printemps", heure: 2, icon: 'hd03.svg' },
|
||||
"couronne": { key: "couronne", label: "Couronne", lettreFont: '', saison: "ete", heure: 3, icon: 'hd04.svg' },
|
||||
@ -64,7 +64,7 @@ export class RdDCalendrier extends Application {
|
||||
const heure = (typeof value == 'string' || typeof value == 'number') && Number.isInteger(Number(value))
|
||||
? Number(value)
|
||||
: (typeof value == 'string') ? RdDCalendrier.getChiffreFromSigne(value)
|
||||
: undefined
|
||||
: undefined
|
||||
|
||||
if (heure != undefined && ['key', 'label', 'lettreFont', 'saison', 'heure', 'icon'].includes(key)) {
|
||||
return RdDCalendrier.getDefSigne(heure)[key]
|
||||
@ -340,21 +340,21 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
checkMaladie( periode) {
|
||||
checkMaladie(periode) {
|
||||
for (let actor of game.actors) {
|
||||
if (actor.type == 'personnage') {
|
||||
let maladies = actor.items.filter( item => (item.type == 'maladie' || (item.type == 'poison' && item.system.active) ) && item.system.periodicite.toLowerCase().includes(periode) );
|
||||
let maladies = actor.items.filter(item => (item.type == 'maladie' || (item.type == 'poison' && item.system.active)) && item.system.periodicite.toLowerCase().includes(periode));
|
||||
for (let maladie of maladies) {
|
||||
if ( maladie.system.identifie) {
|
||||
if (maladie.system.identifie) {
|
||||
ChatMessage.create({ content: `${actor.name} souffre de ${maladie.name} (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
||||
} else {
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -366,7 +366,7 @@ export class RdDCalendrier extends Application {
|
||||
this.calendrier.minutesRelative -= RDD_MINUTES_PAR_HEURES;
|
||||
this.calendrier.heureRdD += 1;
|
||||
this.checkMaladie("heure");
|
||||
}
|
||||
}
|
||||
if (this.calendrier.heureRdD >= RDD_HEURES_PAR_JOUR) {
|
||||
this.calendrier.heureRdD -= RDD_HEURES_PAR_JOUR;
|
||||
await this.incrementerJour();
|
||||
@ -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);
|
||||
@ -483,7 +498,7 @@ export class RdDCalendrier extends Application {
|
||||
return undefined;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getHeureNumber( hNum) {
|
||||
getHeureNumber(hNum) {
|
||||
let heure = Object.values(heuresDef).find(it => (it.heure) == hNum);
|
||||
return heure
|
||||
}
|
||||
@ -495,12 +510,16 @@ export class RdDCalendrier extends Application {
|
||||
if (defHeure) {
|
||||
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[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[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[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]
|
||||
};
|
||||
}
|
||||
return heuresChancesMalchances;
|
||||
}
|
||||
@ -634,9 +653,9 @@ export class RdDCalendrier extends Application {
|
||||
let heuresParActeur = {};
|
||||
for (let actor of game.actors) {
|
||||
let heureNaissance = actor.getHeureNaissance();
|
||||
if ( heureNaissance) {
|
||||
if (heureNaissance) {
|
||||
heuresParActeur[actor.name] = this.getHeuresChanceMalchance(heureNaissance);
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log("ASTRO", astrologieArray);
|
||||
calendrierData.astrologieData = astrologieArray;
|
||||
|
@ -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"}}
|
||||
|
@ -16,7 +16,7 @@
|
||||
<label> Jours</label>
|
||||
<select name="joursAstrologie" data-dtype="Number">
|
||||
{{#select joursSuivants}}
|
||||
{{#each dates as |date key|}}
|
||||
{{#each dates as |date key|}}
|
||||
<option value={{date.index}}>{{date.label}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
|
Loading…
Reference in New Issue
Block a user