mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Add Trait choice in roll dialog
This commit is contained in:
parent
b5ba7e7fba
commit
6b7912f3f4
6 changed files with 55 additions and 25 deletions
|
|
@ -2015,6 +2015,7 @@
|
||||||
},
|
},
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"total": "Total",
|
"total": "Total",
|
||||||
|
"traitModifier": "Trait Modifier",
|
||||||
"true": "True",
|
"true": "True",
|
||||||
"type": "Type",
|
"type": "Type",
|
||||||
"unarmed": "Unarmed",
|
"unarmed": "Unarmed",
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { abilities } from "../../config/actorConfig.mjs";
|
||||||
|
|
||||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||||
|
|
||||||
export default class D20RollDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
export default class D20RollDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
|
|
@ -113,15 +115,21 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
context.isLite = this.config.roll?.lite;
|
context.isLite = this.config.roll?.lite;
|
||||||
context.extraFormula = this.config.extraFormula;
|
context.extraFormula = this.config.extraFormula;
|
||||||
context.formula = this.roll.constructFormula(this.config);
|
context.formula = this.roll.constructFormula(this.config);
|
||||||
|
if(this.actor.system.traits) context.abilities = this.getTraitModifiers();
|
||||||
|
|
||||||
context.showReaction = !context.config.roll?.type && context.rollType === 'DualityRoll';
|
context.showReaction = !this.config.roll?.type && context.rollType === 'DualityRoll';
|
||||||
context.reactionOverride = this.reactionOverride;
|
context.reactionOverride = this.reactionOverride;
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTraitModifiers() {
|
||||||
|
return Object.values(abilities).map(a => ({ id: a.id, label: `${game.i18n.localize(a.label)} (${this.actor.system.traits[a.id]?.value.signedString() ?? 0})` }))
|
||||||
|
}
|
||||||
|
|
||||||
static updateRollConfiguration(event, _, formData) {
|
static updateRollConfiguration(event, _, formData) {
|
||||||
const { ...rest } = foundry.utils.expandObject(formData.object);
|
const { ...rest } = foundry.utils.expandObject(formData.object);
|
||||||
|
|
||||||
this.config.selectedRollMode = rest.selectedRollMode;
|
this.config.selectedRollMode = rest.selectedRollMode;
|
||||||
|
|
||||||
if (this.config.costs) {
|
if (this.config.costs) {
|
||||||
|
|
@ -133,6 +141,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
this.roll[key] = value;
|
this.roll[key] = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if(rest.trait) this.config.roll.trait = rest.trait;
|
||||||
this.config.extraFormula = rest.extraFormula;
|
this.config.extraFormula = rest.extraFormula;
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,27 +72,27 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
||||||
if (!this.parent?.actor) return modifiers;
|
if (!this.parent?.actor) return modifiers;
|
||||||
switch (this.parent.actor.type) {
|
switch (this.parent.actor.type) {
|
||||||
case 'character':
|
case 'character':
|
||||||
const spellcastingTrait =
|
// const spellcastingTrait =
|
||||||
this.type === 'spellcast'
|
// this.type === 'spellcast'
|
||||||
? (this.parent.actor?.system?.spellcastModifierTrait?.key ?? 'agility')
|
// ? (this.parent.actor?.system?.spellcastModifierTrait?.key ?? 'agility')
|
||||||
: null;
|
// : null;
|
||||||
const trait =
|
// const trait =
|
||||||
this.useDefault || !this.trait
|
// this.useDefault || !this.trait
|
||||||
? (spellcastingTrait ?? this.parent.item.system.attack?.roll?.trait ?? 'agility')
|
// ? (spellcastingTrait ?? this.parent.item.system.attack?.roll?.trait ?? 'agility')
|
||||||
: this.trait;
|
// : this.trait;
|
||||||
if (
|
// if (
|
||||||
this.type === CONFIG.DH.GENERAL.rollTypes.attack.id ||
|
// this.type === CONFIG.DH.GENERAL.rollTypes.attack.id ||
|
||||||
this.type === CONFIG.DH.GENERAL.rollTypes.trait.id
|
// this.type === CONFIG.DH.GENERAL.rollTypes.trait.id
|
||||||
)
|
// )
|
||||||
modifiers.push({
|
// modifiers.push({
|
||||||
label: `DAGGERHEART.CONFIG.Traits.${trait}.name`,
|
// label: `DAGGERHEART.CONFIG.Traits.${trait}.name`,
|
||||||
value: this.parent.actor.system.traits[trait].value
|
// value: this.parent.actor.system.traits[trait].value
|
||||||
});
|
// });
|
||||||
else if (this.type === CONFIG.DH.GENERAL.rollTypes.spellcast.id)
|
// else if (this.type === CONFIG.DH.GENERAL.rollTypes.spellcast.id)
|
||||||
modifiers.push({
|
// modifiers.push({
|
||||||
label: `DAGGERHEART.CONFIG.RollTypes.spellcast.name`,
|
// label: `DAGGERHEART.CONFIG.RollTypes.spellcast.name`,
|
||||||
value: this.parent.actor.system.spellcastModifier
|
// value: this.parent.actor.system.spellcastModifier
|
||||||
});
|
// });
|
||||||
break;
|
break;
|
||||||
case 'companion':
|
case 'companion':
|
||||||
case 'adversary':
|
case 'adversary':
|
||||||
|
|
@ -107,6 +107,21 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get rollTrait() {
|
||||||
|
if(this.parent?.actor?.type !== "character") return null;
|
||||||
|
switch (this.type) {
|
||||||
|
case CONFIG.DH.GENERAL.rollTypes.spellcast.id:
|
||||||
|
return this.parent.actor?.system?.spellcastModifierTrait?.key ?? 'agility';
|
||||||
|
case CONFIG.DH.GENERAL.rollTypes.attack.id:
|
||||||
|
case CONFIG.DH.GENERAL.rollTypes.trait.id:
|
||||||
|
return this.useDefault || !this.trait
|
||||||
|
? this.parent.item.system.attack?.roll?.trait ?? 'agility'
|
||||||
|
: this.trait;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class RollField extends fields.EmbeddedDataField {
|
export default class RollField extends fields.EmbeddedDataField {
|
||||||
|
|
@ -145,6 +160,7 @@ export default class RollField extends fields.EmbeddedDataField {
|
||||||
baseModifiers: this.roll.getModifier(),
|
baseModifiers: this.roll.getModifier(),
|
||||||
label: 'Attack',
|
label: 'Attack',
|
||||||
type: this.roll?.type,
|
type: this.roll?.type,
|
||||||
|
trait: this.roll?.rollTrait,
|
||||||
difficulty: this.roll?.difficulty,
|
difficulty: this.roll?.difficulty,
|
||||||
formula: this.roll.getFormula(),
|
formula: this.roll.getFormula(),
|
||||||
advantage: CONFIG.DH.ACTIONS.advantageState[this.roll.advState].value
|
advantage: CONFIG.DH.ACTIONS.advantageState[this.roll.advState].value
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,10 @@ export default class DualityRoll extends D20Roll {
|
||||||
|
|
||||||
applyBaseBonus() {
|
applyBaseBonus() {
|
||||||
const modifiers = super.applyBaseBonus();
|
const modifiers = super.applyBaseBonus();
|
||||||
|
|
||||||
if (this.options.roll.trait && this.data.traits[this.options.roll.trait])
|
if (this.options.roll.trait && this.data.traits[this.options.roll.trait])
|
||||||
modifiers.unshift({
|
modifiers.unshift({
|
||||||
label: `DAGGERHEART.CONFIG.Traits.${this.options.roll.trait}.name`,
|
label: this.options.roll.type === CONFIG.DH.GENERAL.rollTypes.spellcast.id ? "DAGGERHEART.CONFIG.RollTypes.spellcast.name" : `DAGGERHEART.CONFIG.Traits.${this.options.roll.trait}.name`,
|
||||||
value: this.data.traits[this.options.roll.trait].value
|
value: this.data.traits[this.options.roll.trait].value
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<fieldset class="flex">
|
<fieldset class="flex">
|
||||||
<legend>{{localize "DAGGERHEART.GENERAL.save"}}</legend>
|
<legend>{{localize "DAGGERHEART.GENERAL.Roll.reaction"}}</legend>
|
||||||
{{formField fields.trait label="Trait" name="save.trait" value=source.trait localize=true}}
|
{{formField fields.trait label="Trait" name="save.trait" value=source.trait localize=true}}
|
||||||
{{formField fields.difficulty label="Difficulty" name="save.difficulty" value=source.difficulty disabled=(not source.trait) placeholder=@root.baseSaveDifficulty}}
|
{{formField fields.difficulty label="Difficulty" name="save.difficulty" value=source.difficulty disabled=(not source.trait) placeholder=@root.baseSaveDifficulty}}
|
||||||
{{formField fields.damageMod label="Damage on Save" name="save.damageMod" value=source.damageMod localize=true disabled=(not source.trait)}}
|
{{formField fields.damageMod label="Damage on Save" name="save.damageMod" value=source.damageMod localize=true disabled=(not source.trait)}}
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,10 @@
|
||||||
{{selectOptions diceOptions selected=@root.roll.dAdvantage.denomination}}
|
{{selectOptions diceOptions selected=@root.roll.dAdvantage.denomination}}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<span>{{localize "DAGGERHEART.GENERAL.traitModifier"}}</span>
|
||||||
|
<select name="trait">
|
||||||
|
{{selectOptions abilities selected=@root.rollConfig.roll.trait valueAttr="id" labelAttr="label" localize=true}}
|
||||||
|
</select>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
{{#if @root.rallyDie.length}}
|
{{#if @root.rallyDie.length}}
|
||||||
<span class="formula-label">{{localize "DAGGERHEART.CLASS.Feature.rallyDice"}}</span>
|
<span class="formula-label">{{localize "DAGGERHEART.CLASS.Feature.rallyDice"}}</span>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue