forked from public/foundryvtt-reve-de-dragon
Montrer son équipement
On peut aussi le montrer sans le vendre
This commit is contained in:
@ -262,70 +262,6 @@ export class RdDItem extends Item {
|
||||
if (this.actor) {
|
||||
chatData.actor = { id: this.actor.id };
|
||||
}
|
||||
//Check if the posted item should have availability/pay buttons
|
||||
chatData.hasPrice = "cout" in chatData.data;
|
||||
chatData.data.cout_deniers = 0;
|
||||
|
||||
let dialogResult = [-1, -1]; // dialogResult[0] = quantité, dialogResult[1] = prix
|
||||
if (chatData.hasPrice) {
|
||||
chatData.data.cout_deniers = Math.floor(chatData.data.cout * 100);
|
||||
dialogResult = await new Promise((resolve, reject) => {
|
||||
new Dialog({
|
||||
content:
|
||||
`<p>Modifier la quantité?</p>
|
||||
<div class="form-group">
|
||||
<label> Quantité</label>
|
||||
<input name="quantity" type="text" value="1"/>
|
||||
</div>
|
||||
<p>Modifier la prix?</p>
|
||||
<div class="form-group">
|
||||
<label>Prix en Sols</label>
|
||||
<input name="price" type="text" value="${chatData.data.cout}"/>
|
||||
</div>
|
||||
`,
|
||||
title: "Quantité & Prix",
|
||||
buttons: {
|
||||
post: {
|
||||
label: "Soumettre",
|
||||
callback: (dlg) => {
|
||||
resolve([Number(dlg.find('[name="quantity"]').val()), Number(dlg.find('[name="price"]').val())])
|
||||
}
|
||||
},
|
||||
}
|
||||
}).render(true)
|
||||
})
|
||||
}
|
||||
|
||||
let quantiteEnvoi = this.isOwned ? Math.min(dialogResult[0], chatData.data.quantite) : dialogResult[0];
|
||||
const prixTotal = dialogResult[1];
|
||||
if (quantiteEnvoi > 0) {
|
||||
if (this.isOwned) {
|
||||
if (chatData.data.quantite == 0) {
|
||||
quantiteEnvoi = -1
|
||||
}
|
||||
else if (quantiteEnvoi > chatData.data.quantite) {
|
||||
quantiteEnvoi = chatData.data.quantite;
|
||||
ui.notifications.notify(`Impossible de poster plus que ce que vous avez. La quantité à été réduite à ${quantiteEnvoi}.`)
|
||||
}
|
||||
if (quantiteEnvoi > 0) {
|
||||
this.diminuerQuantite(quantiteEnvoi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (chatData.hasPrice) {
|
||||
if (quantiteEnvoi > 0)
|
||||
chatData.postQuantity = Number(quantiteEnvoi);
|
||||
if (prixTotal >= 0) {
|
||||
chatData.postPrice = prixTotal;
|
||||
chatData.data.cout_deniers = Math.floor(prixTotal * 100); // Mise à jour cout en deniers
|
||||
}
|
||||
chatData.finalPrice = Number(chatData.postPrice) * Number(chatData.postQuantity);
|
||||
chatData.data.cout_deniers_total = chatData.data.cout_deniers * Number(chatData.postQuantity);
|
||||
chatData.data.quantite = chatData.postQuantity;
|
||||
console.log("POST : ", chatData.finalPrice, chatData.data.cout_deniers_total, chatData.postQuantity);
|
||||
}
|
||||
|
||||
// JSON object for easy creation
|
||||
chatData.jsondata = JSON.stringify(
|
||||
{
|
||||
|
Reference in New Issue
Block a user