Merge branch 'v1.5-fixes' into 'v1.5'
Fixes mineurs See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!286
This commit is contained in:
commit
5bc0cec515
@ -2082,7 +2082,7 @@ export class RdDActor extends Actor {
|
||||
createCallbackExperience() {
|
||||
return {
|
||||
condition: r => r.rolled.isPart && r.finalLevel < 0 && game.settings.get("core", "rollMode") != 'selfroll',
|
||||
action: r => this.appliquerAjoutExperience(r, game.settings.get("core", "rollMode") != 'blindroll')
|
||||
action: r => this.appliquerAjoutExperience(r, (game.settings.get("core", "rollMode") != 'blindroll' && !user.isGM))
|
||||
};
|
||||
}
|
||||
|
||||
@ -2157,7 +2157,7 @@ export class RdDActor extends Actor {
|
||||
let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence);
|
||||
if (xpData && display) {
|
||||
let message = {
|
||||
whisher: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData)
|
||||
}
|
||||
ChatMessage.create(message);
|
||||
@ -3401,7 +3401,7 @@ export class RdDActor extends Actor {
|
||||
return true;
|
||||
}
|
||||
const tplData = Misc.templateData(this);
|
||||
let rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(tplData.carac.niveau.value));
|
||||
let rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(Misc.templateData(entite).carac.niveau.value));
|
||||
const rollData = {
|
||||
alias: this.name,
|
||||
rolled: rolled,
|
||||
|
@ -26,7 +26,7 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
competence: itemData.name,
|
||||
resistance: 100,
|
||||
equipe: true,
|
||||
dommagesReels: arme.data.dommages,
|
||||
dommagesReels: itemData.data.dommages,
|
||||
penetration: 0,
|
||||
force: 0,
|
||||
rapide: true
|
||||
|
@ -45,9 +45,13 @@ export class RdDCalendrier extends Application {
|
||||
return { top: 200, left: 200 };
|
||||
}
|
||||
|
||||
static getDefSigne(moisRdD) {
|
||||
moisRdD = moisRdD % RDD_MOIS_PAR_AN;
|
||||
return Object.values(heuresDef).find(h => h.heure == moisRdD);
|
||||
static getDefSigne(chiffre) {
|
||||
chiffre = chiffre % RDD_MOIS_PAR_AN;
|
||||
return Object.values(heuresDef).find(h => h.heure == chiffre);
|
||||
}
|
||||
|
||||
static getChiffreFromSigne(signe) {
|
||||
return heuresList.indexOf(signe);
|
||||
}
|
||||
|
||||
static getCalendrier(index) {
|
||||
@ -63,55 +67,50 @@ export class RdDCalendrier extends Application {
|
||||
return calendrier;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async initCalendrier() {
|
||||
// Calendrier
|
||||
this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier"));
|
||||
this.calendrier.annee = this.calendrier.annee ?? (this.calendrier.moisRdD == RDD_MOIS_PAR_AN ? 1 : 0);
|
||||
this.calendrier.moisRdD = (this.calendrier.moisRdD ?? 0) % RDD_MOIS_PAR_AN;
|
||||
|
||||
//console.log("CALENDRIER", this.calendrier);
|
||||
if (this.calendrier == undefined || this.calendrier.moisRdD == undefined) {
|
||||
this.calendrier = RdDCalendrier.getCalendrier(0);
|
||||
if (game.user.isGM) { // Uniquement si GM
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier);
|
||||
}
|
||||
}
|
||||
constructor() {
|
||||
super();
|
||||
// position
|
||||
this.calendrierPos = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier-pos"));
|
||||
if (this.calendrierPos == undefined || this.calendrierPos.top == undefined) {
|
||||
this.calendrierPos = RdDCalendrier.createCalendrierPos();
|
||||
if (game.user.isGM) { // Uniquement si GM
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos);
|
||||
}
|
||||
|
||||
// Calendrier
|
||||
this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier") ?? RdDCalendrier.getCalendrier(0));
|
||||
this.calendrier.annee = this.calendrier.annee ?? Math.floor((this.calendrier.moisRdD ?? 0) / RDD_MOIS_PAR_AN);
|
||||
this.calendrier.moisRdD = (this.calendrier.moisRdD ?? 0) % RDD_MOIS_PAR_AN;
|
||||
|
||||
if (game.user.isGM) { // Uniquement si GM
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier);
|
||||
}
|
||||
|
||||
// nombre astral
|
||||
if (game.user.isGM) {
|
||||
this.listeNombreAstral = this._loadListNombreAstral();
|
||||
await this.rebuildListeNombreAstral(false); // Ensure always up-to-date
|
||||
this.listeNombreAstral = this.getListeNombreAstral();
|
||||
this.rebuildListeNombreAstral(false); // Ensure always up-to-date
|
||||
}
|
||||
console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_loadListNombreAstral() {
|
||||
const listeNombreAstraux = game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral");
|
||||
return listeNombreAstraux ?? [];
|
||||
getListeNombreAstral() {
|
||||
return game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral") ?? [];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static get defaultOptions() {
|
||||
const options = super.defaultOptions;
|
||||
options.template = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html";
|
||||
options.popOut = false;
|
||||
options.resizable = false;
|
||||
return options;
|
||||
return mergeObject(super.defaultOptions, {
|
||||
template: "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html",
|
||||
popOut: false,
|
||||
resizable: false
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDateFromIndex(index) {
|
||||
const date = RdDCalendrier.getCalendrier(index ?? this.getCurrentDayIndex());
|
||||
return (date.jour+1) + ' ' + heuresDef[heuresList[date.moisRdD]].label;
|
||||
return (date.jour + 1) + ' ' + RdDCalendrier.getDefSigne(date.moisRdD).label;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -183,34 +182,23 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getNombreAstral(indexDate) {
|
||||
if (this.listeNombreAstral == undefined) {
|
||||
this.listeNombreAstral = this._loadListNombreAstral() || [];
|
||||
}
|
||||
let liste = this.listeNombreAstral;
|
||||
if ( game.user.isGM ) {
|
||||
if ( typeof(liste) != 'Array' || liste.length == 0 ) {
|
||||
this.rebuildListeNombreAstral();
|
||||
liste = this.listeNombreAstral;
|
||||
}
|
||||
}
|
||||
let astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate);
|
||||
|
||||
let astralData = this.getListeNombreAstral().find((nombreAstral, i) => nombreAstral.index == indexDate);
|
||||
return astralData?.nombreAstral;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rebuildListeNombreAstral(showDice = true) {
|
||||
if (game.user.isGM) {
|
||||
console.log("rebuildListeNombreAstral", showDice);
|
||||
let jourCourant = this.getCurrentDayIndex();
|
||||
|
||||
let newList = [];
|
||||
for (let i = 0; i < MAX_NOMBRE_ASTRAL; i++) {
|
||||
let dayIndex = jourCourant + i;
|
||||
let na = this.listeNombreAstral.find(n => n.index == dayIndex);
|
||||
if (na) {
|
||||
newList[i] = duplicate(na);
|
||||
newList[i] = na;
|
||||
} else {
|
||||
newList[i] = await this.ajouterNombreAstral(dayIndex, showDice );
|
||||
newList[i] = await this.ajouterNombreAstral(dayIndex, showDice);
|
||||
}
|
||||
}
|
||||
//console.log("SAVE list", newList, jourCourant);
|
||||
@ -242,7 +230,7 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
if (this.calendrier.heureRdD >= RDD_HEURES_PAR_JOUR) {
|
||||
this.calendrier.heureRdD -= RDD_HEURES_PAR_JOUR;
|
||||
this.incrementerJour();
|
||||
await this.incrementerJour();
|
||||
}
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
|
||||
// Notification aux joueurs
|
||||
@ -253,10 +241,10 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
incrementerJour() {
|
||||
async incrementerJour() {
|
||||
const index = this.getCurrentDayIndex() + 1;
|
||||
this.calendrier = RdDCalendrier.getCalendrier(index);
|
||||
this.rebuildListeNombreAstral();
|
||||
await this.rebuildListeNombreAstral();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -268,7 +256,7 @@ export class RdDCalendrier extends Application {
|
||||
/* -------------------------------------------- */
|
||||
async positionnerHeure(indexHeure) {
|
||||
if (indexHeure <= this.calendrier.heureRdD) {
|
||||
this.incrementerJour();
|
||||
await this.incrementerJour();
|
||||
}
|
||||
this.calendrier.heureRdD = indexHeure;
|
||||
this.calendrier.minutesRelative = 0;
|
||||
@ -277,13 +265,14 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
fillCalendrierData(formData = {}) {
|
||||
console.log(this.calendrier);
|
||||
let moisKey = heuresList[this.calendrier.moisRdD];
|
||||
let heureKey = heuresList[this.calendrier.heureRdD];
|
||||
console.log(moisKey, heureKey);
|
||||
|
||||
const mois = heuresDef[moisKey];
|
||||
const heure = heuresDef[heureKey];
|
||||
|
||||
//console.log(moisKey, heureKey);
|
||||
formData.heureKey = heureKey;
|
||||
formData.moisKey = moisKey;
|
||||
formData.jourMois = this.calendrier.jour + 1;
|
||||
@ -436,8 +425,8 @@ export class RdDCalendrier extends Application {
|
||||
async saveEditeur(calendrierData) {
|
||||
this.calendrier.minutesRelative = Number(calendrierData.minutesRelative);
|
||||
this.calendrier.jour = Number(calendrierData.jourMois) - 1;
|
||||
this.calendrier.moisRdD = RdDCalendrier.getDefSigne(calendrierData.moisKey);
|
||||
this.calendrier.heureRdD = RdDCalendrier.getDefSigne(calendrierData.heureKey); // Index dans heuresList
|
||||
this.calendrier.moisRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.moisKey);
|
||||
this.calendrier.heureRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.heureKey);
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
|
||||
|
||||
await this.rebuildListeNombreAstral();
|
||||
@ -454,7 +443,7 @@ export class RdDCalendrier extends Application {
|
||||
async showCalendarEditor() {
|
||||
let calendrierData = duplicate(this.fillCalendrierData());
|
||||
if (this.editeur == undefined) {
|
||||
calendrierData.jourMoisOptions = this.buildJoursMois();
|
||||
calendrierData.jourMoisOptions = RdDCalendrier.buildJoursMois();
|
||||
calendrierData.heuresOptions = [0, 1];
|
||||
calendrierData.minutesOptions = Array(RDD_MINUTES_PAR_HEURES).fill().map((item, index) => 0 + index);
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html', calendrierData);
|
||||
|
@ -221,7 +221,6 @@ Hooks.once("ready", async function () {
|
||||
/* -------------------------------------------- */
|
||||
/* Affiche/Init le calendrier */
|
||||
let calendrier = new RdDCalendrier();
|
||||
await calendrier.initCalendrier();
|
||||
let templatePath = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html";
|
||||
let templateData = {};
|
||||
renderTemplate(templatePath, templateData).then(html => {
|
||||
|
@ -891,7 +891,7 @@ export class RdDUtility {
|
||||
static distribuerStress(stressValue, raison = 'Inconnu', nomJoueur = undefined) {
|
||||
if (game.user.isGM) {
|
||||
if (stressValue == undefined){
|
||||
ui.notifications.warn("Pas de valeuir de stress à distribuer!");
|
||||
ui.notifications.warn("Pas de valeur de stress à distribuer!");
|
||||
return;
|
||||
}
|
||||
if (nomJoueur == undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user