mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
h
This commit is contained in:
parent
b3984a8e5f
commit
7e382d2e08
9 changed files with 52 additions and 61 deletions
|
|
@ -43,6 +43,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
||||||
|
|
||||||
async _prepareContext(_options) {
|
async _prepareContext(_options) {
|
||||||
const context = await super._prepareContext(_options);
|
const context = await super._prepareContext(_options);
|
||||||
|
context.config = CONFIG.DH;
|
||||||
context.title = this.config.title
|
context.title = this.config.title
|
||||||
? this.config.title
|
? this.config.title
|
||||||
: game.i18n.localize('DAGGERHEART.EFFECTS.ApplyLocations.damageRoll.name');
|
: game.i18n.localize('DAGGERHEART.EFFECTS.ApplyLocations.damageRoll.name');
|
||||||
|
|
@ -55,7 +56,6 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
||||||
label,
|
label,
|
||||||
icon
|
icon
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,7 @@ export class DHDamageData extends DHResourceData {
|
||||||
required: true
|
required: true
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
label: 'Type',
|
label: 'Type'
|
||||||
initial: 'physical'
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,16 +34,10 @@ export default class DHDamageAction extends DHBaseAction {
|
||||||
|
|
||||||
async rollDamage(event, data) {
|
async rollDamage(event, data) {
|
||||||
const systemData = data.system ?? data;
|
const systemData = data.system ?? data;
|
||||||
/* let formula = this.damage.parts.map(p => this.getFormulaValue(p, data).getFormula(this.actor)).join(' + '),
|
|
||||||
damageTypes = [...new Set(this.damage.parts.reduce((a, c) => a.concat([...c.type]), []))];
|
|
||||||
|
|
||||||
damageTypes = !damageTypes.length ? ['physical'] : damageTypes;
|
|
||||||
|
|
||||||
if (!formula || formula == '') return; */
|
|
||||||
|
|
||||||
let formulas = this.damage.parts.map(p => ({
|
let formulas = this.damage.parts.map(p => ({
|
||||||
formula: this.getFormulaValue(p, data).getFormula(this.actor),
|
formula: this.getFormulaValue(p, data).getFormula(this.actor),
|
||||||
damageTypes: p.type,
|
damageTypes: p.applyTo === 'hitPoints' && !p.type.size ? new Set(['physical']) : p.type,
|
||||||
applyTo: p.applyTo
|
applyTo: p.applyTo
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -51,21 +45,14 @@ export default class DHDamageAction extends DHBaseAction {
|
||||||
|
|
||||||
formulas = this.formatFormulas(formulas, systemData);
|
formulas = this.formatFormulas(formulas, systemData);
|
||||||
|
|
||||||
/* let roll = { formula: formula, total: formula };
|
|
||||||
|
|
||||||
if (isNaN(formula)) formula = Roll.replaceFormulaData(formula, this.getRollData(systemData)); */
|
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
title: game.i18n.format('DAGGERHEART.UI.Chat.damageRoll.title', { damage: this.name }),
|
title: game.i18n.format('DAGGERHEART.UI.Chat.damageRoll.title', { damage: this.name }),
|
||||||
// roll: { formula },
|
|
||||||
// roll: { formulas },
|
|
||||||
roll: formulas,
|
roll: formulas,
|
||||||
targets: systemData.targets.filter(t => t.hit) ?? data.targets,
|
targets: systemData.targets.filter(t => t.hit) ?? data.targets,
|
||||||
hasSave: this.hasSave,
|
hasSave: this.hasSave,
|
||||||
isCritical: systemData.roll?.isCritical ?? false,
|
isCritical: systemData.roll?.isCritical ?? false,
|
||||||
source: systemData.source,
|
source: systemData.source,
|
||||||
data: this.getRollData(),
|
data: this.getRollData(),
|
||||||
// damageTypes,
|
|
||||||
event
|
event
|
||||||
};
|
};
|
||||||
if (this.hasSave) config.onSave = this.save.damageMod;
|
if (this.hasSave) config.onSave = this.save.damageMod;
|
||||||
|
|
@ -76,7 +63,6 @@ export default class DHDamageAction extends DHBaseAction {
|
||||||
config.directDamage = true;
|
config.directDamage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// roll = CONFIG.Dice.daggerheart.DamageRoll.build(config);
|
return CONFIG.Dice.daggerheart.DamageRoll.build(config);
|
||||||
CONFIG.Dice.daggerheart.DamageRoll.build(config);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@ export default class DHHealingAction extends DHBaseAction {
|
||||||
formula = formulaValue.getFormula(this.actor);
|
formula = formulaValue.getFormula(this.actor);
|
||||||
|
|
||||||
if (!formula || formula == '') return;
|
if (!formula || formula == '') return;
|
||||||
let roll = { formula: formula, total: formula },
|
let roll = { formula: formula, total: formula };
|
||||||
bonusDamage = [];
|
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
title: game.i18n.format('DAGGERHEART.UI.Chat.healingRoll.title', {
|
title: game.i18n.format('DAGGERHEART.UI.Chat.healingRoll.title', {
|
||||||
healing: game.i18n.localize(CONFIG.DH.GENERAL.healingTypes[this.healing.type].label)
|
healing: game.i18n.localize(CONFIG.DH.GENERAL.healingTypes[this.healing.type].label)
|
||||||
}),
|
}),
|
||||||
roll: { formula },
|
// roll: { formula },
|
||||||
|
roll: [ formula ],
|
||||||
targets: (data.system?.targets ?? data.targets).filter(t => t.hit),
|
targets: (data.system?.targets ?? data.targets).filter(t => t.hit),
|
||||||
messageType: 'healing',
|
messageType: 'healing',
|
||||||
type: this.healing.type,
|
type: this.healing.type,
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,19 @@ export default class DamageRoll extends DHRoll {
|
||||||
|
|
||||||
static DefaultDialog = DamageDialog;
|
static DefaultDialog = DamageDialog;
|
||||||
|
|
||||||
static async postEvaluate(roll, config = {}) {
|
static async buildEvaluate(rolls, config = {}, message = {}) {
|
||||||
super.postEvaluate(roll, config);
|
if ( config.evaluate !== false ) {
|
||||||
config.roll.type = config.type;
|
for ( const roll of config.roll ) await roll.roll.evaluate();
|
||||||
config.roll.modifierTotal = this.calculateTotalModifiers(roll);
|
}
|
||||||
|
config.roll = config.roll.map(r => this.postEvaluate(r.roll));
|
||||||
|
}
|
||||||
|
|
||||||
|
static postEvaluate(roll, config = {}) {
|
||||||
|
return {
|
||||||
|
...super.postEvaluate(roll, config),
|
||||||
|
type: config.type,
|
||||||
|
modifierTotal: this.calculateTotalModifiers(roll)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async buildPost(roll, config, message) {
|
static async buildPost(roll, config, message) {
|
||||||
|
|
@ -75,38 +84,4 @@ export default class DamageRoll extends DHRoll {
|
||||||
}
|
}
|
||||||
return (part.roll._formula = this.constructor.getFormula(part.roll.terms));
|
return (part.roll._formula = this.constructor.getFormula(part.roll.terms));
|
||||||
}
|
}
|
||||||
|
|
||||||
async evaluate({minimize=false, maximize=false, allowStrings=false, allowInteractive=true, ...options}={}) {
|
|
||||||
if ( this._evaluated ) {
|
|
||||||
throw new Error(`The ${this.constructor.name} has already been evaluated and is now immutable`);
|
|
||||||
}
|
|
||||||
this._evaluated = true;
|
|
||||||
if ( CONFIG.debug.dice ) console.debug(`Evaluating roll with formula "${this.formula}"`);
|
|
||||||
|
|
||||||
// Migration path for async rolls
|
|
||||||
if ( "async" in options ) {
|
|
||||||
foundry.utils.logCompatibilityWarning("The async option for Roll#evaluate has been removed. "
|
|
||||||
+ "Use Roll#evaluateSync for synchronous roll evaluation.");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.options.roll.forEach( async part => {
|
|
||||||
await part.roll.evaluate({minimize, maximize, allowStrings, allowInteractive, ...options})
|
|
||||||
})
|
|
||||||
// return this._evaluate({minimize, maximize, allowStrings, allowInteractive});
|
|
||||||
}
|
|
||||||
|
|
||||||
static postEvaluate(roll, config = {}) {
|
|
||||||
if (!config.roll) config.roll = {};
|
|
||||||
config.roll.total = roll.total;
|
|
||||||
config.roll.formula = roll.formula;
|
|
||||||
config.roll.dice = [];
|
|
||||||
roll.dice.forEach(d => {
|
|
||||||
config.roll.dice.push({
|
|
||||||
dice: d.denomination,
|
|
||||||
total: d.total,
|
|
||||||
formula: d.formula,
|
|
||||||
results: d.results
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ export default class DHRoll extends Roll {
|
||||||
|
|
||||||
// Create Chat Message
|
// Create Chat Message
|
||||||
if (config.source?.message) {
|
if (config.source?.message) {
|
||||||
|
if(Array.isArray(config.roll)) {
|
||||||
|
const pool = foundry.dice.terms.PoolTerm.fromRolls(config.roll);
|
||||||
|
roll = Roll.fromTerms([pool]);
|
||||||
|
}
|
||||||
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
|
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
|
||||||
} else {
|
} else {
|
||||||
config.message = await this.toMessage(roll, config);
|
config.message = await this.toMessage(roll, config);
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,15 @@
|
||||||
|
|
||||||
color: light-dark(@dark, @beige);
|
color: light-dark(@dark, @beige);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.damage-formula {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
.damage-details {
|
||||||
|
font-style: italic;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,22 @@
|
||||||
<h1>{{title}}</h1>
|
<h1>{{title}}</h1>
|
||||||
</header>
|
</header>
|
||||||
{{#each @root.formula}}
|
{{#each @root.formula}}
|
||||||
<span class="formula-label"><b>Formula:</b> {{roll.formula}}</span>
|
<div class="damage-formula">
|
||||||
|
<span class="formula-label"><b>Formula:</b> {{roll.formula}}</span>
|
||||||
|
{{!-- <span>{{localize (concat 'CONFIG.DH.GENERAL.healingTypes.' applyTo '.label')}}</span> --}}
|
||||||
|
<span class="damage-details">
|
||||||
|
{{#with (lookup @root.config.GENERAL.healingTypes applyTo)}}
|
||||||
|
{{localize label}}
|
||||||
|
{{/with}}
|
||||||
|
{{#if damageTypes}}
|
||||||
|
{{#each damageTypes as | type | }}
|
||||||
|
{{#with (lookup @root.config.GENERAL.damageTypes type)}}
|
||||||
|
<i class="fa-solid {{icon}}"></i>
|
||||||
|
{{/with}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" value="{{extraFormula}}" name="roll.{{ @index }}.extraFormula" placeholder="Situational Bonus">
|
<input type="text" value="{{extraFormula}}" name="roll.{{ @index }}.extraFormula" placeholder="Situational Bonus">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
|
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
|
||||||
|
{{log damage}}
|
||||||
{{#unless noTitle}}<div class="dice-flavor">{{damage.title}}</div>{{/unless}}
|
{{#unless noTitle}}<div class="dice-flavor">{{damage.title}}</div>{{/unless}}
|
||||||
<div class="dice-result">
|
<div class="dice-result">
|
||||||
<div class="dice-formula">{{damage.roll.formula}}</div>
|
<div class="dice-formula">{{damage.roll.formula}}</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue