Added buttons to Add or Subtract money

This commit is contained in:
Vlyan
2021-06-16 10:50:50 +02:00
parent c4549877ee
commit b0e212f3e3
4 changed files with 50 additions and 2 deletions

View File

@@ -6,8 +6,9 @@
- Added English Compendiums for Field of Victory (thanks to mdosantos). - 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 "Blessed Treasures" in items for Field of Victory (thanks to PlatFleece)
- Added English/French "Blessed Treasures" and "Concealed Horror" in items for Shadowlands. - Added English/French "Blessed Treasures" and "Concealed Horror" in items for Shadowlands.
- Added label for grips in Weapon sheet (thanks to TesserWract) - QoL : Added label for grips in Weapon sheet (thanks to TesserWract).
- Fixed the "empty sheet" bug ! (I hope) - 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 "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 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. - Fixed the "unlink actor data" who still change the Actor Data.

View File

@@ -95,6 +95,9 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
this.render(false); this.render(false);
}); });
// Money +/-
html.find(".money-control").on("click", this._modifyMoney.bind(this));
// Advancements Tab to current rank onload // Advancements Tab to current rank onload
// TODO class "Active" Bug on load, dunno why :/ // TODO class "Active" Bug on load, dunno why :/
this._tabs this._tabs
@@ -212,4 +215,33 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
_moneyToZeni(koku, bu, zeni) { _moneyToZeni(koku, bu, zeni) {
return Math.floor(koku * CONFIG.l5r5e.money[0]) + Math.floor(bu * CONFIG.l5r5e.money[1]) + Math.floor(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);
}
} }

View File

@@ -689,6 +689,9 @@
margin-left: 0.5rem; margin-left: 0.5rem;
} }
} }
.money-buttons {
line-height: 13px;
}
} }
table { table {
font-size: 0.85rem; font-size: 0.85rem;

View File

@@ -3,14 +3,26 @@
<label> <label>
{{localize 'l5r5e.money.koku'}} {{localize 'l5r5e.money.koku'}}
<input name="data.money.koku" type="number" value="{{data.data.money.koku}}" data-dtype="Number" min="0" placeholder="0"/> <input name="data.money.koku" type="number" value="{{data.data.money.koku}}" data-dtype="Number" min="0" placeholder="0"/>
<span class="money-buttons">
<i class="money-control pointer-choice fa fa-plus-square" data-type="koku" data-value="1"></i>
<i class="money-control pointer-choice fa fa-minus-square" data-type="koku" data-value="-1"></i>
</span>
</label> </label>
<label> <label>
{{localize 'l5r5e.money.bu'}} {{localize 'l5r5e.money.bu'}}
<input name="data.money.bu" type="number" value="{{data.data.money.bu}}" data-dtype="Number" min="0" placeholder="0"/> <input name="data.money.bu" type="number" value="{{data.data.money.bu}}" data-dtype="Number" min="0" placeholder="0"/>
<span class="money-buttons">
<i class="money-control pointer-choice fa fa-plus-square" data-type="bu" data-value="1"></i>
<i class="money-control pointer-choice fa fa-minus-square" data-type="bu" data-value="-1"></i>
</span>
</label> </label>
<label> <label>
{{localize 'l5r5e.money.zeni'}} {{localize 'l5r5e.money.zeni'}}
<input name="data.money.zeni" type="number" value="{{data.data.money.zeni}}" data-dtype="Number" min="0" placeholder="0"/> <input name="data.money.zeni" type="number" value="{{data.data.money.zeni}}" data-dtype="Number" min="0" placeholder="0"/>
<span class="money-buttons">
<i class="money-control pointer-choice fa fa-plus-square" data-type="zeni" data-value="1"></i>
<i class="money-control pointer-choice fa fa-minus-square" data-type="zeni" data-value="-1"></i>
</span>
</label> </label>
</fieldset> </fieldset>
{{!-- items list --}} {{!-- items list --}}