mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Fixed GroupAttack and DirectDamage
This commit is contained in:
parent
6273394db8
commit
88754c5a80
4 changed files with 72 additions and 46 deletions
|
|
@ -553,8 +553,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
const { memberKey } = button.dataset;
|
||||
this.updatePartyData(
|
||||
{
|
||||
[`system.tagTeam.members.${memberKey}.damageRollData.types`]:
|
||||
_replace({})
|
||||
[`system.tagTeam.members.${memberKey}.damageRollData`]: {
|
||||
main: null,
|
||||
resources: _replace({})
|
||||
}
|
||||
},
|
||||
this.getUpdatingParts(button)
|
||||
);
|
||||
|
|
@ -577,18 +579,18 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
|
||||
async getCriticalDamage(origDamage) {
|
||||
const newDamage = origDamage ? ChatDamageData.fromJSON(JSON.stringify(origDamage)) : null;
|
||||
for (let key in newDamage?.types ?? {}) {
|
||||
const criticalDamage = await getCritDamageBonus(newDamage.types[key].formula);
|
||||
if (!criticalDamage) continue;
|
||||
|
||||
const criticalTerm = new foundry.dice.terms.NumericTerm({ number: criticalDamage, evaluated: true });
|
||||
criticalTerm.evaluate();
|
||||
newDamage.types[key] = await Roll.fromTerms([
|
||||
...origDamage.types[key].terms,
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
criticalTerm
|
||||
]);
|
||||
newDamage.types[key].options = foundry.utils.deepClone(origDamage.types[key].options);
|
||||
if (newDamage?.main) {
|
||||
const criticalDamage = await getCritDamageBonus(newDamage.main.formula);
|
||||
if (criticalDamage) {
|
||||
const criticalTerm = new foundry.dice.terms.NumericTerm({ number: criticalDamage, evaluated: true });
|
||||
criticalTerm.evaluate();
|
||||
newDamage.main = await Roll.fromTerms([
|
||||
...origDamage.main.terms,
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
criticalTerm
|
||||
]);
|
||||
newDamage.main.options = foundry.utils.deepClone(origDamage.main.options);
|
||||
}
|
||||
}
|
||||
|
||||
return newDamage;
|
||||
|
|
@ -644,25 +646,47 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
? await this.getCriticalDamage(secondaryRoll.damageRollData)
|
||||
: secondaryRoll.damageRollData;
|
||||
if (mainRoll.damageRollData) {
|
||||
for (const [key, damage] of Object.entries(secondaryDamage.types ?? {})) {
|
||||
if (key in mainRoll.damageRollData.types) {
|
||||
mainRoll.damageRollData.types[key] = Roll.fromTerms([
|
||||
...baseMainRoll.damageRollData.types[key].terms,
|
||||
if (secondaryDamage.main) {
|
||||
if (mainRoll.damageRollData.main) {
|
||||
mainRoll.damageRollData.main = Roll.fromTerms([
|
||||
...baseMainRoll.damageRollData.main.terms,
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...baseSecondaryRoll.damageRollData.types[key].terms
|
||||
...baseSecondaryRoll.damageRollData.main.terms
|
||||
]);
|
||||
|
||||
/* Joining the roll.options of both rolls */
|
||||
const joinedDamageTypes = new Set([
|
||||
...baseMainRoll.damageRollData.types[key].options.damageTypes,
|
||||
...baseSecondaryRoll.damageRollData.types[key].options.damageTypes
|
||||
...baseMainRoll.damageRollData.main.options.damageTypes,
|
||||
...baseSecondaryRoll.damageRollData.main.options.damageTypes
|
||||
]);
|
||||
mainRoll.damageRollData.types[key].options = {
|
||||
...baseMainRoll.damageRollData.types[key].options,
|
||||
mainRoll.damageRollData.main.options = {
|
||||
...baseMainRoll.damageRollData.main.options,
|
||||
damageTypes: [...joinedDamageTypes]
|
||||
};
|
||||
} else {
|
||||
mainRoll.damageRollData.types[key] = damage;
|
||||
mainRoll.damageRollData.main = secondaryDamage.main;
|
||||
}
|
||||
}
|
||||
|
||||
for (const [key, damage] of Object.entries(secondaryDamage.resources ?? {})) {
|
||||
if (key in mainRoll.damageRollData.resources) {
|
||||
mainRoll.damageRollData.resources[key] = Roll.fromTerms([
|
||||
...baseMainRoll.damageRollData.resources[key].terms,
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...baseSecondaryRoll.damageRollData.resources[key].terms
|
||||
]);
|
||||
|
||||
/* Joining the roll.options of both rolls */
|
||||
const joinedDamageTypes = new Set([
|
||||
...baseMainRoll.damageRollData.resources[key].options.damageTypes,
|
||||
...baseSecondaryRoll.damageRollData.resources[key].options.damageTypes
|
||||
]);
|
||||
mainRoll.damageRollData.resources[key].options = {
|
||||
...baseMainRoll.damageRollData.resources[key].options,
|
||||
damageTypes: [...joinedDamageTypes]
|
||||
};
|
||||
} else {
|
||||
mainRoll.damageRollData.resources[key] = damage;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -727,8 +751,12 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
...mainRoll.options,
|
||||
damage: joinedRoll.damageRollData?.toJSON()
|
||||
};
|
||||
for (const type of Object.keys(joinedRoll.damageRollData?.types ?? {})) {
|
||||
systemData.damage.types[type] = joinedRoll.damageRollData.types[type].toJSON();
|
||||
|
||||
if (joinedRoll.damageRollData.main) {
|
||||
systemData.damage.main = joinedRoll.damageRollData.toJSON();
|
||||
}
|
||||
for (const type of Object.keys(joinedRoll.damageRollData?.resources ?? {})) {
|
||||
systemData.damage.resources[type] = joinedRoll.damageRollData.resources[type].toJSON();
|
||||
}
|
||||
|
||||
const cls = getDocumentClass('ChatMessage'),
|
||||
|
|
|
|||
|
|
@ -13,18 +13,19 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
if (this.damage.includeBase) {
|
||||
const baseDamage = this.getParentHitPointDamage();
|
||||
if (baseDamage) {
|
||||
if (!this.damage.parts.hitPoints) {
|
||||
this.damage.parts.hitPoints = baseDamage;
|
||||
if (!this.damage.main) {
|
||||
this.damage.main = baseDamage;
|
||||
} else {
|
||||
for (const type of baseDamage.type) this.damage.parts.hitPoints.type.add(type);
|
||||
for (const type of baseDamage.type) this.damage.main.type.add(type);
|
||||
|
||||
this.damage.parts.hitPoints.value.custom = {
|
||||
this.damage.main.value.custom = {
|
||||
enabled: true,
|
||||
formula: `${baseDamage.value.getFormula()} + ${this.damage.parts.hitPoints.value.getFormula()}`
|
||||
formula: `${baseDamage.value.getFormula()} + ${this.damage.main.value.getFormula()}`
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.roll.useDefault) {
|
||||
this.roll.trait = this.item.system.attack.roll.trait;
|
||||
this.roll.type = 'attack';
|
||||
|
|
@ -33,18 +34,18 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
}
|
||||
|
||||
getParentHitPointDamage() {
|
||||
return this.item?.system?.attack.damage.parts.hitPoints;
|
||||
return this.item?.system?.attack.damage.main;
|
||||
}
|
||||
|
||||
get damageFormula() {
|
||||
const hitPointsPart = this.damage.parts.hitPoints;
|
||||
const hitPointsPart = this.damage.main;
|
||||
if (!hitPointsPart) return '0';
|
||||
|
||||
return hitPointsPart.value.getFormula();
|
||||
}
|
||||
|
||||
get altDamageFormula() {
|
||||
const hitPointsPart = this.damage.parts.hitPoints;
|
||||
const hitPointsPart = this.damage.main;
|
||||
if (!hitPointsPart) return '0';
|
||||
|
||||
return hitPointsPart.valueAlt.getFormula();
|
||||
|
|
|
|||
|
|
@ -288,7 +288,6 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
hasEffect: this.hasEffect,
|
||||
hasSave: this.hasSave,
|
||||
onSave: this.save?.damageMod,
|
||||
isDirect: !!this.damage?.direct,
|
||||
selectedMessageMode: game.settings.get('core', 'messageMode'),
|
||||
data: this.getRollData(),
|
||||
evaluate: this.hasRoll,
|
||||
|
|
@ -306,20 +305,20 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
};
|
||||
|
||||
if (this.damage) {
|
||||
config.isDirect = this.damage.direct;
|
||||
config.isDirect = !!this.damage.main?.direct;
|
||||
|
||||
const groupAttackTokens = this.damage.groupAttack
|
||||
const groupAttackTokens = this.damage.main?.groupAttack
|
||||
? game.system.api.fields.ActionFields.DamageField.getGroupAttackTokens(
|
||||
this.actor.id,
|
||||
this.damage.groupAttack
|
||||
this.damage.main.groupAttack
|
||||
)
|
||||
: null;
|
||||
|
||||
config.damageOptions = {
|
||||
groupAttack: this.damage.groupAttack
|
||||
groupAttack: this.damage.main?.groupAttack
|
||||
? {
|
||||
numAttackers: Math.max(groupAttackTokens.length, 1),
|
||||
range: this.damage.groupAttack
|
||||
range: this.damage.main.groupAttack
|
||||
}
|
||||
: null
|
||||
};
|
||||
|
|
|
|||
|
|
@ -120,10 +120,8 @@ export default class DamageRoll extends DHRoll {
|
|||
const type = this.options.messageType ?? (this.options.hasHealing ? 'healing' : 'damage');
|
||||
const changeKeys = [];
|
||||
|
||||
for (const roll of this.options.roll) {
|
||||
for (const damageType of roll.damageTypes?.values?.() ?? []) {
|
||||
changeKeys.push(`system.bonuses.${type}.${damageType}`);
|
||||
}
|
||||
for (const damageType of this.options.damageFormula?.damageTypes?.values?.() ?? []) {
|
||||
changeKeys.push(`system.bonuses.${type}.${damageType}`);
|
||||
}
|
||||
|
||||
const item = this.data.parent?.items?.get(this.options.source.item);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue