Montrer son équipement
On peut aussi le montrer sans le vendre
This commit is contained in:
parent
508d352b0b
commit
4aef9c0571
@ -188,6 +188,11 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
item?.proposerVente();
|
item?.proposerVente();
|
||||||
});
|
});
|
||||||
|
html.find('.item-montrer').click(async event => {
|
||||||
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
|
item?.postItem();
|
||||||
|
});
|
||||||
|
|
||||||
html.find('.item-action').click(async event => {
|
html.find('.item-action').click(async event => {
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
this.actor.actionItem(item);
|
this.actor.actionItem(item);
|
||||||
|
@ -34,18 +34,16 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
|
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
|
||||||
if ("cout" in Misc.templateData(this.object) && this.object.isVideOuNonConteneur()) {
|
if ("cout" in Misc.templateData(this.object) && this.object.isVideOuNonConteneur()) {
|
||||||
buttons.unshift({
|
buttons.unshift({
|
||||||
class: "post",
|
class: "vendre",
|
||||||
icon: "fas fa-comments-dollar",
|
icon: "fas fa-comments-dollar",
|
||||||
onclick: ev => this.item.proposerVente()
|
onclick: ev => this.item.proposerVente()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
buttons.unshift({
|
||||||
buttons.unshift({
|
class: "montrer",
|
||||||
class: "post",
|
icon: "fas fa-comment",
|
||||||
icon: "fas fa-comment",
|
onclick: ev => this.item.postItem()
|
||||||
onclick: ev => this.item.postItem()
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
return buttons
|
return buttons
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +200,10 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
item?.proposerVente();
|
item?.proposerVente();
|
||||||
});
|
});
|
||||||
|
html.find('.item-montrer').click(async event => {
|
||||||
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
|
item?.postItem();
|
||||||
|
});
|
||||||
html.find('.item-action').click(async event => {
|
html.find('.item-action').click(async event => {
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
this.actor.actionItem(item, async () => itemSheetDialog.render(true));
|
this.actor.actionItem(item, async () => itemSheetDialog.render(true));
|
||||||
|
@ -262,70 +262,6 @@ export class RdDItem extends Item {
|
|||||||
if (this.actor) {
|
if (this.actor) {
|
||||||
chatData.actor = { id: this.actor.id };
|
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
|
// JSON object for easy creation
|
||||||
chatData.jsondata = JSON.stringify(
|
chatData.jsondata = JSON.stringify(
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
<a class="item-control item-vendre" title="Vendre ou donner"><i class="fas fa-comments-dollar"></i></a>
|
<a class="item-control item-vendre" title="Vendre ou donner"><i class="fas fa-comments-dollar"></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
<a class="item-control item-montrer" title="Montrer"><i class="fas fa-comment"></i></a>
|
||||||
{{#if item.data.actionPrincipale}}
|
{{#if item.data.actionPrincipale}}
|
||||||
<a class="item-name item-action">{{item.data.actionPrincipale}}</a>
|
<a class="item-name item-action">{{item.data.actionPrincipale}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -9,28 +9,6 @@
|
|||||||
{{#each properties as |property p|}}
|
{{#each properties as |property p|}}
|
||||||
<span>{{{property}}}</span><br>
|
<span>{{{property}}}</span><br>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#if (or postQuantity postPrice)}}
|
|
||||||
<span>
|
|
||||||
{{#if postQuantity}}
|
|
||||||
<b>Quantité: </b> <span class="postQuantity">{{postQuantity}}</span>
|
|
||||||
{{/if}}
|
|
||||||
{{#if postPrice}}
|
|
||||||
<b>Prix: </b> <span class="postPrice">{{postPrice}} Sols</span>
|
|
||||||
{{/if}}
|
|
||||||
</span><br>
|
|
||||||
{{/if}}
|
|
||||||
<span>
|
|
||||||
<b>Prix Total: </b> <span class="postPrice">{{finalPrice}} Sols</span><br>
|
|
||||||
</span>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{{#if hasPrice}}
|
|
||||||
<span class="chat-card-button-area">
|
|
||||||
<a class='payer-button chat-card-button market-button'
|
|
||||||
data-jsondata='{{jsondata}}'
|
|
||||||
{{#if actor.id}}data-actor-id='{{actor.id}}'{{/if}}
|
|
||||||
data-somme-denier="{{data.cout_deniers_total}}" data-quantite="{{data.quantite}}">Payer</a>
|
|
||||||
</span>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user