mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Damage-Reroll (#753)
* Added rerolls for damage dice in chat * Fixed multiple dice * Added reroll icon * Fixed new style of dialog
This commit is contained in:
parent
2aaab73699
commit
300719c116
28 changed files with 1094 additions and 167 deletions
|
|
@ -4,10 +4,13 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
|
||||
async renderHTML() {
|
||||
const actor = game.actors.get(this.speaker.actor);
|
||||
const actorData = actor && this.isContentVisible ? actor : {
|
||||
img: this.author.avatar ? this.author.avatar : 'icons/svg/mystery-man.svg',
|
||||
name: ''
|
||||
};
|
||||
const actorData =
|
||||
actor && this.isContentVisible
|
||||
? actor
|
||||
: {
|
||||
img: this.author.avatar ? this.author.avatar : 'icons/svg/mystery-man.svg',
|
||||
name: ''
|
||||
};
|
||||
/* We can change to fully implementing the renderHTML function if needed, instead of augmenting it. */
|
||||
const html = await super.renderHTML({ actor: actorData, author: this.author });
|
||||
|
||||
|
|
@ -18,28 +21,26 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
||||
/** @inheritDoc */
|
||||
prepareData() {
|
||||
if(this.isAuthor && this.targetSelection === null)
|
||||
this.targetSelection = this.system.targets?.length > 0;
|
||||
if (this.isAuthor && this.targetSelection === null) this.targetSelection = this.system.targets?.length > 0;
|
||||
super.prepareData();
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
||||
/** @inheritDoc */
|
||||
_onCreate(data, options, userId) {
|
||||
super._onCreate(data, options, userId);
|
||||
if(this.system.registerTargetHook) this.system.registerTargetHook();
|
||||
if (this.system.registerTargetHook) this.system.registerTargetHook();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @inheritDoc */
|
||||
async _preDelete(options, user) {
|
||||
if(this.targetHook !== null) Hooks.off("targetToken", this.targetHook);
|
||||
if (this.targetHook !== null) Hooks.off('targetToken', this.targetHook);
|
||||
return super._preDelete(options, user);
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
element.addEventListener('mouseleave', this.unhoverTarget);
|
||||
element.addEventListener('click', this.clickTarget);
|
||||
});
|
||||
|
||||
|
||||
html.querySelectorAll('.button-target-selection').forEach(element => {
|
||||
element.addEventListener('click', this.onTargetSelection.bind(this));
|
||||
});
|
||||
|
|
@ -192,7 +193,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
|
||||
onTargetSelection(event) {
|
||||
event.stopPropagation();
|
||||
if(!event.target.classList.contains("target-selected"))
|
||||
if (!event.target.classList.contains('target-selected'))
|
||||
this.system.targetMode = Boolean(event.target.dataset.targetHit);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue