Skip to content

Commit

Permalink
Added log entries for buyer funds before and after the purchase so in…
Browse files Browse the repository at this point in the history
… case something goes wrong one can at least see what happened and revert the players inventory
  • Loading branch information
kevin brammer committed Mar 20, 2021
1 parent fb82eca commit b408ee9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lootsheetnpc5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,8 @@ Hooks.once("init", () => {
// console.log(`ItemCost: ${itemCostInGold}`)
let buyerFunds = duplicate(buyer.data.data.currency);

console.log(`Funds before purchase: ${buyerFunds}`);

const conversionRates = {
"pp": 1,
"gp": CONFIG.DND5E.currencyConversion.gp.each,
Expand Down Expand Up @@ -1401,6 +1403,9 @@ Hooks.once("init", () => {

// Update buyer's funds
buyer.update({ "data.currency": buyerFunds });

console.log(`Funds after purchase: ${buyerFunds}`);

let moved = await moveItems(seller, buyer, [{ itemId, quantity }]);

for (let m of moved) {
Expand Down

0 comments on commit b408ee9

Please sign in to comment.