Skip to content

Commit

Permalink
Merge pull request #156 from jeremyregnerus:Issue-152
Browse files Browse the repository at this point in the history
Resolves #152 Use default rolls for Attack and Damage
  • Loading branch information
zeel01 authored Feb 23, 2022
2 parents c95c0d6 + c5db034 commit 7c6fde8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
2 changes: 2 additions & 0 deletions monsterblock.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@
height: 1em;
padding: 0;
}
.monsterblock .item-attackRoll:hover,
.monsterblock .item-damageRoll:hover,
.monsterblock .ability:hover,
.monsterblock .saving-throw:hover,
.monsterblock .skill:hover,
Expand Down
23 changes: 23 additions & 0 deletions scripts/dnd5e/MonsterBlock5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,29 @@ export default class MonsterBlock5e extends ActorSheet5eNPC {
}
else return item.roll(); // Conveniently, items have all this logic built in already.
});

// uses the built in attack roll from the item
// uses mousedown to prevent highlighting of text when using shift modifier
html.find(".item-attackRoll").mousedown(async (event) => {
event.preventDefault();

let id = event.currentTarget.dataset.itemId;
const item = this.actor.items.get(id);

item.rollAttack({event});
});

// uses the built in damage roll from the item
// uses mousedown to prevent highlighting of text when using shift modifier
html.find(".item-damageRoll").mousedown(async (event) => {
event.preventDefault();

let id = event.currentTarget.dataset.itemId;
let versatile = event.currentTarget.dataset.versatile;
const item = this.actor.items.get(id);

item.rollDamage({event, versatile});
})

// Item editing handlers. Allows right clicking on the description of any item (features, action, etc.) to open its own sheet to edit.
html.find(".item").contextmenu(this.openItemEditor.bind(this));
Expand Down
6 changes: 3 additions & 3 deletions templates/dnd5e/parts/damageRoll.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<span class="attack-damage"
data-roll-flavor="{{localize 'DND5E.Damage'}}: {{name}}"
data-roll-formula="{{formula}}">
<span class="item-damageRoll"
data-item-id="{{id}}"
data-versatile={{versatile}} >
{{~text~}}
</span>
12 changes: 5 additions & 7 deletions templates/dnd5e/parts/main/attack.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
{{ localize "MOBLOKS5E.NameDescriptionSep" }}
{{#if @root.flags.attack-descriptions}}
<span class="generated-text">
<span class="attack-bonus"
data-roll-flavor="{{ localize "DND5E.Attack" }}: {{item.name}}"
data-roll-formula="1d20 + {{item.tohit}}">
<span class="item-attackRoll" data-item-id="{{item._id}}">
<span class="attack-type">
{{~item.description.attackType~}}
{{ localize "MOBLOKS5E.Colon" }}
Expand All @@ -33,13 +31,13 @@
{{#unless @first}}
{{ localize "MOBLOKS5E.MultiDamageAttackConjunctionPlus" }}
{{/unless}}
{{> "modules/monsterblock/templates/dnd5e/parts/damageRoll.hbs" text=part.text name=../item.name formula=part.formula}}
{{> "modules/monsterblock/templates/dnd5e/parts/damageRoll.hbs" id=../item._id text=part.text }}
{{ localize "MOBLOKS5E.damage" }}
{{~#if (and @first ../item.description.versatile)~}}
{{ localize "MOBLOKS5E.Comma" }}
{{> "modules/monsterblock/templates/dnd5e/parts/damageRoll.hbs"
name=../item.name
formula=../item.description.versatile.formula
{{> "modules/monsterblock/templates/dnd5e/parts/damageRoll.hbs"
id=../item._id
versatile=true
text=( localize "MOBLOKS5E.AttackVersatile"
damage=../item.description.versatile.text
)
Expand Down

0 comments on commit 7c6fde8

Please sign in to comment.