diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f6020c..7312a24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,9 @@ - Added English Compendiums for Field of Victory (thanks to mdosantos). - Added English "Blessed Treasures" in items for Field of Victory (thanks to PlatFleece) - Added English/French "Blessed Treasures" and "Concealed Horror" in items for Shadowlands. -- Added label for grips in Weapon sheet (thanks to TesserWract) -- Fixed the "empty sheet" bug ! (I hope) +- QoL : Added label for grips in Weapon sheet (thanks to TesserWract). +- QoL : Added buttons to Add or Subtract money. +- Fixed the "empty sheet" bug (I hope). - Fixed the "bought_at_rank" does not change according to the PC rank value when an Item is drop on a sheet. - Fixed the issue #23 "Token image does not save". Now we reflect the change on the token name/image only if it's a linked actor and if the token/sheet have the same values. - Fixed the "unlink actor data" who still change the Actor Data. diff --git a/system/scripts/actors/character-sheet.js b/system/scripts/actors/character-sheet.js index 1410af4..3a99e62 100644 --- a/system/scripts/actors/character-sheet.js +++ b/system/scripts/actors/character-sheet.js @@ -95,6 +95,9 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e { this.render(false); }); + // Money +/- + html.find(".money-control").on("click", this._modifyMoney.bind(this)); + // Advancements Tab to current rank onload // TODO class "Active" Bug on load, dunno why :/ this._tabs @@ -212,4 +215,33 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e { _moneyToZeni(koku, bu, zeni) { return Math.floor(koku * CONFIG.l5r5e.money[0]) + Math.floor(bu * CONFIG.l5r5e.money[1]) + Math.floor(zeni); } + + /** + * Add or Subtract money (+/- buttons) + * @param {Event} event + * @private + */ + _modifyMoney(event) { + event.preventDefault(); + event.stopPropagation(); + + const elmt = $(event.currentTarget); + const type = elmt.data("type"); + let mod = elmt.data("value"); + if (!mod || !type) { + return; + } + + if (type !== "zeni") { + mod = Math.floor(mod * CONFIG.l5r5e.money[type === "koku" ? 0 : 1]); + } + + this.actor.data.data.zeni = +this.actor.data.data.zeni + mod; + this.actor.update({ + data: { + zeni: this.actor.data.data.zeni, + }, + }); + this.render(false); + } } diff --git a/system/styles/scss/sheets.scss b/system/styles/scss/sheets.scss index 7aa64ee..c608fab 100644 --- a/system/styles/scss/sheets.scss +++ b/system/styles/scss/sheets.scss @@ -689,6 +689,9 @@ margin-left: 0.5rem; } } + .money-buttons { + line-height: 13px; + } } table { font-size: 0.85rem; diff --git a/system/templates/actors/character/inventory.html b/system/templates/actors/character/inventory.html index 1d99d23..2801e26 100644 --- a/system/templates/actors/character/inventory.html +++ b/system/templates/actors/character/inventory.html @@ -3,14 +3,26 @@ {{!-- items list --}}