diff --git a/changelog.md b/changelog.md
index 04facd2a..34eb5cf8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,10 @@
# 11.2
+## 11.2.22 - Le futur d'Akarlikarlikar
+- correction de la vente par le tchat: seul le premier acheteur pouvait acheter
+
+### Support V12
+- adaptation fenêtre de recherche
+
## 11.2.21 - Le questionnement d'Akarlikarlikar
- Une confirmation spécifique est demandée pour monter dans les terres médianes en cas de rencontre en attente
- L'expérience en caractéristique sur les jets de chance et rêve actuels est mise dans la caractéristique correspondante
diff --git a/module/achat-vente/chat-vente.js b/module/achat-vente/chat-vente.js
new file mode 100644
index 00000000..76d69d9f
--- /dev/null
+++ b/module/achat-vente/chat-vente.js
@@ -0,0 +1,70 @@
+import { SYSTEM_RDD } from "../constants.js";
+import { RdDUtility } from "../rdd-utility.js";
+
+const DETAIL_VENTE = 'detailVente';
+const NB_LOTS = 'nbLotss';
+
+export class ChatVente {
+
+ static getDetailVente(chatMessageId) {
+ const chatMessage = game.messages.get(chatMessageId)
+ if (!chatMessage) {
+ return undefined;
+ }
+ const nbLots = chatMessage.getFlag(SYSTEM_RDD, NB_LOTS)
+ const detail = foundry.utils.duplicate(chatMessage.getFlag(SYSTEM_RDD, DETAIL_VENTE))
+ if (!detail.item) {
+ ui.notifications.warn("Impossible d'acheter: informations sur l'objet manquantes")
+ return undefined;
+ }
+
+ const vendeur = detail.vendeurId ? game.actors.get(detail.vendeurId) : undefined;
+ return foundry.utils.mergeObject(detail,
+ {
+ alias: vendeur?.name ?? game.user.name,
+ vendeur,
+ nbLots: nbLots,
+ chatMessageIdVente: chatMessageId
+ })
+ }
+
+ static getDetailAchatVente(chatMessageId) {
+ const acheteur = RdDUtility.getSelectedActor()
+ const detail = ChatVente.getDetailVente(chatMessageId)
+ if (!acheteur && !detail.vendeur) {
+ ui.notifications.info("Pas d'acheteur ni de vendeur, aucun changement");
+ return undefined;
+ }
+ return foundry.utils.mergeObject(detail, { acheteur })
+ }
+
+
+ static async setDetailAchatVente(chatMessage, vente) {
+ await chatMessage?.setFlag(SYSTEM_RDD, NB_LOTS, vente.nbLots)
+ await chatMessage?.setFlag(SYSTEM_RDD, DETAIL_VENTE, {
+ item: vente.item,
+ properties: vente.item.getProprietes(),
+ vendeurId: vente.vendeurId,
+ tailleLot: vente.tailleLot,
+ quantiteIllimite: vente.quantiteIllimite,
+ prixLot: vente.prixLot
+ })
+ }
+
+ static async diminuerQuantite(chatMessageId, quantite) {
+ const chatMessage = game.messages.get(chatMessageId)
+ const vente = ChatVente.getDetailVente(chatMessageId)
+ vente.nbLots = Math.max(0, vente.nbLots - quantite)
+ await chatMessage?.setFlag(SYSTEM_RDD, NB_LOTS, vente.nbLots)
+
+ const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente);
+ chatMessage.update({ content: html });
+ chatMessage.render(true);
+ }
+
+ static async displayAchatVente(venteData) {
+ const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', venteData);
+ const chatMessage = await ChatMessage.create(RdDUtility.chatDataSetup(html))
+ await ChatVente.setDetailAchatVente(chatMessage, venteData)
+ }
+}
\ No newline at end of file
diff --git a/module/dialog-item-achat.js b/module/achat-vente/dialog-item-achat.js
similarity index 65%
rename from module/dialog-item-achat.js
rename to module/achat-vente/dialog-item-achat.js
index 25e591c0..3e1814ea 100644
--- a/module/dialog-item-achat.js
+++ b/module/achat-vente/dialog-item-achat.js
@@ -1,35 +1,13 @@
-import { Misc } from "./misc.js";
-import { RdDUtility } from "./rdd-utility.js";
+import { Misc } from "../misc.js";
+import { RdDUtility } from "../rdd-utility.js";
+import { ChatVente } from "./chat-vente.js";
export class DialogItemAchat extends Dialog {
static preparerAchat(chatButton) {
- const vendeurId = chatButton.attributes['data-vendeurId']?.value;
- const vendeur = vendeurId ? game.actors.get(vendeurId) : undefined;
- const acheteur = RdDUtility.getSelectedActor();
- const json = chatButton.attributes['data-jsondata']?.value;
- if (!acheteur && !vendeur) {
- ui.notifications.info("Pas d'acheteur ni de vendeur, aucun changement");
- return undefined;
- }
- if (!json) {
- ui.notifications.warn("Impossible d'acheter: informations sur l'objet manquantes")
- return undefined;
- }
-
- return {
- item: JSON.parse(json),
- vendeur,
- acheteur,
- nbLots: parseInt(chatButton.attributes['data-quantiteNbLots']?.value),
- tailleLot: parseInt(chatButton.attributes['data-tailleLot']?.value ?? 1),
- prixLot: Number(chatButton.attributes['data-prixLot']?.value ?? 0),
- quantiteIllimite: chatButton.attributes['data-quantiteIllimite']?.value == 'true',
- chatMessageIdVente: RdDUtility.findChatMessageId(chatButton),
- };
+ return ChatVente.getDetailAchatVente(RdDUtility.findChatMessageId(chatButton))
}
-
static async onAcheter({ item, vendeur, acheteur, tailleLot, prixLot, nbLots, quantiteIllimite, chatMessageIdVente }) {
const venteData = {
item,
@@ -38,17 +16,21 @@ export class DialogItemAchat extends Dialog {
acheteur,
tailleLot,
quantiteIllimite,
- quantiteNbLots: nbLots,
+ nbLots,
choix: { seForcer: false, supprimerSiZero: true },
prixLot,
isVente: prixLot > 0,
isConsommable: item.type == 'nourritureboisson' && acheteur?.isPersonnage(),
chatMessageIdVente
- };
+ }
+ if (venteData.vendeur?.id == venteData.acheteur?.id) {
+ ui.notifications.info("Inutile de se vendre à soi-même")
+ return
+ }
- DialogItemAchat.changeNombreLots(venteData, 1);
- const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-achat.html`, venteData);
- new DialogItemAchat(html, venteData).render(true);
+ DialogItemAchat.changeNombreLots(venteData, 1)
+ const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-achat.html`, venteData)
+ new DialogItemAchat(html, venteData).render(true)
}
static changeNombreLots(venteData, nombreLots) {
@@ -116,18 +98,18 @@ export class DialogItemAchat extends Dialog {
this.venteData.choix.seForcer = event.currentTarget.checked;
}
- setNombreLots(nombreLots) {
+ setNombreLots(nbLots) {
if (!this.venteData.quantiteIllimite) {
- if (!this.venteData.quantiteIllimite && nombreLots > this.venteData.quantiteNbLots) {
- ui.notifications.warn(`Seulement ${this.venteData.quantiteNbLots} lots disponibles, vous ne pouvez pas en prendre ${nombreLots}`)
+ if (!this.venteData.quantiteIllimite && nbLots > this.venteData.nbLots) {
+ ui.notifications.warn(`Seulement ${this.venteData.nbLots} lots disponibles, vous ne pouvez pas en prendre ${nbLots}`)
}
- nombreLots = Math.min(nombreLots, this.venteData.quantiteNbLots);
+ nbLots = Math.min(nbLots, this.venteData.nbLots);
}
- DialogItemAchat.changeNombreLots(this.venteData, nombreLots);
+ DialogItemAchat.changeNombreLots(this.venteData, nbLots);
- this.html.find(".nombreLots").val(nombreLots);
+ this.html.find(".nombreLots").val(nbLots);
this.html.find(".prixTotal").text(this.venteData.prixTotal);
this.html.find("span.total-sust").text(this.venteData.totalSust);
this.html.find("span.total-desaltere").text(this.venteData.totalDesaltere);
diff --git a/module/dialog-item-vente.js b/module/achat-vente/dialog-item-vente.js
similarity index 61%
rename from module/dialog-item-vente.js
rename to module/achat-vente/dialog-item-vente.js
index d871f7c1..07b1bad2 100644
--- a/module/dialog-item-vente.js
+++ b/module/achat-vente/dialog-item-vente.js
@@ -1,29 +1,30 @@
-import { HtmlUtility } from "./html-utility.js";
+import { HtmlUtility } from "../html-utility.js";
+import { RdDUtility } from "../rdd-utility.js";
+import { ChatVente } from "./chat-vente.js";
export class DialogItemVente extends Dialog {
- static async display({ item, callback, quantiteMax = undefined }) {
+ static async display({ item, quantiteMax = undefined }) {
const quantite = quantiteMax ?? item.getQuantite() ?? 1;
- const isOwned = item.parent;
const venteData = {
item: item,
alias: item.actor?.name ?? game.user.name,
- vendeurId: item.actor?.id,
+ vendeurId: item.actor.id,
prixOrigine: item.calculerPrixCommercant(),
prixUnitaire: item.calculerPrixCommercant(),
prixLot: item.calculerPrixCommercant(),
tailleLot: 1,
- quantiteNbLots: quantite,
- quantiteMaxLots: quantite,
+ nbLots: quantite,
+ maxLots: quantite,
quantiteMax: quantite,
- quantiteIllimite: item.isItemCommerce() ? quantiteMax == undefined : !isOwned,
- isOwned: isOwned,
- };
+ quantiteIllimite: item.isItemCommerce() ? quantiteMax == undefined : !item.parent,
+ isOwned: item.parent,
+ }
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-vente.html`, venteData);
- return new DialogItemVente(venteData, html, callback).render(true);
+ return new DialogItemVente(venteData, html).render(true);
}
- constructor(venteData, html, callback) {
+ constructor(venteData, html) {
let options = { classes: ["dialogvente"], width: 400, height: 'fit-content', 'z-index': 99999 };
let conf = {
@@ -34,7 +35,6 @@ export class DialogItemVente extends Dialog {
};
super(conf, options);
- this.callback = callback;
this.venteData = venteData;
}
@@ -43,7 +43,7 @@ export class DialogItemVente extends Dialog {
this.html = html;
this.html.find(".tailleLot").change(event => this.setTailleLot(Number(event.currentTarget.value)));
- this.html.find(".quantiteNbLots").change(event => this.setNbLots(Number(event.currentTarget.value)));
+ this.html.find(".nbLots").change(event => this.setNbLots(Number(event.currentTarget.value)));
this.html.find(".quantiteIllimite").change(event => this.setQuantiteIllimite(event.currentTarget.checked));
this.html.find(".prixLot").change(event => this.setPrixLot(Number(event.currentTarget.value)));
@@ -52,7 +52,15 @@ export class DialogItemVente extends Dialog {
async onProposer(it) {
this.updateVente(this.getChoixVente());
- this.callback(this.venteData);
+
+ this.venteData["properties"] = this.venteData.item.getProprietes();
+ if (this.venteData.isOwned) {
+ if (this.venteData.nbLots * this.venteData.tailleLot > this.venteData.quantiteMax) {
+ ui.notifications.warn(`Vous avez ${this.venteData.quantiteMax} ${this.venteData.item.name}, ce n'est pas suffisant pour vendre ${this.venteData.nbLots} de ${this.venteData.tailleLot}`)
+ return;
+ }
+ }
+ await ChatVente.displayAchatVente(this.venteData)
}
updateVente(update) {
@@ -61,7 +69,7 @@ export class DialogItemVente extends Dialog {
getChoixVente() {
return {
- quantiteNbLots: Number(this.html.find(".quantiteNbLots").val()),
+ nbLots: Number(this.html.find(".nbLots").val()),
tailleLot: Number(this.html.find(".tailleLot").val()),
quantiteIllimite: this.html.find(".quantiteIllimite").is(':checked'),
prixLot: Number(this.html.find(".prixLot").val())
@@ -77,26 +85,26 @@ export class DialogItemVente extends Dialog {
const maxLots = Math.floor(this.venteData.quantiteMax / tailleLot);
this.updateVente({
tailleLot,
- quantiteNbLots: Math.min(maxLots, this.venteData.quantiteNbLots),
- quantiteMaxLots: maxLots,
+ nbLots: Math.min(maxLots, this.venteData.nbLots),
+ maxLots: maxLots,
prixLot: (tailleLot * this.venteData.prixOrigine).toFixed(2)
});
this.html.find(".prixLot").val(this.venteData.prixLot);
- this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
- this.html.find(".quantiteNbLots").attr("max", this.venteData.quantiteMaxLots)
+ this.html.find(".nbLots").val(this.venteData.nbLots);
+ this.html.find(".nbLots").attr("max", this.venteData.maxLots)
}
setNbLots(nbLots) {
this.updateVente({
- quantiteNbLots: this.venteData.isOwned ? Math.max(0, Math.min(nbLots, this.venteData.quantiteMaxLots)) : nbLots
+ nbLots: this.venteData.isOwned ? Math.max(0, Math.min(nbLots, this.venteData.maxLots)) : nbLots
})
- this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
+ this.html.find(".nbLots").val(this.venteData.nbLots);
}
setQuantiteIllimite(checked) {
this.updateVente({ quantiteIllimite: checked })
this.html.find(".label-quantiteIllimite").text(this.venteData.quantiteIllimite ? "Illimités" : "disponibles");
- HtmlUtility.showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite)
+ HtmlUtility.showControlWhen(this.html.find(".nbLots"), !this.venteData.quantiteIllimite)
}
}
\ No newline at end of file
diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 8b042f4c..4ff63dd7 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -32,21 +32,20 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
width: 550,
showCompNiveauBase: false,
vueArchetype: false,
- });
+ }, { inplace: false });
}
/* -------------------------------------------- */
async getData() {
let formData = await super.getData();
- foundry.utils.mergeObject(formData,
- {
- editable: this.isEditable,
- cssClass: this.isEditable ? "editable" : "locked",
- limited: this.actor.limited,
- owner: this.actor.isOwner,
- biographie: await TextEditor.enrichHTML(this.actor.system.biographie, { async: true }),
- notes: await TextEditor.enrichHTML(this.actor.system.notes, { async: true }),
- });
+ foundry.utils.mergeObject(formData, {
+ editable: this.isEditable,
+ cssClass: this.isEditable ? "editable" : "locked",
+ limited: this.actor.limited,
+ owner: this.actor.isOwner,
+ biographie: await TextEditor.enrichHTML(this.actor.system.biographie, { async: true }),
+ notes: await TextEditor.enrichHTML(this.actor.system.notes, { async: true }),
+ });
foundry.utils.mergeObject(formData.calc, {
surenc: this.actor.computeMalusSurEncombrement(),
surprise: RdDBonus.find(this.actor.getSurprise(false)).descr,
@@ -211,7 +210,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
const key = Number(li.data("key") ?? -1);
await this.actor.deleteExperienceLog(0, key + 1);
});
- // Boutons spéciaux MJs
+ // Boutons spéciaux MJs
this.html.find('.forcer-tmr-aleatoire').click(async event => this.actor.reinsertionAleatoire("Action MJ"))
this.html.find('.afficher-tmr').click(async event => this.actor.changeTMRVisible())
}
diff --git a/module/actor.js b/module/actor.js
index 653d6e20..bbb8f125 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -2346,7 +2346,7 @@ export class RdDActor extends RdDBaseActorSang {
async _xpCaracDerivee(xpData) {
const caracs = RdDActor._getComposantsCaracDerivee(xpData.caracName)
- .map(c => foundry.utils.mergeObject(this.system.carac[c], { isMax: this.isCaracMax(c) }))
+ .map(c => foundry.utils.mergeObject(this.system.carac[c], { isMax: this.isCaracMax(c) }, { inplace: false }))
switch (caracs.filter(it => !it.isMax).length) {
case 0:
xpData.caracRepartitionManuelle = true;
diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js
index 38155403..840e6adf 100644
--- a/module/actor/base-actor-reve.js
+++ b/module/actor/base-actor-reve.js
@@ -286,12 +286,12 @@ export class RdDBaseActorReve extends RdDBaseActor {
getCarac() {
// TODO: le niveau d'une entité de cauchemar devrait être exclu...
- const carac = foundry.utils.mergeObject(foundry.utils.duplicate(this.system.carac),
+ return foundry.utils.mergeObject(this.system.carac,
{
'reve-actuel': this.getCaracReveActuel(),
'chance-actuelle': this.getCaracChanceActuelle()
- });
- return carac;
+ },
+ { inplace: false })
}
/* -------------------------------------------- */
diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js
index fd428432..1df6c37d 100644
--- a/module/actor/base-actor-sheet.js
+++ b/module/actor/base-actor-sheet.js
@@ -20,7 +20,7 @@ export class RdDBaseActorSheet extends ActorSheet {
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: undefined }],
vueDetaillee: false
- });
+ }, { inplace: false })
}
/* -------------------------------------------- */
diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js
index a9913159..224b253a 100644
--- a/module/actor/base-actor.js
+++ b/module/actor/base-actor.js
@@ -1,3 +1,4 @@
+import { ChatVente } from "../achat-vente/chat-vente.js";
import { ChatUtility } from "../chat-utility.js";
import { SYSTEM_SOCKET_ID } from "../constants.js";
import { Grammar } from "../grammar.js";
@@ -360,12 +361,9 @@ export class RdDBaseActor extends Actor {
ChatUtility.notifyUser(achat.userId, 'warn', `Vous n'avez pas assez d'argent pour payer ${Math.ceil(cout / 100)} sols !`);
return;
}
- await this.decrementerVente(vendeur, itemVendu, quantite, cout);
- if (acheteur) {
- await acheteur.depenserSols(cout);
- const createdItemId = await acheteur.creerQuantiteItem(itemVendu, quantite);
- await acheteur.consommerNourritureAchetee(achat, achat.vente, createdItemId);
- }
+ await vendeur?.vendre(itemVendu, quantite, cout);
+ await acheteur?.acheter(itemVendu, quantite, cout, achat)
+
if (cout > 0) {
RdDAudio.PlayContextAudio("argent");
}
@@ -379,24 +377,26 @@ export class RdDBaseActor extends Actor {
});
if (!achat.vente.quantiteIllimite) {
- if (achat.vente.quantiteNbLots <= achat.choix.nombreLots) {
+ if (achat.vente.nbLots <= achat.choix.nombreLots) {
ChatUtility.removeChatMessageId(achat.chatMessageIdVente);
}
else if (achat.chatMessageIdVente) {
- achat.vente.properties = itemVendu.getProprietes();
- achat.vente.quantiteNbLots -= achat.choix.nombreLots;
- achat.vente.jsondata = JSON.stringify(achat.vente.item);
- const messageVente = game.messages.get(achat.chatMessageIdVente);
- messageVente.update({ content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', achat.vente) });
- messageVente.render(true);
+ await ChatVente.diminuerQuantite(achat.chatMessageIdVente, achat.choix.nombreLots)
}
}
}
- async decrementerVente(vendeur, itemVendu, quantite, cout) {
- if (vendeur) {
- await vendeur.ajouterSols(cout);
- await vendeur.decrementerQuantiteItem(itemVendu, quantite);
+ async vendre(item, quantite, cout) {
+ await this.ajouterSols(cout);
+ await this.decrementerQuantiteItem(item, quantite);
+ }
+
+ async acheter(item, quantite, cout, achat) {
+ await this.depenserSols(cout)
+ const createdItemId = await this.creerQuantiteItem(item, quantite)
+ if (achat.choix.consommer && item.type == 'nourritureboisson' && createdItemId != undefined) {
+ achat.choix.doses = achat.choix.nombreLots;
+ await this.consommerNourritureboisson(createdItemId, achat.choix, achat.vente.actingUserId);
}
}
@@ -409,31 +409,28 @@ export class RdDBaseActor extends Actor {
return disponible == undefined || disponible >= quantiteDemande;
}
- async consommerNourritureAchetee(achat, vente, createdItemId) {
- if (achat.choix.consommer && vente.item.type == 'nourritureboisson' && createdItemId != undefined) {
- achat.choix.doses = achat.choix.nombreLots;
- await this.consommerNourritureboisson(createdItemId, achat.choix, vente.actingUserId);
- }
- }
-
+ async consommerNourritureboisson(itemId, choix, userId) { }
async decrementerQuantiteItem(item, quantite, options = { supprimerSiZero: true }) {
if (item.isService()) {
return;
}
+ const itemId = item.id;
let resteQuantite = (item.system.quantite ?? 1) - quantite;
if (resteQuantite <= 0) {
if (options.supprimerSiZero) {
await this.deleteEmbeddedDocuments("Item", [item.id]);
}
else {
- await this.updateEmbeddedDocuments("Item", [{ _id: item.id, 'system.quantite': 0 }]);
+ await this.updateEmbeddedDocuments("Item", [{ _id: itemId, 'system.quantite': 0 }]);
}
if (resteQuantite < 0) {
ui.notifications.warn(`La quantité de ${item.name} était insuffisante, l'objet a donc été supprimé`)
}
}
else if (resteQuantite > 0) {
+ const realItem = this.getItem(item.id)
+ realItem.update({ 'system.quantite': resteQuantite });
await this.updateEmbeddedDocuments("Item", [{ _id: item.id, 'system.quantite': resteQuantite }]);
}
}
@@ -445,7 +442,7 @@ export class RdDBaseActor extends Actor {
type: item.type,
img: item.img,
name: item.name,
- system: foundry.utils.mergeObject(item.system, { quantite: isItemEmpilable ? quantite : undefined })
+ system: foundry.utils.mergeObject(item.system, { quantite: isItemEmpilable ? quantite : undefined }, { inplace: false })
};
const newItems = isItemEmpilable ? [baseItem] : Array.from({ length: quantite }, (_, i) => baseItem);
const items = await this.createEmbeddedDocuments("Item", newItems);
diff --git a/module/actor/commerce-sheet.js b/module/actor/commerce-sheet.js
index 1fb84fc3..2aed0d6b 100644
--- a/module/actor/commerce-sheet.js
+++ b/module/actor/commerce-sheet.js
@@ -1,4 +1,4 @@
-import { DialogItemAchat } from "../dialog-item-achat.js";
+import { DialogItemAchat } from "../achat-vente/dialog-item-achat.js";
import { RdDItem } from "../item.js";
import { RdDUtility } from "../rdd-utility.js";
import { RdDBaseActorSheet } from "./base-actor-sheet.js";
@@ -15,7 +15,7 @@ export class RdDCommerceSheet extends RdDBaseActorSheet {
template: "systems/foundryvtt-reve-de-dragon/templates/actor/commerce-actor-sheet.html",
width: 600, height: 720,
tabs: []
- });
+ }, { inplace: false })
}
get title() {
if (this.actor.token && this.actor.token != this.actor.prototypeToken) {
diff --git a/module/actor/commerce.js b/module/actor/commerce.js
index 9f6cd289..ed075a6b 100644
--- a/module/actor/commerce.js
+++ b/module/actor/commerce.js
@@ -25,8 +25,7 @@ export class RdDCommerce extends RdDBaseActor {
}
await super.depenserSols(cout)
}
-
- async consommerNourritureAchetee(achat, vente, createdItemId) {
+ async consommerNourritureboisson(itemId, choix, userId) {
// ne pas consommer pour un commerce
}
diff --git a/module/actor/creature-sheet.js b/module/actor/creature-sheet.js
index 6e9b865c..80ddb9a6 100644
--- a/module/actor/creature-sheet.js
+++ b/module/actor/creature-sheet.js
@@ -12,7 +12,7 @@ export class RdDCreatureSheet extends RdDBaseActorSangSheet {
return foundry.utils.mergeObject(RdDBaseActorSangSheet.defaultOptions, {
template: "systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html",
width: 640, height: 720
- });
+ }, { inplace: false })
}
/* -------------------------------------------- */
diff --git a/module/actor/entite-sheet.js b/module/actor/entite-sheet.js
index 927b749c..354f4429 100644
--- a/module/actor/entite-sheet.js
+++ b/module/actor/entite-sheet.js
@@ -9,7 +9,7 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet {
return foundry.utils.mergeObject(RdDBaseActorReveSheet.defaultOptions, {
template: "systems/foundryvtt-reve-de-dragon/templates/actor-entite-sheet.html",
width: 640, height: 720,
- });
+ }, { inplace: false })
}
async getData() {
diff --git a/module/actor/vehicule-sheet.js b/module/actor/vehicule-sheet.js
index e63d9f2b..fb38f1b6 100644
--- a/module/actor/vehicule-sheet.js
+++ b/module/actor/vehicule-sheet.js
@@ -9,7 +9,7 @@ export class RdDActorVehiculeSheet extends RdDBaseActorSheet {
return foundry.utils.mergeObject(RdDBaseActorSheet.defaultOptions, {
template: "systems/foundryvtt-reve-de-dragon/templates/actor-vehicule-sheet.html",
width: 640, height: 720,
- });
+ }, { inplace: false })
}
/* -------------------------------------------- */
diff --git a/module/item-competence.js b/module/item-competence.js
index dce1f30c..b25ea07f 100644
--- a/module/item-competence.js
+++ b/module/item-competence.js
@@ -199,7 +199,7 @@ export class RdDItemCompetence extends Item {
if (idOrName == undefined || idOrName == "") {
return RdDItemCompetence.sansCompetence();
}
- options = foundry.utils.mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence' }, { overwrite: false });
+ options = foundry.utils.mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence' }, { overwrite: false, inplace: false });
return RdDItemCompetence.findFirstItem(list, idOrName, options);
}
diff --git a/module/item-competencecreature.js b/module/item-competencecreature.js
index e541b458..d16f8aba 100644
--- a/module/item-competencecreature.js
+++ b/module/item-competencecreature.js
@@ -33,8 +33,7 @@ export class RdDItemCompetenceCreature extends Item {
if (categorieAttaque != undefined) {
// si c'est un Item compétence: cloner pour ne pas modifier la compétence
let arme = item.clone();
- foundry.utils.mergeObject(arme,
- {
+ return foundry.utils.mergeObject(arme, {
action: item.isCompetencePossession() ? 'possession' : 'attaque',
system: {
competence: arme.name,
@@ -48,8 +47,7 @@ export class RdDItemCompetenceCreature extends Item {
force: 0,
rapide: true,
}
- });
- return arme;
+ }, { inplace: false });
}
return undefined;
}
diff --git a/module/item-sheet.js b/module/item-sheet.js
index 48bf5fa6..5b32caae 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -44,7 +44,7 @@ export class RdDItemSheet extends ItemSheet {
template: RdDItemSheet.defaultTemplate(RdDItemSheet.ITEM_TYPE),
width: 550,
height: 550
- });
+ }, { inplace: false });
}
/* -------------------------------------------- */
diff --git a/module/item.js b/module/item.js
index e52970e0..a97c050c 100644
--- a/module/item.js
+++ b/module/item.js
@@ -1,4 +1,4 @@
-import { DialogItemVente } from "./dialog-item-vente.js";
+import { DialogItemVente } from "./achat-vente/dialog-item-vente.js";
import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js";
import { RdDHerbes } from "./rdd-herbes.js";
@@ -233,7 +233,7 @@ export class RdDItem extends Item {
}
isCompetenceArme() {
- return this.isCompetence() && [ 'melee','tir', 'lancer'].includes(this.system.categorie)
+ return this.isCompetence() && ['melee', 'tir', 'lancer'].includes(this.system.categorie)
}
isCompetencePossession() { return TYPES.competencecreature == this.type && this.system.categorie == "possession" }
@@ -538,7 +538,7 @@ export class RdDItem extends Item {
_id: this.id,
'system.quantite': this.system.quantite * sust,
'system.encombrement': Misc.keepDecimals(this.system.encombrement / sust, 2),
- 'system.cout': Misc.keepDecimals(this.system.cout / sust, 2),
+ 'system.cout': Math.max(0, Misc.keepDecimals(this.system.cout / sust, 2)),
'system.sust': 1
}])
}
@@ -621,23 +621,7 @@ export class RdDItem extends Item {
ui.notifications.warn(`Votre ${this.name} n'est pas vide, pas possible de le proposer`);
return;
}
- await DialogItemVente.display({
- item: this,
- quantiteMax,
- callback: async (vente) => {
- vente["properties"] = this.getProprietes();
- if (vente.isOwned) {
- if (vente.quantiteNbLots * vente.tailleLot > vente.quantiteMax) {
- ui.notifications.warn(`Vous avez ${vente.quantiteMax} ${vente.item.name}, ce n'est pas suffisant pour vendre ${vente.quantiteNbLots} de ${vente.tailleLot}`)
- return;
- }
- }
- vente.jsondata = JSON.stringify(vente.item);
-
- let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente);
- ChatMessage.create(RdDUtility.chatDataSetup(html));
- }
- });
+ await DialogItemVente.display({ item: this, quantiteMax })
}
/* -------------------------------------------- */
diff --git a/module/item/blessure.js b/module/item/blessure.js
index f35a013e..04db4238 100644
--- a/module/item/blessure.js
+++ b/module/item/blessure.js
@@ -39,7 +39,7 @@ export class RdDItemBlessure extends RdDItem {
ui.notifications.warn(`Pas de tâche de soins pour une blessure ${gravite}`)
return undefined;
}
- return foundry.utils.mergeObject(foundry.utils.duplicate(BASE_TACHE_SOIN_BLESSURE), tache)
+ return foundry.utils.mergeObject(BASE_TACHE_SOIN_BLESSURE, tache, { inplace: false })
}
static async applyFullBlessure(actor, gravite) {
@@ -106,12 +106,12 @@ export class RdDItemBlessure extends RdDItem {
}
async setSoinsBlessure(systemUpdate = {}) {
- systemUpdate = foundry.utils.mergeObject(systemUpdate, this.system, { overwrite: false }),
- systemUpdate.soinscomplets.done = systemUpdate.premierssoins.done && systemUpdate.soinscomplets.done
+ systemUpdate = foundry.utils.mergeObject(systemUpdate, this.system, { overwrite: false })
+ systemUpdate.soinscomplets.done = systemUpdate.premierssoins.done && systemUpdate.soinscomplets.done
await this.update({
img: this.getImgSoins(systemUpdate.gravite, systemUpdate.soinscomplets.done),
system: systemUpdate
- });
+ })
}
async recuperationBlessure({ actor, timestamp, message, isMaladeEmpoisonne, blessures }) {
diff --git a/module/item/sheet-base-inventaire.js b/module/item/sheet-base-inventaire.js
index 4df15a05..014bc4ea 100644
--- a/module/item/sheet-base-inventaire.js
+++ b/module/item/sheet-base-inventaire.js
@@ -10,7 +10,7 @@ export class RdDItemInventaireSheet extends RdDItemSheet {
static get defaultOptions() {
return foundry.utils.mergeObject(RdDItemSheet.defaultOptions, {
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "informations" }]
- });
+ }, { inplace: false })
}
setPosition(options = {}) {
@@ -23,9 +23,10 @@ export class RdDItemInventaireSheet extends RdDItemSheet {
async getData() {
const formData = await super.getData();
- return foundry.utils.mergeObject(formData, {
+ foundry.utils.mergeObject(formData, {
milieux: await game.system.rdd.environnement.autresMilieux(this.item)
- });
+ })
+ return formData
}
activateListeners(html) {
diff --git a/module/item/sheet-rencontre.js b/module/item/sheet-rencontre.js
index 58a93a9c..bfd55b7a 100644
--- a/module/item/sheet-rencontre.js
+++ b/module/item/sheet-rencontre.js
@@ -8,7 +8,7 @@ export class RdDRencontreItemSheet extends RdDItemSheet {
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }]
- });
+ }, { inplace: false })
}
/* -------------------------------------------- */
@@ -35,7 +35,7 @@ export class RdDRencontreItemSheet extends RdDItemSheet {
select: RdDRencontre.mapEffets(this.item.system.echec.effets)
}
}
- });
+ })
return formData;
}
diff --git a/module/rdd-combat.js b/module/rdd-combat.js
index 444dd378..8c54ba32 100644
--- a/module/rdd-combat.js
+++ b/module/rdd-combat.js
@@ -128,21 +128,17 @@ export class RdDCombatManager extends Combat {
// Send a chat message
let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode");
- let messageData = foundry.utils.mergeObject(
- {
- speaker: {
- scene: canvas.scene._id,
- actor: combatant.actor?._id,
- token: combatant.token._id,
- alias: combatant.token.name,
- sound: CONFIG.sounds.dice,
- },
- flavor: `${combatant.token.name} a fait son jet d'Initiative (${messageOptions.initInfo})
-
- `,
+ let messageData = foundry.utils.mergeObject({
+ speaker: {
+ scene: canvas.scene._id,
+ actor: combatant.actor?._id,
+ token: combatant.token._id,
+ alias: combatant.token.name,
+ sound: CONFIG.sounds.dice,
},
- messageOptions
- );
+ flavor: `${combatant.token.name} a fait son jet d'Initiative (${messageOptions.initInfo})
`,
+ },
+ messageOptions);
roll.toMessage(messageData, { rollMode, create: true });
RdDCombatManager.processPremierRoundInit();
diff --git a/module/rdd-confirm.js b/module/rdd-confirm.js
index 7e701432..85d52813 100644
--- a/module/rdd-confirm.js
+++ b/module/rdd-confirm.js
@@ -12,7 +12,7 @@ export class RdDConfirm {
buttons = foundry.utils.mergeObject(RdDConfirm._createButtonActionSave(options), buttons);
}
if (autresActions) {
- buttons = foundry.utils.mergeObject(autresActions, buttons);
+ buttons = foundry.utils.mergeObject(autresActions, buttons, { inplace: false });
}
const dialogDetails = {
title: options.title,
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index c7032a42..028ab7a1 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -4,7 +4,7 @@ import { RdDCombat } from "./rdd-combat.js";
import { Misc } from "./misc.js";
import { Grammar } from "./grammar.js";
import { TMRUtility } from "./tmr-utility.js";
-import { DialogItemAchat } from "./dialog-item-achat.js";
+import { DialogItemAchat } from "./achat-vente/dialog-item-achat.js";
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
import { RdDDice } from "./rdd-dice.js";
import { RdDItem } from "./item.js";
diff --git a/module/settings/regles-optionnelles.js b/module/settings/regles-optionnelles.js
index 2d2f36bd..95ca2a2c 100644
--- a/module/settings/regles-optionnelles.js
+++ b/module/settings/regles-optionnelles.js
@@ -71,8 +71,7 @@ export class ReglesOptionnelles extends FormApplication {
}
static get defaultOptions() {
- const options = super.defaultOptions;
- foundry.utils.mergeObject(options, {
+ return foundry.utils.mergeObject(super.defaultOptions, {
id: "regles-optionnelles",
template: "systems/foundryvtt-reve-de-dragon/templates/settings/regles-optionnelles.html",
height: 650,
@@ -80,8 +79,7 @@ export class ReglesOptionnelles extends FormApplication {
minimizable: false,
closeOnSubmit: true,
title: "Règles optionnelles"
- });
- return options;
+ }, { inplace: false })
}
getData() {
diff --git a/module/settings/system-compendiums.js b/module/settings/system-compendiums.js
index f0ce4b9e..6281bab5 100644
--- a/module/settings/system-compendiums.js
+++ b/module/settings/system-compendiums.js
@@ -152,7 +152,7 @@ export class SystemCompendiums extends FormApplication {
getData() {
const systemCompendiums = Object.values(CONFIGURABLE_COMPENDIUMS)
- .map(it => foundry.utils.mergeObject(it, { value: SystemCompendiums.getCompendium(it.compendium) }));
+ .map(it => foundry.utils.mergeObject(it, { value: SystemCompendiums.getCompendium(it.compendium) }, { inplace: false }))
const availableCompendiums = game.packs.map(pack => {
return {
name: pack.collection,
@@ -163,7 +163,7 @@ export class SystemCompendiums extends FormApplication {
return foundry.utils.mergeObject(super.getData(), {
systemCompendiums: systemCompendiums,
availableCompendiums: availableCompendiums
- });
+ }, { inplace: false })
}
activateListeners(html) {
diff --git a/module/sommeil/app-astrologie.js b/module/sommeil/app-astrologie.js
index eca4accb..0e33a748 100644
--- a/module/sommeil/app-astrologie.js
+++ b/module/sommeil/app-astrologie.js
@@ -25,7 +25,7 @@ export class AppAstrologie extends Application {
classes: ['calendar-astrologie'],
popOut: true,
resizable: false
- });
+ }, { inplace: false })
}
constructor(actor, options = {}) {
@@ -49,7 +49,7 @@ export class AppAstrologie extends Application {
signeNaissance: RdDTimestamp.definition(0)
}
})
- return this.appData;
+ return this.appData
}
getActorAstrologie() {
diff --git a/module/time/rdd-calendrier.js b/module/time/rdd-calendrier.js
index 0ff8022c..d5f4432d 100644
--- a/module/time/rdd-calendrier.js
+++ b/module/time/rdd-calendrier.js
@@ -43,7 +43,7 @@ export class RdDCalendrier extends Application {
resizable: false,
width: 'fit-content',
height: 'fit-content',
- });
+ }, { inplace: false })
}
constructor() {
diff --git a/module/tirage/fenetre-recherche-tirage.js b/module/tirage/fenetre-recherche-tirage.js
index be6a5293..932778d0 100644
--- a/module/tirage/fenetre-recherche-tirage.js
+++ b/module/tirage/fenetre-recherche-tirage.js
@@ -125,7 +125,7 @@ export class FenetreRechercheTirage extends Application {
popOut: true,
dragDrop: [{ dragSelector: "a.content-link" }],
resizable: true
- });
+ }, { inplace: false })
}
static async create() {
diff --git a/module/voyage/dialog-fatigue-voyage.js b/module/voyage/dialog-fatigue-voyage.js
index 343f267e..74a4b179 100644
--- a/module/voyage/dialog-fatigue-voyage.js
+++ b/module/voyage/dialog-fatigue-voyage.js
@@ -142,18 +142,19 @@ export class DialogFatigueVoyage extends Dialog {
it => this.$extractActor(this.html.find(it))
)
actors.filter(it => it.selected)
- .forEach(async it => {
+ .forEach(async it => {
const perteFatigue = fatigueBase + it.ajustement
ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(it.actor.name),
content: await renderTemplate(
- 'systems/foundryvtt-reve-de-dragon/templates/voyage/chat-fatigue_voyage.hbs', foundry.utils.mergeObject(it,
+ 'systems/foundryvtt-reve-de-dragon/templates/voyage/chat-fatigue_voyage.hbs',
+ foundry.utils.mergeObject(it,
{
parameters: this.parameters,
fatigueBase: fatigueBase,
perteFatigue: perteFatigue,
isVoyage: fatigueBase == this.parameters.nombreHeures * this.parameters.fatigueHoraire
- })
+ }, { inplace: false })
),
})
await it.actor.santeIncDec("fatigue", perteFatigue)
diff --git a/templates/chat-vente-item.html b/templates/chat-vente-item.html
index 90603356..a39562b1 100644
--- a/templates/chat-vente-item.html
+++ b/templates/chat-vente-item.html
@@ -1,3 +1,4 @@
+{{log 'chat-vente-item' this}}
{{#unless quantiteIllimite}}
- Lots disponibles: {{quantiteNbLots}}
+ Lots disponibles: {{nbLots}}
{{/unless}}
{{#if (gt tailleLot 1)}}
Lots de: {{tailleLot}}
@@ -22,15 +23,9 @@
{{numberFormat prixLot decimals=2 sign=false}} Sols
{{/if}}