fantasycalendar / FoundryVTT-ItemPiles

Other
34 stars 54 forks source link

Add utility method getStringFromCurrencies #499

Closed p4535992 closed 8 months ago

p4535992 commented 8 months ago

I decided to kill lazy money in favor of item piles.

During the development of integration with other modules I noticed that they almost all are based on the concept of value+denominatiom, in order not to rewrite the same code several times I thought to try to insert the utility method directly on Item Piles, also because I don't know if there are necessary controls on currency denominations present on game.itempiles.API.CURRENCIES or game.itempiles.API.SECONDARY_CURRENCIES.

Haxxer commented 8 months ago

I would recommend using the abbreviation property on the currencies, which are usually {#}GP, which when {#} is replaced with the number it becomes 5GP. You can see this here:

https://github.com/fantasycalendar/FoundryVTT-ItemPiles/blob/master/src/helpers/pile-utilities.js#L1444-L1452

I would also recommend putting the validation in the public-facing API method, rather than the method in the PileUtilities, to conform to the typical layout, as you can see here:

https://github.com/fantasycalendar/FoundryVTT-ItemPiles/blob/master/src/API/api.js#L1780-L1799

p4535992 commented 8 months ago

Apply advises and put a method for help to check if the abbreviation exists on item piles. If it makes sense to you as well or I remove it ... basically I need a method to be able to say the string "GP" is recorded as abbrevation "GP" (without the {#} ) in at least one of the currencies, or maybe there is already a alternative method for accomplish this.

Haxxer commented 8 months ago

Probably isn't needed to validate that, but we'll keep it. Thanks for the contribution!