Open SquidOfDoomed opened 3 weeks ago
Buying works from the loot sheet. If you want to increase the compatibility with Monks Module I need more info what they need. I wont research it
Good point. Cant supply that since I am still starting off with foundry. Tried the same thing with the default loot and no modules and could not purchase items with a test character. I created a user, an item, a character (555 crowns) and a loot sheet containing the item (for 50 crowns). I updated the test user permissions (owner of character, observer of shop) and logged in as that account. Trying to purchase it led to the following error on console:
Uncaught (in promise) TypeError: buyerActor is undefined
_onItemBuy https://<ip>:30000/systems/TheWitcherTRPG/module/actor/sheets/WitcherLootSheet.js:250
jQuery 2
dispatch
handle
Result: No items were transferred but money removed. It is very possible that one of my steps was wrong or I am missing some setting. If so, it would be great if you could point me towards the solution. This was the main reason I tried to use something like Monks Enhanced Journal.
If this should be another bug, I can also report it. My hope is that both could be the same issue since the behavior is identical. Thanks for your quick response by the way!
I see, the buyer needs to be owner of the loot actor due to the content of the loot actor being changed. Can you try with updated permissions?
Can you open a bug for the deduction of money. It should only be spent if the target actor can get the item
Did create that bug report: https://github.com/witchertrpg-foundryvtt/TheWitcherTRPG/issues/136 I also tried with owner. Now the buy works. Sadly not as expected. If you have x50 of an item and you click buy it removes the crowns of one item but adds 50 items to the character sheet. The shop then results having x49 items left. Screenshot:
I looked a bit further into this and it seems to me that the "createEmbeddedDocuments" function is using the readonly _stats (item base) values instead of the system.quantity that is set. I managed to get it to work via updating the item after creation (module/actor/sheets/WitcherLootSheet.js:112):
await createdItem.update({ "system.quantity": newItem.system.quantity });
I am aware that this is a potentially ugly solution but it works better than before. It is possible that I understood the documentation wrongly. I'm open for feedback on this.
What do you think?
Description:
I'm encountering an issue where players cannot successfully purchase items from a shop in Foundry VTT. When a player clicks "purchase," the chat logs the transaction, but the item is not added to their inventory. This issue occurs with both custom shops and the default shop functionality. Foundry VTT Version:
12.33.1 The Witcher TRPG Version:
12.2.1 Modules Installed:
Steps to Reproduce:
Console Error:
The following error is shown in the console when an item is purchased:
javascript
Uncaught (in promise) TypeError: event.dataTransfer is undefined [Detected 3 packages: system:TheWitcherTRPG(v12.2.1), monks-enhanced-journal(12.01), lib-wrapper(1.12.14.0)] _onDropItem itemMixin.js:23 grantItem LootSheet.js:511 jQuery 9 activateListeners LootSheet.js:127 renderSubSheet enhanced-journal.js:439 _render enhanced-journal.js:149 render foundry.js:5793