Merge branch 'v1.4-fix' into 'v1.4'

Plusieurs fixes

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!245
This commit is contained in:
Leratier Bretonnien 2021-05-20 16:00:43 +00:00
commit 04b67f2188
8 changed files with 96 additions and 75 deletions

View File

@ -1030,6 +1030,7 @@ export class RdDActor extends Actor {
}
else if (dest?.isEquipementSimilaire(item)) {
await this.regrouperEquipementsSimilaires(item, dest);
result = false;
}
}
}
@ -1800,7 +1801,7 @@ export class RdDActor extends Actor {
jetVie: {
forceAlcool: forceAlcool,
nbDoses: nbDoses,
selectedCarac: actorData.data.carac.constitution,
selectedCarac: actorData.data.sante.vie,
carac: actorData.data.carac,
caracValue: actorData.data.sante.vie.max,
finalLevel: etat + forceAlcool - nbDoses,
@ -1809,6 +1810,7 @@ export class RdDActor extends Actor {
}
await RdDResolutionTable.rollData(ethylismeData.jetVie);
this._appliquerExperienceRollData(ethylismeData.jetVie);
RollDataAjustements.calcul(ethylismeData.jetVie, this);
if (ethylismeData.jetVie.rolled.isSuccess) {
ethylisme.nb_doses++;
@ -1816,22 +1818,22 @@ export class RdDActor extends Actor {
ethylisme.value = Math.max(ethylisme.value - 1, -7);
ethylisme.nb_doses = 0;
let perte = await RdDDice.rollTotal("1d6", {showDice:true});
let perte = await RdDDice.rollTotal("1d6", { showDice: true });
ethylismeData.perteEndurance = await this.santeIncDec("endurance", -perte, { ethylisme: true });
if (!ethylisme.jet_moral) {
ethylismeData.jetMoral = await this._jetMoral('heureuse');
if (ethylismeData.jetMoral.ajustement == 1) {
ethylismeData.moralAlcool ='heureux';
ethylismeData.moralAlcool = 'heureux';
ethylisme.jet_moral = true;
} else if (ethylisme.value == -1) {
ethylismeData.jetMoral.ajustement = -1;
ethylismeData.moralAlcool ='triste';
ethylismeData.moralAlcool = 'triste';
ethylisme.jet_moral = true;
await this.moralIncDec(-1);
}
}
if (ethylisme.value<0) {
if (ethylisme.value < 0) {
// Qui a bu boira (p 164)
ethylismeData.jetVolonte = {
selectedCarac: actorData.data.carac.volonte,
@ -1841,6 +1843,7 @@ export class RdDActor extends Actor {
showDice: true
}
await RdDResolutionTable.rollData(ethylismeData.jetVolonte);
this._appliquerExperienceRollData(ethylismeData.jetVolonte);
RollDataAjustements.calcul(ethylismeData.jetVolonte, this);
}
}
@ -2315,7 +2318,9 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
_appliquerExperienceRollData(rollData) {
const callback = this.createCallbackExperience();
if (callback.condition(rollData)) { callback.action(rollData); }
if (callback.condition(rollData)) {
callback.action(rollData);
}
}
/* -------------------------------------------- */
@ -2777,6 +2782,7 @@ export class RdDActor extends Actor {
return { result: false, xpcarac: 0, xpCompetence: 0 };
}
if (caracName == 'Vie') caracName = 'constitution';
if (caracName == 'derobee') caracName = 'agilite';
if (caracName == 'reve-actuel') caracName = 'reve';
let xp = Math.abs(rolled.finalLevel);
@ -3405,7 +3411,7 @@ export class RdDActor extends Actor {
ui.notifications.info("Inutile de se vendre à soi-même");
return;
}
if (!game.user.isGM) {
if (!Misc.isElectedUser()) {
RdDActor.remoteActorCall({
userId: Misc.connectedGMOrUser(),
actorId: this.vendeur?.id ?? this.acheteur?.id,
@ -3449,10 +3455,14 @@ export class RdDActor extends Actor {
if (acheteur) {
// TODO: achat depuis un compendium
const achat = duplicate(Misc.data(vendeur?.getObjet(itemId) ?? game.items.get(itemId)));
const itemData = Misc.data(vendeur?.getObjet(itemId) ?? game.items.get(itemId));
const achat = {
type: itemData.type,
img: itemData.img,
name: itemData.name,
data: itemData.data
}
achat.data.quantite = venteData.quantiteTotal;
achat._id = undefined;
// TODO: investigate bug - création marche mal...
await acheteur.createEmbeddedDocuments("Item", [achat]);
}
if (coutDeniers > 0) {
@ -3464,6 +3474,7 @@ export class RdDActor extends Actor {
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-achat-item.html', venteData)
});
if (!venteData.quantiteIllimite) {
if (venteData.quantiteNbLots <= venteData.nombreLots) {
ChatUtility.removeChatMessageId(chatMessageIdVente);
}
@ -3475,7 +3486,7 @@ export class RdDActor extends Actor {
messageVente.update({ content: newMessageVente });
messageVente.render(true);
}
}
}
/* -------------------------------------------- */

View File

@ -29,6 +29,7 @@ export class DialogItemAchat extends Dialog {
vendeur: Misc.data(vendeur),
acheteur: Misc.data(acheteur),
tailleLot: event.currentTarget.attributes['data-tailleLot']?.value ?? 1,
quantiteIllimite : event.currentTarget.attributes['data-quantiteIllimite']?.value == 'true',
quantiteNbLots: event.currentTarget.attributes['data-quantiteNbLots']?.value,
nombreLots: 1,
prixLot: prixLot,

View File

@ -39,11 +39,11 @@ export const defaultItemImg = {
/* -------------------------------------------- */
export class RdDItem extends Item {
constructor(data) {
constructor(data, context) {
if (!data.img) {
data.img = defaultItemImg[data.type];
}
super(data);
super(data, context);
}
static getTypeObjetsEquipement() {

View File

@ -6,7 +6,7 @@ import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDUtility } from "./rdd-utility.js";
import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js";
import {RdDDice } from "./rdd-dice.js";
import { RdDDice } from "./rdd-dice.js";
/* -------------------------------------------- */
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
@ -65,14 +65,15 @@ export class RdDCalendrier extends Application {
// nombre astral
if (game.user.isGM) {
this.listeNombreAstral = this._loadListNombreAstral();
this.rebuildListeNombreAstral(); // Ensure always up-to-date
await this.rebuildListeNombreAstral(); // Ensure always up-to-date
}
console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral);
}
/* -------------------------------------------- */
_loadListNombreAstral() {
return Object.values(game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral"));
const listeNombreAstraux = game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral");
return Object.values(listeNombreAstraux);
}
/* -------------------------------------------- */
@ -96,8 +97,10 @@ export class RdDCalendrier extends Application {
getNumericDateFromIndex(index = undefined) {
if (!index) index = this.getCurrentDayIndex();
let month = Math.floor(index / 28)
return { month: heuresList[month],
day: (index - (month * 28)) + 1 }
return {
month: heuresList[month],
day: (index - (month * 28)) + 1
}
}
/* -------------------------------------------- */
@ -112,7 +115,7 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */
getIndexFromDate(jour, mois) {
return (heuresDef[mois].heure * 28) + (jour-1);
return (heuresDef[mois].heure * 28) + (jour - 1);
}
/* -------------------------------------------- */
getJoursSuivants(num) {
@ -127,41 +130,45 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */
async ajouterNombreAstral(index) {
const nombreAstral = await RdDDice.rollTotal("1dh");
return {
nombreAstral: await RdDDice.rollTotal("1dh"),
nombreAstral: nombreAstral,
valeursFausses: [],
index: index
}
}
/* -------------------------------------------- */
getCurrentNombreAstral() {
async getCurrentNombreAstral() {
let indexDate = this.getCurrentDayIndex();
return this.getNombreAstral(indexDate);
return await this.getNombreAstral(indexDate);
}
/* -------------------------------------------- */
resetNombreAstral( ) {
resetNombreAstral() {
this.listeNombreAstral = [];
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
}
/* -------------------------------------------- */
getNombreAstral(indexDate) {
async getNombreAstral(indexDate) {
const liste = this.listeNombreAstral ?? this._loadListNombreAstral();
let astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate);
if (!astralData?.nombreAstral) {
this.rebuildListeNombreAstral();
await this.rebuildListeNombreAstral();
astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate);
}
return astralData?.nombreAstral ?? "N/A";
}
/* -------------------------------------------- */
rebuildListeNombreAstral() {
async rebuildListeNombreAstral() {
let jourCourant = this.getCurrentDayIndex();
let jourFin = jourCourant + 12;
let newList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(i => this.ajouterNombreAstral(jourCourant + i));
let newList = [];
for (let i=0; i<12; i++) {
newList.push(await this.ajouterNombreAstral(jourCourant + i));
}
if (this.listeNombreAstral) {
for (const na of this.listeNombreAstral) {
if (na && na.index >= jourCourant && na.index < jourFin) {
@ -173,21 +180,21 @@ export class RdDCalendrier extends Application {
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
}
/* -------------------------------------------- */
onCalendarButton(ev) {
async onCalendarButton(ev) {
ev.preventDefault();
const calendarAvance = ev.currentTarget.attributes['data-calendar-avance'];
const calendarSet = ev.currentTarget.attributes['data-calendar-set'];
if (calendarAvance) {
this.incrementTime(Number(calendarAvance.value));
await this.incrementTime(Number(calendarAvance.value));
}
else if (calendarSet) {
this.positionnerHeure(Number(calendarSet.value));
}
this.updateDisplay();
await this.updateDisplay();
}
/* -------------------------------------------- */
incrementTime(minutes = 0) {
async incrementTime(minutes = 0) {
this.calendrier.minutesRelative += minutes;
if (this.calendrier.minutesRelative >= 120) {
this.calendrier.minutesRelative -= 120;
@ -195,7 +202,7 @@ export class RdDCalendrier extends Application {
}
if (this.calendrier.heureRdD > 11) {
this.calendrier.heureRdD -= 12;
this.incrementerJour();
await this.incrementerJour();
}
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
// Notification aux joueurs
@ -206,7 +213,7 @@ export class RdDCalendrier extends Application {
}
/* -------------------------------------------- */
incrementerJour() {
async incrementerJour() {
this.calendrier.jour += 1;
if (this.calendrier.jour >= RDD_JOUR_PAR_MOIS) {
this.calendrier.jour -= RDD_JOUR_PAR_MOIS;
@ -215,19 +222,20 @@ export class RdDCalendrier extends Application {
this.calendrier.moisRdD += 1;
// Reconstruire les nombres astraux
}
this.rebuildListeNombreAstral();
await this.rebuildListeNombreAstral();
}
/* -------------------------------------------- */
syncPlayerTime(calendrier) {
async syncPlayerTime(calendrier) {
this.calendrier = duplicate(calendrier); // Local copy update
this.updateDisplay();
await this.updateDisplay();
}
/* -------------------------------------------- */
positionnerHeure(indexHeure) {
if (indexHeure <= this.calendrier.heureRdD)
this.incrementerJour();
async positionnerHeure(indexHeure) {
if (indexHeure <= this.calendrier.heureRdD){
await this.incrementerJour();
}
this.calendrier.heureRdD = indexHeure;
this.calendrier.minutesRelative = 0;
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
@ -269,18 +277,18 @@ export class RdDCalendrier extends Application {
console.log(request);
let jourDiff = this.getLectureAstrologieDifficulte(request.date);
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat);
let rollData= {
let rollData = {
caracValue: request.carac_vue,
finalLevel: niveau,
showDice: false
};
await RdDResolutionTable.rollData(rollData);
let nbAstral = this.getNombreAstral(request.date);
let nbAstral = await this.getNombreAstral(request.date);
request.rolled = rollData.rolled;
request.isValid = true;
if (!request.rolled.isSuccess) {
request.isValid = false;
nbAstral = await RdDDice.rollTotal("1dhr"+nbAstral);
nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral);
// 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 });
@ -299,11 +307,11 @@ export class RdDCalendrier extends Application {
}
/* -------------------------------------------- */
getAjustementAstrologique(heureNaissance, name = 'inconnu') {
async getAjustementAstrologique(heureNaissance, name = 'inconnu') {
let heure = Grammar.toLowerCaseNoAccent(heureNaissance);
if (heure && heuresDef[heure]) {
let hn = heuresDef[heure].heure;
let chiffreAstral = this.getCurrentNombreAstral();
let chiffreAstral = await this.getCurrentNombreAstral();
let heureCourante = this.calendrier.heureRdD;
let ecartChance = (hn + chiffreAstral - heureCourante) % 12;
switch (ecartChance) {
@ -350,12 +358,12 @@ export class RdDCalendrier extends Application {
}
/* -------------------------------------------- */
updateDisplay() {
async updateDisplay() {
let data = this.fillCalendrierData();
// Rebuild data
let dateHTML = `Jour ${data.jourMois} de ${data.nomMois} (${data.nomSaison})`;
if (game.user.isGM) {
dateHTML = dateHTML + " - NA: " + this.getCurrentNombreAstral();
dateHTML = dateHTML + " - NA: " + await this.getCurrentNombreAstral();
}
for (let handle of document.getElementsByClassName("calendar-date-rdd")) {
handle.innerHTML = dateHTML;
@ -372,16 +380,16 @@ export class RdDCalendrier extends Application {
}
/* -------------------------------------------- */
saveEditeur(calendrierData) {
async saveEditeur(calendrierData) {
this.calendrier.minutesRelative = Number(calendrierData.minutesRelative);
this.calendrier.jour = Number(calendrierData.jourMois) - 1;
this.calendrier.moisRdD = heuresList.findIndex(mois => mois === calendrierData.moisKey);
this.calendrier.heureRdD = heuresList.findIndex(heure => heure === calendrierData.heureKey);; // Index dans heuresList
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
this.rebuildListeNombreAstral();
await this.rebuildListeNombreAstral();
this.updateDisplay();
await this.updateDisplay();
}
/* -------------------------------------------- */
@ -421,12 +429,12 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
async activateListeners(html) {
super.activateListeners(html);
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
this.updateDisplay();
await this.updateDisplay();
html.find('.calendar-btn').click(ev => this.onCalendarButton(ev));

View File

@ -134,9 +134,8 @@ export class RdDDice {
return roll;
}
static async rollTotal(formula) {
const roll = new Roll(formula);
await roll.evaluate({ async: true });
static async rollTotal(formula, options = { showDice: false }) {
const roll = await RdDDice.roll(formula, options);
return roll.total;
}

View File

@ -3,7 +3,7 @@
{{#if bless.active}}
<i class="fas fa-skull-crossbones blessure-active-{{gravite}}"></i>
{{else}}
<i class="fas fa-skull-crossbones fas-inactive"></i>
<i class="fas fa-skull-crossbones blessure-inactive"></i>
{{/if}}
</td>
<td>

View File

@ -243,7 +243,7 @@
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=competenceByCategory.tir categorie="Compétences de Tir"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=competenceByCategory.lancer categorie="Compétences de Lancer"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=competenceByCategory.connaissance categorie="Connaissances"}}
{{#if data.attributs.hautrevant.value}}
{{#if (or data.attributs.hautrevant.value options.montrerArchetype)}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=competenceByCategory.draconic categorie="Draconic"}}
{{/if}}

View File

@ -15,13 +15,15 @@
{{item.name}}</h4>
</div>
{{#unless quantiteIllimite}}
<div class="flexrow flex-group-left">
<label>{{#if (gt tailleLot 1)}}Lots disponibles
{{else}}Quantité disponible{{/if}}</label>
<label>{{quantiteNbLots}}</label>
<label>{{#if quantiteIllimite}}
pas de limite
{{else}}
{{quantiteNbLots}}
{{/if}}</label>
</div>
{{/unless}}
<div class="flexrow flex-group-left">
<label>
{{#if (gt tailleLot 1)}}Nombre de lots de {{tailleLot}}