mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Moved DamageTypes to roll.options
This commit is contained in:
parent
124c4749db
commit
fbcb9e4572
6 changed files with 72 additions and 76 deletions
|
|
@ -258,9 +258,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
await message.system.damage.rerollDamageDie(damageType, dice, result);
|
||||
await message.update({
|
||||
'system.damage.types': {
|
||||
[damageType]: {
|
||||
roll: message.system.damage.types[damageType].roll.toJSON()
|
||||
}
|
||||
[damageType]: message.system.damage.types[damageType].toJSON()
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -140,9 +140,9 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
const update = { system: { damage: { types: {} } } };
|
||||
for (const key of Object.keys(this.damage.types)) {
|
||||
const type = this.damage.types[key];
|
||||
const reroll = await type.roll.reroll();
|
||||
const reroll = await type.reroll();
|
||||
rerolls.push(reroll);
|
||||
update.system.damage.types[key] = { roll: reroll.toJSON() };
|
||||
update.system.damage.types[key] = reroll.toJSON();
|
||||
}
|
||||
|
||||
await triggerChatRollFx(rerolls);
|
||||
|
|
@ -192,10 +192,15 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
source.damage = {
|
||||
types: Object.keys(source.damage).reduce((acc, key) => {
|
||||
const damageData = source.damage[key];
|
||||
acc[key] = {
|
||||
roll: damageData.parts[0]?.roll ?? null,
|
||||
damageTypes: damageData.parts[0]?.damageTypes ?? []
|
||||
};
|
||||
const oldRoll = damageData.parts[0]?.roll;
|
||||
acc[key] = oldRoll ? {
|
||||
...oldRoll,
|
||||
options: {
|
||||
...oldRoll.options,
|
||||
damageTypes: damageData.parts[0].damageTypes ?? []
|
||||
}
|
||||
} : null;
|
||||
|
||||
return acc;
|
||||
}, {})
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
return {
|
||||
types: new fields.TypedObjectField(new fields.SchemaField({
|
||||
roll: new fields.JSONField({validate: ChatDamageData.#validateRoll}),
|
||||
damageTypes: new fields.ArrayField(new fields.StringField({ choices: CONFIG.DH.GENERAL.damageTypes }))
|
||||
}))
|
||||
types: new fields.TypedObjectField(new fields.JSONField({validate: ChatDamageData.#validateRoll}))
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -31,14 +28,14 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
|||
for (const key of Object.keys(this.types)) {
|
||||
const type = this.types[key];
|
||||
try {
|
||||
type.roll = Roll.fromData(type.roll);
|
||||
type.roll.modifierTotal = CONFIG.Dice.daggerheart.DHRoll.calculateTotalModifiers(type.roll);
|
||||
this.types[key] = Roll.fromData(type);
|
||||
this.types[key].options.modifierTotal = CONFIG.Dice.daggerheart.DHRoll.calculateTotalModifiers(type);
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
async rerollDamageDie(damageType, dice, resultIndex) {
|
||||
const reroll = this.types[damageType].roll;
|
||||
const reroll = this.types[damageType];
|
||||
const rerollDice = reroll.dice[dice];
|
||||
await rerollDice.rerollResult(resultIndex);
|
||||
await reroll._evaluate();
|
||||
|
|
|
|||
|
|
@ -19,12 +19,10 @@ export default class DamageRoll extends DHRoll {
|
|||
|
||||
for (const roll of config.roll) {
|
||||
await roll.roll.evaluate();
|
||||
|
||||
roll.roll.options = { damageTypes: roll.damageTypes ?? [] };
|
||||
|
||||
if (!config.damage?.types) config.damage = { types: {} };
|
||||
config.damage.types[roll.applyTo] = {
|
||||
roll: roll.roll,
|
||||
damageTypes: roll.damageTypes ?? []
|
||||
};
|
||||
config.damage.types[roll.applyTo] = roll.roll;
|
||||
}
|
||||
|
||||
roll._evaluated = true;
|
||||
|
|
|
|||
|
|
@ -1,25 +1,24 @@
|
|||
{{#each damage.types as |damage key|}}
|
||||
{{#each damage.types as |roll key|}}
|
||||
<div class="roll-data {{#if isCritical}}critical{{/if}}">
|
||||
<div class="duality-label">
|
||||
<span>{{localize (concat "DAGGERHEART.CONFIG.HealingType." key ".name")}}:</span>
|
||||
<span>{{damage.roll.total}}</span>
|
||||
</div>
|
||||
{{#with damage.roll}}
|
||||
<div class="roll-dice-container">
|
||||
{{#each this.dice as |dice index|}}
|
||||
<a class="roll-dice" data-action="rerollDamageDice" data-member-key="{{../../../key}}" data-damage-key="{{@../../key}}" data-dice="{{index}}">
|
||||
<span class="dice-label">{{dice.total}}</span>
|
||||
<img src="{{concat "systems/daggerheart/assets/icons/dice/hope/" dice.denomination ".svg"}}" />
|
||||
</a>
|
||||
{{#unless @last}}
|
||||
<span class="roll-operator">+</span>
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{#if this.modifierTotal}}
|
||||
{{#if this.dice.length}}<span class="roll-operator">{{#if (gte this.modifierTotal 0)}}+{{else}}-{{/if}}</span>{{/if}}
|
||||
<span class="roll-value">{{positive this.modifierTotal}}</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/with}}
|
||||
|
||||
<div class="roll-dice-container">
|
||||
{{#each roll.dice as |dice index|}}
|
||||
<a class="roll-dice" data-action="rerollDamageDice" data-member-key="{{../../../key}}" data-damage-key="{{@../../key}}" data-dice="{{index}}">
|
||||
<span class="dice-label">{{dice.total}}</span>
|
||||
<img src="{{concat "systems/daggerheart/assets/icons/dice/hope/" dice.denomination ".svg"}}" />
|
||||
</a>
|
||||
{{#unless @last}}
|
||||
<span class="roll-operator">+</span>
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{#if roll.modifierTotal}}
|
||||
{{#if roll.dice.length}}<span class="roll-operator">{{#if (gte roll.modifierTotal 0)}}+{{else}}-{{/if}}</span>{{/if}}
|
||||
<span class="roll-value">{{positive roll.modifierTotal}}</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
|
@ -10,57 +10,56 @@
|
|||
</div>
|
||||
<div class="roll-part-extra on-reduced">
|
||||
<div class="wrapper">
|
||||
{{#each damage.types as | data index | }}
|
||||
<div class="roll-formula">{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll')}}: {{data.roll.total}}</div>
|
||||
{{#each damage.types as | roll index | }}
|
||||
<div class="roll-formula">{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll')}}: {{roll.total}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="roll-part-content dice-result">
|
||||
<div class="dice-tooltip">
|
||||
<div class="wrapper">
|
||||
{{#each damage.types as | data index | }}
|
||||
{{#each damage.types as | roll index | }}
|
||||
<fieldset>
|
||||
<legend>
|
||||
{{#if ../hasHealing}}{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.name')}}{{else}}{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll')}}{{/if}} <div class="roll-formula">{{localize "DAGGERHEART.GENERAL.total"}}: {{roll.total}}</div>{{#if (and (eq index "hitPoints") ../isDirect)}} <div class="roll-formula">{{localize "DAGGERHEART.CONFIG.DamageType.direct.short"}}</div>{{/if}}
|
||||
</legend>
|
||||
{{#with data.roll}}
|
||||
{{#if (and (not @root.hasHealing) damageTypes.length)}}
|
||||
<label class="roll-part-header"><span>
|
||||
{{#each damageTypes}}
|
||||
{{localize (concat 'DAGGERHEART.CONFIG.ArmorFeature.' this '.name')}}
|
||||
{{#unless @last}}/{{/unless}}
|
||||
{{/each}}
|
||||
<div class="roll-formula">{{total}}</div></span></label>
|
||||
{{/if}}
|
||||
<div class="roll-dice">
|
||||
{{#if dice.length}}
|
||||
{{#each dice}}
|
||||
{{#each results}}
|
||||
{{#if active}}
|
||||
<div class="roll-die{{#unless @../first}} has-plus{{/unless}}">
|
||||
<div
|
||||
class="dice reroll-button {{../dice}}"
|
||||
data-die-index="0" data-type="damage" data-damage-type="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
||||
>
|
||||
{{#if hasRerolls}}<i class="fa-solid fa-dice dice-rerolled" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerolled"}}"></i>{{/if}}
|
||||
{{result}}
|
||||
</div>
|
||||
|
||||
{{#if (and (not @root.hasHealing) roll.options.damageTypes.length)}}
|
||||
<label class="roll-part-header"><span>
|
||||
{{#each roll.options.damageTypes}}
|
||||
{{localize (concat 'DAGGERHEART.CONFIG.ArmorFeature.' this '.name')}}
|
||||
{{#unless @last}}/{{/unless}}
|
||||
{{/each}}
|
||||
<div class="roll-formula">{{roll.total}}</div></span></label>
|
||||
{{/if}}
|
||||
<div class="roll-dice">
|
||||
{{#if roll.dice.length}}
|
||||
{{#each roll.dice}}
|
||||
{{#each results}}
|
||||
{{#if active}}
|
||||
<div class="roll-die{{#unless @../first}} has-plus{{/unless}}">
|
||||
<div
|
||||
class="dice reroll-button {{../dice}}"
|
||||
data-die-index="0" data-type="damage" data-damage-type="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
||||
>
|
||||
{{#if hasRerolls}}<i class="fa-solid fa-dice dice-rerolled" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerolled"}}"></i>{{/if}}
|
||||
{{result}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#if modifierTotal}}
|
||||
<div class="roll-die{{#if (gt modifierTotal 0)}} has-plus{{/if}}">
|
||||
<div class="font-20">{{modifierTotal}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<div class="roll-die">
|
||||
<div class="font-20">{{total}}</div>
|
||||
{{/each}}
|
||||
{{#if roll.modifierTotal}}
|
||||
<div class="roll-die{{#if (gt roll.modifierTotal 0)}} has-plus{{/if}}">
|
||||
<div class="font-20">{{roll.modifierTotal}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/with}}
|
||||
{{else}}
|
||||
<div class="roll-die">
|
||||
<div class="font-20">{{roll.total}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</fieldset>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue