Fix payer et deplacement objets
This commit is contained in:
parent
2a8602d23a
commit
343b3c54f7
@ -785,21 +785,24 @@ export class RdDActor extends Actor {
|
||||
itemsList.push( {id: itemId, conteneurId: undefined }); // Init list
|
||||
sourceActor.buildSubConteneurObjetList( itemId, itemsList ); // Get itemId list
|
||||
|
||||
let conteneurMap = {};
|
||||
let itemMap = {};
|
||||
for (let item of itemsList) {
|
||||
let copyItem = sourceActor.data.items.find( subItem => subItem._id == item.id );
|
||||
let newItem = await this.createOwnedItem( duplicate(copyItem) );
|
||||
console.log('New object', newItem);
|
||||
if (copyItem.type == 'conteneur') {
|
||||
conteneurMap[copyItem._id] = newItem._id;
|
||||
}
|
||||
let srcItem = sourceActor.data.items.find( subItem => subItem._id == item.id );
|
||||
let newItem = await this.createOwnedItem( duplicate(srcItem) );
|
||||
console.log('New object', newItem, srcItem);
|
||||
itemMap[srcItem._id] = newItem._id; // Pour garder le lien ancien / nouveau
|
||||
}
|
||||
for (let item of itemsList) { // Second boucle pour traiter la remise en conteneurs
|
||||
// gestion conteneur/contenu
|
||||
if ( item.conteneurId) { // l'Objet était dans un conteneur
|
||||
let newConteneurId = conteneurMap[item.conteneurId];
|
||||
let newConteneurId = itemMap[item.conteneurId]; // Get conteneur
|
||||
let newConteneur = this.data.items.find( subItem => subItem._id == newConteneurId );
|
||||
console.log('New conteneur filling!', newConteneur);
|
||||
|
||||
let newItemId = itemMap[item.id]; // Get newItem
|
||||
|
||||
console.log('New conteneur filling!', newConteneur, newItemId, item );
|
||||
let contenu = duplicate(newConteneur.data.contenu);
|
||||
contenu.push( newItem._id );
|
||||
contenu.push( newItemId );
|
||||
await this.updateOwnedItem( {_id: newConteneurId, 'data.contenu': contenu });
|
||||
}
|
||||
}
|
||||
@ -2469,16 +2472,18 @@ export class RdDActor extends Actor {
|
||||
console.log("DENIER", game.user.character, sumDenier, denierDisponible);
|
||||
|
||||
let msg = "";
|
||||
let isPayed = false;
|
||||
if (denierDisponible >= sumDenier) {
|
||||
denierDisponible -= sumDenier;
|
||||
this.optimizeArgent(denierDisponible);
|
||||
msg = `Vous avez payé <strong>${sumDenier} Deniers</strong>, qui ont été soustraits de votre argent.`;
|
||||
RdDAudio.PlayContextAudio("argent"); // Petit son
|
||||
isPayed = true;
|
||||
} else {
|
||||
msg = "Vous n'avez pas assez d'argent pour paye cette somme !";
|
||||
}
|
||||
|
||||
if (dataObj) {
|
||||
if (dataObj && isPayed) {
|
||||
dataObj.payload.data.cout = sumDenier / 100; // Mise à jour du prix en sols , avec le prix acheté
|
||||
await this.createOwnedItem(dataObj.payload);
|
||||
msg += `<br>Et l'objet <strong>${dataObj.payload.name}</strong> a été ajouté à votre inventaire.`;
|
||||
|
@ -72,7 +72,9 @@ export class RdDItem extends Item {
|
||||
chatData.data.cout_deniers = Math.floor(dialogResult[1] * 100); // Mise à jour cout en deniers
|
||||
}
|
||||
chatData.finalPrice = Number(chatData.postPrice) * Number(chatData.postQuantity);
|
||||
chatData.data.cout_deniers_total *= 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);
|
||||
}
|
||||
// Don't post any image for the item (which would leave a large gap) if the default image is used
|
||||
if (chatData.img.includes("/blank.png"))
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"description": "Rêve de Dragon RPG for FoundryVTT",
|
||||
"version": "1.2.28",
|
||||
"version": "1.2.29",
|
||||
"manifestPlusVersion": "1.0.0",
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.8",
|
||||
|
@ -26,7 +26,8 @@
|
||||
|
||||
{{#if hasPrice}}
|
||||
<span class="chat-card-button-area">
|
||||
<a id='payer-button' class='chat-card-button market-button' data-jsondata='{{jsondata}}' data-somme-denier="{{data.cout_deniers_total}}">Payer</a>
|
||||
<a id='payer-button' class='chat-card-button market-button' data-jsondata='{{jsondata}}'
|
||||
data-somme-denier="{{data.cout_deniers_total}}">Payer</a>
|
||||
</span>
|
||||
{{/if}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user