Fix astrologie joueur
This commit is contained in:
parent
c79298b60a
commit
454193490d
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -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();
|
||||||
|
@ -14,7 +14,7 @@ import { DialogChronologie } from "./dialog-chronologie.js";
|
|||||||
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
||||||
const heuresList = ["vaisseau", "sirene", "faucon", "couronne", "dragon", "epees", "lyre", "serpent", "poissonacrobate", "araignee", "roseau", "chateaudormant"];
|
const heuresList = ["vaisseau", "sirene", "faucon", "couronne", "dragon", "epees", "lyre", "serpent", "poissonacrobate", "araignee", "roseau", "chateaudormant"];
|
||||||
const heuresDef = {
|
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' },
|
"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' },
|
"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' },
|
"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))
|
const heure = (typeof value == 'string' || typeof value == 'number') && Number.isInteger(Number(value))
|
||||||
? Number(value)
|
? Number(value)
|
||||||
: (typeof value == 'string') ? RdDCalendrier.getChiffreFromSigne(value)
|
: (typeof value == 'string') ? RdDCalendrier.getChiffreFromSigne(value)
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
if (heure != undefined && ['key', 'label', 'lettreFont', 'saison', 'heure', 'icon'].includes(key)) {
|
if (heure != undefined && ['key', 'label', 'lettreFont', 'saison', 'heure', 'icon'].includes(key)) {
|
||||||
return RdDCalendrier.getDefSigne(heure)[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) {
|
for (let actor of game.actors) {
|
||||||
if (actor.type == 'personnage') {
|
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) {
|
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 !` });
|
ChatMessage.create({ content: `${actor.name} souffre de ${maladie.name} (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
||||||
} else {
|
} else {
|
||||||
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -366,7 +366,7 @@ export class RdDCalendrier extends Application {
|
|||||||
this.calendrier.minutesRelative -= RDD_MINUTES_PAR_HEURES;
|
this.calendrier.minutesRelative -= RDD_MINUTES_PAR_HEURES;
|
||||||
this.calendrier.heureRdD += 1;
|
this.calendrier.heureRdD += 1;
|
||||||
this.checkMaladie("heure");
|
this.checkMaladie("heure");
|
||||||
}
|
}
|
||||||
if (this.calendrier.heureRdD >= RDD_HEURES_PAR_JOUR) {
|
if (this.calendrier.heureRdD >= RDD_HEURES_PAR_JOUR) {
|
||||||
this.calendrier.heureRdD -= RDD_HEURES_PAR_JOUR;
|
this.calendrier.heureRdD -= RDD_HEURES_PAR_JOUR;
|
||||||
await this.incrementerJour();
|
await this.incrementerJour();
|
||||||
@ -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);
|
||||||
@ -483,7 +498,7 @@ export class RdDCalendrier extends Application {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getHeureNumber( hNum) {
|
getHeureNumber(hNum) {
|
||||||
let heure = Object.values(heuresDef).find(it => (it.heure) == hNum);
|
let heure = Object.values(heuresDef).find(it => (it.heure) == hNum);
|
||||||
return heure
|
return heure
|
||||||
}
|
}
|
||||||
@ -495,12 +510,16 @@ export class RdDCalendrier extends Application {
|
|||||||
if (defHeure) {
|
if (defHeure) {
|
||||||
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,
|
||||||
heuresChancesMalchances[2] = { value : "-4", heures: [this.getHeureNumber((hn + chiffreAstral+6) % RDD_HEURES_PAR_JOUR).label]};
|
this.getHeureNumber((hn + chiffreAstral + 8) % 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[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;
|
return heuresChancesMalchances;
|
||||||
}
|
}
|
||||||
@ -634,9 +653,9 @@ export class RdDCalendrier extends Application {
|
|||||||
let heuresParActeur = {};
|
let heuresParActeur = {};
|
||||||
for (let actor of game.actors) {
|
for (let actor of game.actors) {
|
||||||
let heureNaissance = actor.getHeureNaissance();
|
let heureNaissance = actor.getHeureNaissance();
|
||||||
if ( heureNaissance) {
|
if (heureNaissance) {
|
||||||
heuresParActeur[actor.name] = this.getHeuresChanceMalchance(heureNaissance);
|
heuresParActeur[actor.name] = this.getHeuresChanceMalchance(heureNaissance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("ASTRO", astrologieArray);
|
//console.log("ASTRO", astrologieArray);
|
||||||
calendrierData.astrologieData = astrologieArray;
|
calendrierData.astrologieData = astrologieArray;
|
||||||
|
@ -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"}}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<label> Jours</label>
|
<label> Jours</label>
|
||||||
<select name="joursAstrologie" data-dtype="Number">
|
<select name="joursAstrologie" data-dtype="Number">
|
||||||
{{#select joursSuivants}}
|
{{#select joursSuivants}}
|
||||||
{{#each dates as |date key|}}
|
{{#each dates as |date key|}}
|
||||||
<option value={{date.index}}>{{date.label}}</option>
|
<option value={{date.index}}>{{date.label}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
Loading…
Reference in New Issue
Block a user