Skip to content

Commit

Permalink
Merge pull request #194 from anthonyronda/fix/gp-cost-do-not-multiply…
Browse files Browse the repository at this point in the history
…-when-at-max

Fix GP cost multiplying when a max quantity is defined
  • Loading branch information
anthonyronda authored Jun 9, 2022
2 parents 3ccdda2 + c66af8f commit d25a660
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@
"OSE.items.enterTag": "Tags",
"OSE.items.pattern": "Attack pattern marker",
"OSE.items.uses": "Uses",
"OSE.items.gp.short": "GP",
"OSE.items.gp.long": "Gold Pieces",

"OSE.items.Range": "Range",
"OSE.items.Melee": "Melee",
Expand Down
2 changes: 1 addition & 1 deletion src/module/dialog/character-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class OseCharacterCreator extends FormApplication {
});
// Generate gold
const itemData = {
name: "GP",
name: game.i18n.localize("OSE.items.gp.short"),
type: "item",
img: "systems/ose/assets/gold.png",
data: {
Expand Down
9 changes: 7 additions & 2 deletions src/module/dialog/character-gp-cost.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export class OseCharacterGpCost extends FormApplication {
// Generate gold
const totalCost = await this._getTotalCost(await this.getData());
const gp = await this.object.items.find((item) => {
return item.name === "GP" && item.data.data.treasure;
return (
(item.name === game.i18n.localize("OSE.items.gp.short") ||
item.name === "GP") && // legacy behavior used GP, even for other languages
item.data.data.treasure
);
});
if (!gp) {
ui.notifications.error(game.i18n.localize("OSE.error.noGP"));
Expand Down Expand Up @@ -104,7 +108,8 @@ export class OseCharacterGpCost extends FormApplication {
physical.some((itemType) => item.type === itemType) &&
!item.data.treasure
)
total += item.data.cost * item.data.quantity.value;
if (item.data.quantity.max) total += item.data.cost;
else total += item.data.cost * item.data.quantity.value;
});
return total;
}
Expand Down

0 comments on commit d25a660

Please sign in to comment.