Skip to content

Commit

Permalink
feat(item attack): included a message ID validation for critical attacks
Browse files Browse the repository at this point in the history
The last message ID is compared to the current ID for critical system to be deactivated or
activated.
  • Loading branch information
SouOWendel committed Dec 18, 2023
1 parent 8dbd1bb commit df7e49b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions module/documents/item.mjs
Expand Up @@ -87,14 +87,16 @@ export class OrdemItem extends Item {
const rollAttack = await item.rollAttack({
event: event,
});
item.lastMessageId = messageId;
item.critical = rollAttack.isCritical;
break;
}
case 'damage':
// case 'versatile':
await item.rollDamage({
event: event,
critical: item.critical
critical: item.critical,
lastId: item.lastMessageId == messageId
// spellLevel: spellLevel,
// versatile: action === 'versatile'
});
Expand Down Expand Up @@ -292,17 +294,14 @@ export class OrdemItem extends Item {
const bonus = damage.bonus && '+' + damage.bonus;
const critical = await options.critical || null;
const dice = damage.formula.split('d');
let crtlForm = '';

console.log(critical);
if (critical.isCritical) crtlForm = `${dice[0]*critical.multiplier}d${dice[1]}`;
const rollform = (critical.isCritical && options.lastId) ? `${dice[0]*critical.multiplier}d${dice[1]}` : damage.formula;

for (const [i, attrParent] of Object.entries(this.parent.system.attributes)) {
if (i == attr) attr = '+' + attrParent.value;
}

const rollConfig = {
formula: (crtlForm || damage.formula) + attr + bonus,
formula: rollform + attr + bonus,
data: this.getRollData(),
chatMessage: true
};
Expand Down

0 comments on commit df7e49b

Please sign in to comment.