mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
TagTeamDialog fixes to accomodate new flat damage.types structure
This commit is contained in:
parent
fbcb9e4572
commit
c68b3045f2
1 changed files with 9 additions and 10 deletions
|
|
@ -612,14 +612,13 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
async getCriticalDamage(origDamage) {
|
async getCriticalDamage(origDamage) {
|
||||||
const newDamage = origDamage ? ChatDamageData.fromJSON(JSON.stringify(origDamage)) : null;
|
const newDamage = origDamage ? ChatDamageData.fromJSON(JSON.stringify(origDamage)) : null;
|
||||||
for (let key in newDamage?.types ?? {}) {
|
for (let key in newDamage?.types ?? {}) {
|
||||||
const damage = newDamage.types[key];
|
const criticalDamage = await getCritDamageBonus(newDamage.types[key].formula);
|
||||||
const criticalDamage = await getCritDamageBonus(damage.roll.formula);
|
|
||||||
if (!criticalDamage) continue;
|
if (!criticalDamage) continue;
|
||||||
|
|
||||||
const criticalTerm = new foundry.dice.terms.NumericTerm({ number: criticalDamage, evaluated: true });
|
const criticalTerm = new foundry.dice.terms.NumericTerm({ number: criticalDamage, evaluated: true });
|
||||||
criticalTerm.evaluate();
|
criticalTerm.evaluate();
|
||||||
damage.roll = await Roll.fromTerms([
|
newDamage.types[key] = await Roll.fromTerms([
|
||||||
...origDamage.types[key].roll.terms,
|
...origDamage.types[key].terms,
|
||||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||||
criticalTerm
|
criticalTerm
|
||||||
]);
|
]);
|
||||||
|
|
@ -675,10 +674,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
if (mainRoll.damageRollData) {
|
if (mainRoll.damageRollData) {
|
||||||
for (const [key, damage] of Object.entries(secondaryDamage.types ?? {})) {
|
for (const [key, damage] of Object.entries(secondaryDamage.types ?? {})) {
|
||||||
if (key in mainRoll.damageRollData.types) {
|
if (key in mainRoll.damageRollData.types) {
|
||||||
mainRoll.damageRollData.types[key].roll = Roll.fromTerms([
|
mainRoll.damageRollData.types[key] = Roll.fromTerms([
|
||||||
...baseMainRoll.damageRollData.types[key].roll.terms,
|
...baseMainRoll.damageRollData.types[key].terms,
|
||||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||||
...baseSecondaryRoll.damageRollData.types[key].roll.terms
|
...baseSecondaryRoll.damageRollData.types[key].terms
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
mainRoll.damageRollData.types[key] = damage;
|
mainRoll.damageRollData.types[key] = damage;
|
||||||
|
|
@ -744,10 +743,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
/* This could assumably be done better. For some reason rolls don't get correctly done through rollData.toJSON */
|
/* This could assumably be done better. For some reason rolls don't get correctly done through rollData.toJSON */
|
||||||
const systemData = {
|
const systemData = {
|
||||||
...mainRoll.options,
|
...mainRoll.options,
|
||||||
damage: joinedRoll.damageRollData.toJSON()
|
damage: joinedRoll.damageRollData?.toJSON()
|
||||||
};
|
};
|
||||||
for (const type of Object.keys(joinedRoll.damageRollData.types)) {
|
for (const type of Object.keys(joinedRoll.damageRollData?.types ?? {})) {
|
||||||
systemData.damage.types[type].roll = joinedRoll.damageRollData.types[type].roll.toJSON();
|
systemData.damage.types[type] = joinedRoll.damageRollData.types[type].toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
const cls = getDocumentClass('ChatMessage'),
|
const cls = getDocumentClass('ChatMessage'),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue