Skip to content

Commit

Permalink
Bug Fixes with Battlegroup trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliharu committed Feb 22, 2025
1 parent 47ac15e commit f53f93f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
34 changes: 22 additions & 12 deletions module/apps/dice-roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2504,8 +2504,8 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
// Split the formula string based on operand
const [leftOperand, operand, rightOperand] = charmValue.split(operandRegex);

var leftVar = this._getFormulaValue(leftOperand.trim(), opposedCharmActor, item);
var rightVar = this._getFormulaValue(rightOperand.trim(), opposedCharmActor, item);
let leftVar = this._getFormulaValue(leftOperand.trim(), opposedCharmActor, item);
let rightVar = this._getFormulaValue(rightOperand.trim(), opposedCharmActor, item);

// Perform operation based on operand
switch (operand) {
Expand Down Expand Up @@ -2588,7 +2588,7 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)

if (formula.includes('cap')) {
// let split = formula.split(' ');
const match = formula.match(/^(\d+)\s+cap\s+(\(.*\))$/);
const match = formula.match(/^(\d+)\s+cap\s+(\(?.*?\)?)$/);

if (!match) {
console.error("Invalid formula format:", formula);
Expand Down Expand Up @@ -2681,7 +2681,7 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
}
if (formula?.toLowerCase() === 'damagedealt') {
if (this.object.initiativeDamageDealt) {
return this.object.initiativeDamageDealt || 0;
return this.object.initiativeDamageDealt;
}
return this.object.damageLevelsDealt || 0;
}
Expand Down Expand Up @@ -2731,9 +2731,10 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
}
if (formula.includes('rollfaces-')) {
formula = formula.replace('rollfaces-', '');
let countRerolledDice = true;
let countRerolledDice = false;
if (formula.includes('-precedence')) {
formula = formula.replace('-precedence', '');
countRerolledDice = true;
}
if (!parseInt(formula)) {
return 0;
Expand Down Expand Up @@ -4360,7 +4361,7 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
}
}
}
if (this.object.targetCombatant?.actor?.system?.battlegroup) {
if (this.object.target?.actor?.system?.battlegroup) {
if (game.settings.get("exaltedthird", "automaticWitheringDamage")) {
sizeDamaged = this.dealHealthDamage(this.object.damageSuccesses, true);
if (sizeDamaged) {
Expand All @@ -4386,7 +4387,7 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
if (crashed) {
fullInitiative += (this.object.damage.crashBonus ?? 5);
}
if (this.object.targetCombatant?.actor?.system?.battlegroup) {
if (this.object.target?.actor?.system?.battlegroup) {
fullInitiative = (5 * sizeDamaged) + 1;
}
if (!game.settings.get("exaltedthird", "automaticWitheringDamage") && this.object.gainedInitiative) {
Expand Down Expand Up @@ -4839,7 +4840,6 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
}
switch (bonus.effect) {
case 'diceModifier':
case 'successModifier':
case 'penaltyModifier':
case 'ignorePenalties':
case 'rerollNumber':
Expand All @@ -4854,6 +4854,12 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
case 'goalNumber':
this.object[bonus.effect] += this._getFormulaValue(cleanedValue, triggerActor, charm);
break;
case 'successModifier':
if(this.object.total) {
this.object.total += this._getFormulaValue(cleanedValue, triggerActor, charm);
}
this.object[bonus.effect] += this._getFormulaValue(cleanedValue, triggerActor, charm);
break;
case 'attackClash':
this.object.isClash = (typeof cleanedValue === "boolean" ? cleanedValue : true);
for (let specialAttack of this.object.specialAttacksList) {
Expand Down Expand Up @@ -5232,10 +5238,14 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)

async _triggerRequirementsMet(charm, trigger, bonusType = "benefit", triggerAmountIndex, display, triggerHasBeenActivatedOnItem, triggerActor) {
let fufillsRequirements = true;
let opposingActor = this.object.target;
let opposingActor = this.object.target?.actor;
if (bonusType === 'benefit' && this.object.rollType === 'useOpposingCharms') {
opposingActor = this.object.attacker;
}
if(bonusType === 'opposed' && this.object.rollType !== 'useOpposingCharms') {
opposingActor = this.actor;
}

for (const requirementObject of Object.values(trigger.requirements)) {
if (!fufillsRequirements) {
break;
Expand Down Expand Up @@ -5312,10 +5322,10 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
}
break;
case 'incapacitatedTarget':
if (!this.object.target) {
if (!this.object.target?.actor) {
fufillsRequirements = false;
}
else if (this.object.target.system.health.value > (this.object.damageLevelsDealt ?? 0)) {
else if (this.object.target.actor.system.health.value > (this.object.damageLevelsDealt ?? 0)) {
fufillsRequirements = false;
}
break;
Expand Down Expand Up @@ -5423,7 +5433,7 @@ export default class RollForm extends HandlebarsApplicationMixin(ApplicationV2)
if (!opposingActor) {
fufillsRequirements = false;
}
else if (!opposingActor.system.battlegroup) {
else if ((opposingActor.system.battlegroup ?? false) !== cleanedValue) {
fufillsRequirements = false;
}
break;
Expand Down
3 changes: 2 additions & 1 deletion module/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ export class ExaltedThirdItem extends Item {
}

async _createModifiers(target = this.parent) {
if (!target) {
if (!target || !this.system.custommodifier.key || target.items.some(items => items.type === 'modifier' && items.system.formulaKey === this.system.custommodifier.key)) {
return;
}
await target.createEmbeddedDocuments("Item", [
{
name: this.system.custommodifier.name || "No Name",
img: this.img,
type: 'modifier',
parent: target,
renderSheet: undefined,
Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Unofficial Exalted third edition system module for FoundryVTT! Portions of the materials are the copyrights and trademarks of Paradox Interactive AB, and are used with permission. All rights reserved. For more information please visit worldofdarkness.com.",
"url": "https://github.com/Aliharu/Foundry-Ex3",
"license": "LICENSE.txt",
"version": "3.7.1",
"version": "3.7.2",
"compatibility": {
"minimum": "12",
"verified": "12",
Expand Down Expand Up @@ -50,7 +50,7 @@
],
"relationships": [],
"manifest": "https://raw.githubusercontent.com/Aliharu/Foundry-Ex3/master/system.json",
"download": "https://github.com/Aliharu/Foundry-Ex3/releases/download/v3.7.1/release3.7.1.zip",
"download": "https://github.com/Aliharu/Foundry-Ex3/releases/download/v3.7.2/release3.7.2.zip",
"bugs": "https://github.com/Aliharu/Foundry-Ex3/issues",
"gridDistance": 5,
"gridUnits": "ft",
Expand Down

0 comments on commit f53f93f

Please sign in to comment.