Skip to content

Commit

Permalink
[#170] Fix not applying proficiency (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
PwQt authored Oct 18, 2024
2 parents ec1fbc0 + 49a5476 commit 49d420f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"MAGICITEMS.SheetEffect": "Effect",
"MAGICITEMS.SheetUpcast": "Upcast",
"MAGICITEMS.SheetCost": "Cost/Lvl",
"MAGICITEMS.SheetSaveDC": "Save DC",
"MAGICITEMS.SheetAttackBonus": "Atk. Bonus",
"MAGICITEMS.SheetNoRecharge": "Not Rechargeable",
"MAGICITEMS.SheetNoChargesMessage": "does not have enough charge for",
"MAGICITEMS.SheetDialogTitle": "Warning!",
Expand Down
1 change: 1 addition & 0 deletions src/scripts/magic-item-entry/MagicItemSpell.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class MagicItemSpell extends AbstractMagicItemEntry {
this.dc = this.flatDc && this.dc ? this.dc : "";
this.componentsVSM = this.componentsVSM;
this.componentsALL = this.componentsALL;
this.atkBonus = this.checkAtkBonus && this.atkBonus ? this.atkBonus : "";
}

get levels() {
Expand Down
23 changes: 21 additions & 2 deletions src/scripts/magic-item-owned-entry/OwnedMagicItemSpell.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ export class OwnedMagicItemSpell extends AbstractOwnedMagicItemEntry {
});
}

if (data.system.actionType === "rsak" || data.system.actionType === "msak") {
let attackBonusValue = this.item.atkBonus.toString();
if (!this.item.checkAtkBonus) {
attackBonusValue = this.magicItem.actor?.system?.attributes?.prof?.toString();
}
if (data.system.attack.bonus) {
data.system.attack.bonus += `+ ${attackBonusValue}`;
} else {
data.system.attack.bonus = attackBonusValue;
}
}

// if (this.item.checkAtkBonus) {
// data = foundry.utils.mergeObject(data, {
// "system"
// });
// }

data = foundry.utils.mergeObject(data, {
"system.preparation": { mode: "magicitems" },
});
Expand All @@ -51,11 +69,11 @@ export class OwnedMagicItemSpell extends AbstractOwnedMagicItemEntry {
let clonedOwnedItem = this.ownedItem;
let itemUseConfiguration = {};

const sOptions = MagicItemHelpers.createSummoningOptions(spell);
if (
MagicItemHelpers.canSummon() &&
(spell.system.summons?.creatureTypes?.length > 1 || spell.system.summons?.profiles?.length > 1)
) {
const sOptions = MagicItemHelpers.createSummoningOptions(spell);
const summoningDialogResult = await this.askSummonningMessage(sOptions);
if (summoningDialogResult) {
foundry.utils.mergeObject(itemUseConfiguration, {
Expand All @@ -76,6 +94,7 @@ export class OwnedMagicItemSpell extends AbstractOwnedMagicItemEntry {
spell = spell.clone({ "system.scaling": "none" }, { keepId: true });
clonedOwnedItem = clonedOwnedItem.clone({ "system.scaling": "none" }, { keepId: true });
spell.prepareFinalAttributes();
//clonedOwnedItem.prepareFinalAttributes();
}

if (upcastLevel !== spell.system.level) {
Expand All @@ -93,7 +112,7 @@ export class OwnedMagicItemSpell extends AbstractOwnedMagicItemEntry {
configureDialog: false,
createMessage: true,
flags: {
"dnd5e.itemData": clonedOwnedItem.toJSON(),
"dnd5e.itemData": clonedOwnedItem,
},
});
if (chatData) {
Expand Down
18 changes: 17 additions & 1 deletion src/templates/magic-item-tab.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
<div class="item-detail spell-consumption-head">{{localize "MAGICITEMS.SheetConsumption"}}</div>
<div class="item-detail spell-upcast-head">{{localize "MAGICITEMS.SheetUpcast"}}</div>
<div class="item-detail spell-cost-head">{{localize "MAGICITEMS.SheetCost"}}</div>
<div class="item-detail spell-dc-head">Save DC</div>
<div class="item-detail spell-dc-head">{{localize "MAGICITEMS.SheetSaveDC"}}</div>
<div class="item-detail spell-atk-bonus">{{localize "MAGICITEMS.SheetAttackBonus"}}</div>
<div class="item-controls spell-controls-head">&nbsp;</div>
</li>
<ol class="item-list">
Expand Down Expand Up @@ -170,6 +171,21 @@
{{enabled item.flatDc}}
/>
</div>
<div class="item-detail flexrow spell-atk-bonus">
<input
class="atk-bonus-checkbox"
type="checkbox"
name="flags.magicitems.spells.{{i}}.checkAtkBonus"
{{checked item.checkAtkBonus}}
/>
<input
class="atk-bonus"
type="text"
name="flags.magicitems.spells.{{i}}.atkBonus"
value="{{item.atkBonus}}"
{{enabled item.checkAtkBonus}}
/>
</div>
<div class="item-controls">
<a class="item-control item-delete item-spell" data-tooltip="Delete Spell">
<i class="fas fa-trash" data-spell-idx="{{i}}"></i>
Expand Down

0 comments on commit 49d420f

Please sign in to comment.