diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index fd9fb336..ed649231 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -220,7 +220,7 @@ export class RdDActorSheet extends ActorSheet {
RdDUtility.selectObjetType( this );
});
html.find('.creer-une-oeuvre').click(async event => {
- this.selectTypeOeuvre();
+ RdDUtility.selectTypeOeuvre(this);
});
html.find('#nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs();
diff --git a/module/actor.js b/module/actor.js
index 194106a9..94369442 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -31,6 +31,7 @@ import { DialogConsommer } from "./dialog-item-consommer.js";
import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js";
import { RollDataAjustements } from "./rolldata-ajustements.js";
import { DialogItemAchat } from "./dialog-item-achat.js";
+import { RdDItem } from "./item.js";
/* -------------------------------------------- */
@@ -810,7 +811,8 @@ export class RdDActor extends Actor {
if (caracName == 'Taille') {
return;
}
- await this.update({ [`data.carac.${caracName}.xp`]: caracXP ?? 0 });
+ // if ( isNaN(caracXP) || typeof(caracXP) != 'number') caracXP = 0;
+ //await this.update({ [`data.carac.${caracName}.xp`]: caracXP });
this.checkCaracXP(caracName);
}
@@ -896,7 +898,7 @@ export class RdDActor extends Actor {
async updateCompetenceXP(compName, newXp) {
let comp = this.getCompetence(compName);
if (comp) {
- newXp = newXp ?? 0;
+ if ( isNaN(newXp) || typeof(newXp) != 'number') newXp = 0;
this.checkCompetenceXP(compName, newXp);
const update = { _id: comp.id, 'data.xp': newXp };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
@@ -911,7 +913,7 @@ export class RdDActor extends Actor {
async updateCompetenceXPSort(compName, compValue) {
let comp = this.getCompetence(compName);
if (comp) {
- compValue = compValue ?? 0;
+ if ( isNaN(compValue) || typeof(compValue) != 'number') compValue = 0;
const update = { _id: comp.id, 'data.xp_sort': compValue };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
this.updateExperienceLog("XP Sort", compValue, "XP modifié en sort de " + compName);
@@ -3545,8 +3547,9 @@ export class RdDActor extends Actor {
return;
}
}
- if (vendeur) {
- let itemVenduData = Misc.data(vendeur.getObjet(itemId));
+ const itemVendu = vendeur?.getObjet(itemId);
+ if (itemVendu) {
+ let itemVenduData = Misc.data(itemVendu);
if ("quantite" in itemVenduData.data ? itemVenduData.data.quantite < achat.quantiteTotal : achat.nombreLots != 1) {
await acheteur?.ajouterDeniers(coutDeniers);
ui.notifications.warn(`Le vendeur n'a plus assez de ${vente.item.name} !`);
@@ -3585,7 +3588,9 @@ export class RdDActor extends Actor {
ChatUtility.removeChatMessageId(chatMessageIdVente);
}
else {
+ vente["properties"] = new RdDItem(vente.item).getProprietes();
vente.quantiteNbLots -= achat.nombreLots;
+ vente.jsondata = JSON.stringify(vente.item);
messageVente.update({ content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente) });
messageVente.render(true);
}
diff --git a/module/item.js b/module/item.js
index 26b0fb7e..870f0328 100644
--- a/module/item.js
+++ b/module/item.js
@@ -215,7 +215,7 @@ export class RdDItem extends Item {
}
async _onProposerVente(venteData) {
- venteData["properties"] = this[`_${venteData.item.type}ChatData`]();
+ venteData["properties"] = this.getProprietes();
if (venteData.isOwned) {
if (venteData.quantiteNbLots * venteData.tailleLot > venteData.quantiteMax) {
ui.notifications.warn(`Vous avez ${venteData.quantiteMax} ${venteData.item.name}, ce n'est pas suffisant pour vendre ${venteData.quantiteNbLots} de ${venteData.tailleLot}`)
@@ -229,11 +229,15 @@ export class RdDItem extends Item {
ChatMessage.create(RdDUtility.chatDataSetup(html));
}
+ getProprietes() {
+ return this[`_${Misc.data(this).type}ChatData`]();
+ }
+
/* -------------------------------------------- */
async postItem() {
console.log(this);
let chatData = duplicate(Misc.data(this));
- const properties = this[`_${chatData.type}ChatData`]();
+ const properties = this.getProprietes();
chatData["properties"] = properties
if (this.actor) {
chatData.actor = { id: this.actor.id };
diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js
index 52c6f7ca..0e4b3f48 100644
--- a/module/rdd-calendrier.js
+++ b/module/rdd-calendrier.js
@@ -187,20 +187,18 @@ export class RdDCalendrier extends Application {
async rebuildListeNombreAstral() {
if (game.user.isGM) {
let jourCourant = this.getCurrentDayIndex();
- let jourFin = jourCourant + 12;
let newList = [];
- for (const na of this.listeNombreAstral) {
- let index = na?.index;
- if (index && index >= jourCourant && index < jourFin) {
- newList[index - jourCourant] = na;
- }
- }
for (let i = 0; i < 12; i++) {
- if (newList[i] == undefined) {
- newList[i] = await this.ajouterNombreAstral(jourCourant + i);
+ let dayIndex = jourCourant + i;
+ let na = this.listeNombreAstral.find( n => n.index == dayIndex);
+ if ( na ) {
+ newList[i] = duplicate(na);
+ } else {
+ newList[i] = await this.ajouterNombreAstral(dayIndex);
}
}
+ console.log("SAVE list", newList, jourCourant);
this.listeNombreAstral = newList;
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
}
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index f41c37ad..4daa2008 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -285,7 +285,29 @@ export class RdDUtility {
});
d.render(true);
}
-
+
+ /* -------------------------------------------- */
+ static async selectTypeOeuvre( actorSheet) {
+ let typeObjets = RdDItem.getTypesOeuvres();
+ let options = `Selectionnez le type d'oeuvre';
+ let d = new Dialog({
+ title: "Créer un équipement",
+ content: options,
+ buttons: {
+ one: {
+ icon: '',
+ label: "Créer l'objet",
+ callback: () => this.creerObjet(actorSheet)
+ }
+ }
+ });
+ d.render(true);
+ }
+
/* -------------------------------------------- */
static buildListOptions(min, max) {
let options = ""
diff --git a/system.json b/system.json
index c2e1b1ff..bdffdc55 100644
--- a/system.json
+++ b/system.json
@@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
- "version": "1.4.26",
+ "version": "1.4.28",
"manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "0.8.99",