ironmonk88 / monks-enhanced-journal

GNU General Public License v3.0
53 stars 54 forks source link

Request: Allow decimals in shop prices (SWADE) #287

Open humsi opened 2 years ago

humsi commented 2 years ago

Hi, I have only recently found the module and so far I am very impressed. Very streamlined and well-thought-out.

However, there is one thing that does not work as I had hoped.

I play Savage Worlds and would like to create a shop. In Savage Worlds there is only one currency (e.g. Dollar) and the item prices are listed accordingly with decimal values (e.g. Arrow - cost $0.1 per item). To do this, I created the journal entry type "Shop" and dragged the items from the compendium into the shop's journal entry.

Edit: Since release of version 1.0.59 it's no longer possible to drag-and-drop an item from the compendium to the shop inventory if the price contains a decimal number. The shop is broken from now on and cannot be used. It only shows a blank page. grafik

The console displays the following error message:

monks-enhanced-journal |  TypeError: Cannot read properties of undefined (reading 'length')
    at Function.getPrice (EnhancedJournalSheet.js:500)
    at ShopSheet.getPrice (EnhancedJournalSheet.js:523)
    at ShopSheet.getItemGroups (EnhancedJournalSheet.js:865)
    at ShopSheet.getData (ShopSheet.js:55)
    at EnhancedJournal.renderSubSheet (enhanced-journal.js:207)
    at EnhancedJournal._render (enhanced-journal.js:114)
Original bug report > The items are displayed correctly, but the prices are shown incorrectly. > **Decimal values are automatically reset to 0. So if I set an item value to $0.1, the value automatically changes to 0.** > > ![image](https://user-images.githubusercontent.com/83549920/170112125-e7cf9f36-181a-4bd4-b7a0-dac99dfc4bbd.png) > > > > It seems that the prices are only accepted if the numbers in the fields are integers. > Is there any way to display decimal values as well? > > **And in the attempt to solve the problem with an alternative currency (such as gold), the next problem arose directly:** > (Thus, I could have avoided the decimal digits by making 0.1$ = 1 silver) > > Let's say the shopkeeper only accepts bare metal, like gold (1 Gold = $10). > I've set up the currency conversion correctly (Dollar:0, Gold:10). > ![image](https://user-images.githubusercontent.com/83549920/170111604-3a4be945-3fb2-47dc-a1e5-b9aa45e6c5ab.png) > > > If I set up an item which should sell for 1 Gold (or $10) the price is not converted, and instead the gold price is deducted at the purchase. So instead of $10 only $1 is withdrawn from the player. Here is an example: > > ![curreny_conversion](https://user-images.githubusercontent.com/83549920/170112584-ba2518f1-7388-4d47-aedb-dffbdd196d27.gif) > Any idea how to fix this?

Thanks 🙂!

Gazook89 commented 2 years ago

Just going to add to this that I think decimal values should be a toggle, rather than always include. I am also using SWADE, but sticking to "gold" as the currency, and want to avoid players have decimal values for their total gold.

Gazook89 commented 2 years ago

Coming back to this, I can confirm that dragging Items to a shop breaks the shop if the value is a decimal. Slightly different error than reported above, though:

monks-enhanced-journal |  TypeError: price.toString().split(...)[1] is undefined
    getPrice https://assets.forge-vtt.com/bazaar/modules/monks-enhanced-journal/1.0.63/sheets/EnhancedJournalSheet.js:551
    getPrice https://assets.forge-vtt.com/bazaar/modules/monks-enhanced-journal/1.0.63/sheets/EnhancedJournalSheet.js:586
    getItemGroups https://assets.forge-vtt.com/bazaar/modules/monks-enhanced-journal/1.0.63/sheets/EnhancedJournalSheet.js:940
    getData https://assets.forge-vtt.com/bazaar/modules/monks-enhanced-journal/1.0.63/sheets/ShopSheet.js:63
    renderSubSheet https://assets.forge-vtt.com/bazaar/modules/monks-enhanced-journal/1.0.63/apps/enhanced-journal.js:215
    _render https://assets.forge-vtt.com/bazaar/modules/monks-enhanced-journal/1.0.63/apps/enhanced-journal.js:114
monks-enhanced-journal.js:31:41
Gazook89 commented 2 years ago

Same issue on DnD5e system as on SWADE. To replicate in the DnD5e system, you need to delete out any 'smaller denomination' in the module "currency" settings. For example:

  1. create an item with value of .2 gp. Create a shop
  2. create a shop
  3. open the MEJ module settings, and in the currency dialog remove all currencies except gp, with a conversion of 0.
  4. drag the Item to the shop -- boom, error.

Seems like the function is requiring a conversion for decimals, rather than just allowing the decimal to exist (if no conversion is available).