mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/233 234 235 (#246)
* #233 #234 #235 + Fixes * Fix reaction roll
This commit is contained in:
parent
eb647f1e31
commit
750282aeec
24 changed files with 355 additions and 192 deletions
|
|
@ -192,6 +192,10 @@
|
|||
"Full": "Disadvantage",
|
||||
"Short": "Dis"
|
||||
},
|
||||
"Neutral": {
|
||||
"Full": "None",
|
||||
"Short": "no"
|
||||
},
|
||||
"OK": "OK",
|
||||
"Cancel": "Cancel",
|
||||
"Or": "Or",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
/** NOT USED ANYMORE - TO BE DELETED **/
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class NpcRollSelectionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import DamageDialog from '../dialogs/damageDialog.mjs';
|
|||
*/
|
||||
|
||||
export class DHRoll extends Roll {
|
||||
baseTerms = [];
|
||||
constructor(formula, data, options) {
|
||||
super(formula, data, options);
|
||||
}
|
||||
|
|
@ -37,6 +38,7 @@ export class DHRoll extends Roll {
|
|||
if (config.dialog.configure !== false) {
|
||||
// Open Roll Dialog
|
||||
const DialogClass = config.dialog?.class ?? this.DefaultDialog;
|
||||
console.log(roll, config)
|
||||
const configDialog = await DialogClass.configure(roll, config, message);
|
||||
if (!configDialog) return;
|
||||
}
|
||||
|
|
@ -98,9 +100,27 @@ export class DHRoll extends Roll {
|
|||
config.dialog.configure ??= !(config.event.shiftKey || config.event.altKey || config.event.ctrlKey);
|
||||
}
|
||||
|
||||
formatModifier(modifier) {
|
||||
const numTerm = modifier < 0 ? '-' : '+';
|
||||
return [
|
||||
new foundry.dice.terms.OperatorTerm({ operator: numTerm }),
|
||||
new foundry.dice.terms.NumericTerm({ number: Math.abs(modifier) })
|
||||
];
|
||||
}
|
||||
|
||||
getFaces(faces) {
|
||||
return Number((faces.startsWith('d') ? faces.replace('d', '') : faces));
|
||||
}
|
||||
|
||||
constructFormula(config) {
|
||||
// const formula = Roll.replaceFormulaData(this.options.roll.formula, config.data);
|
||||
this.terms = Roll.parse(this.options.roll.formula, config.data);
|
||||
|
||||
if (this.options.extraFormula) {
|
||||
this.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...this.constructor.parse(this.options.extraFormula, this.options.data)
|
||||
);
|
||||
}
|
||||
return (this._formula = this.constructor.getFormula(this.terms));
|
||||
}
|
||||
}
|
||||
|
|
@ -112,12 +132,9 @@ export class DualityDie extends foundry.dice.terms.Die {
|
|||
}
|
||||
|
||||
export class D20Roll extends DHRoll {
|
||||
|
||||
constructor(formula, data = {}, options = {}) {
|
||||
super(formula, data, options);
|
||||
// this.createBaseDice();
|
||||
// this.configureModifiers();
|
||||
|
||||
// this._formula = this.resetFormula();
|
||||
this.constructFormula();
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +157,7 @@ export class D20Roll extends DHRoll {
|
|||
|
||||
set d20(faces) {
|
||||
if (!(this.terms[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||
this.terms[0].faces = faces;
|
||||
this.terms[0].faces = this.getFaces(faces);
|
||||
}
|
||||
|
||||
get dAdvantage() {
|
||||
|
|
@ -153,11 +170,11 @@ export class D20Roll extends DHRoll {
|
|||
}
|
||||
|
||||
get hasAdvantage() {
|
||||
return this.options.advantage === this.constructor.ADV_MODE.ADVANTAGE;
|
||||
return this.options.roll.advantage === this.constructor.ADV_MODE.ADVANTAGE;
|
||||
}
|
||||
|
||||
get hasDisadvantage() {
|
||||
return this.options.advantage === this.constructor.ADV_MODE.DISADVANTAGE;
|
||||
return this.options.roll.advantage === this.constructor.ADV_MODE.DISADVANTAGE;
|
||||
}
|
||||
|
||||
static applyKeybindings(config) {
|
||||
|
|
@ -171,18 +188,55 @@ export class D20Roll extends DHRoll {
|
|||
config.dialog.configure ??= !Object.values(keys).some(k => k);
|
||||
|
||||
// Determine advantage mode
|
||||
const advantage = config.advantage || keys.advantage;
|
||||
const disadvantage = config.disadvantage || keys.disadvantage;
|
||||
if (advantage && !disadvantage) config.advantage = this.ADV_MODE.ADVANTAGE;
|
||||
else if (!advantage && disadvantage) config.advantage = this.ADV_MODE.DISADVANTAGE;
|
||||
else config.advantage = this.ADV_MODE.NORMAL;
|
||||
const advantage = config.roll.advantage === this.ADV_MODE.ADVANTAGE || keys.advantage;
|
||||
const disadvantage = config.roll.advantage === this.ADV_MODE.DISADVANTAGE || keys.disadvantage;
|
||||
if (advantage && !disadvantage) config.roll.advantage = this.ADV_MODE.ADVANTAGE;
|
||||
else if (!advantage && disadvantage) config.roll.advantage = this.ADV_MODE.DISADVANTAGE;
|
||||
else config.roll.advantage = this.ADV_MODE.NORMAL;
|
||||
}
|
||||
|
||||
constructFormula(config) {
|
||||
// this.terms = [];
|
||||
this.createBaseDice();
|
||||
this.configureModifiers();
|
||||
this.resetFormula();
|
||||
return this._formula;
|
||||
}
|
||||
|
||||
createBaseDice() {
|
||||
if (this.terms[0] instanceof foundry.dice.terms.Die) return;
|
||||
if (this.terms[0] instanceof foundry.dice.terms.Die) {
|
||||
this.terms = [this.terms[0]];
|
||||
return;
|
||||
}
|
||||
this.terms[0] = new foundry.dice.terms.Die({ faces: 20 });
|
||||
}
|
||||
|
||||
configureModifiers() {
|
||||
this.applyAdvantage();
|
||||
this.applyBaseBonus();
|
||||
|
||||
this.options.experiences?.forEach(m => {
|
||||
if (this.options.data.experiences?.[m])
|
||||
this.options.roll.modifiers.push({
|
||||
label: this.options.data.experiences[m].name,
|
||||
value: this.options.data.experiences[m].total ?? this.options.data.experiences[m].value
|
||||
});
|
||||
});
|
||||
|
||||
this.options.roll.modifiers?.forEach(m => {
|
||||
this.terms.push(...this.formatModifier(m.value));
|
||||
});
|
||||
|
||||
this.baseTerms = foundry.utils.deepClone(this.terms);
|
||||
|
||||
if (this.options.extraFormula) {
|
||||
this.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...this.constructor.parse(this.options.extraFormula, this.options.data)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
applyAdvantage() {
|
||||
this.d20.modifiers.findSplice(m => ['kh', 'kl'].includes(m));
|
||||
if (!this.hasAdvantage && !this.hasDisadvantage) this.number = 1;
|
||||
|
|
@ -192,47 +246,16 @@ export class D20Roll extends DHRoll {
|
|||
}
|
||||
}
|
||||
|
||||
// Trait bonus != Adversary
|
||||
configureModifiers() {
|
||||
this.applyAdvantage();
|
||||
// this.options.roll.modifiers = [];
|
||||
this.applyBaseBonus();
|
||||
|
||||
this.options.experiences?.forEach(m => {
|
||||
if (this.options.data.experiences?.[m])
|
||||
this.options.roll.modifiers.push({
|
||||
label: this.options.data.experiences[m].name,
|
||||
value: this.options.data.experiences[m].total ?? this.options.data.experiences[m].value
|
||||
});
|
||||
});
|
||||
this.options.roll.modifiers?.forEach(m => {
|
||||
this.terms.push(...this.formatModifier(m.value));
|
||||
});
|
||||
|
||||
if (this.options.extraFormula) {
|
||||
this.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...this.constructor.parse(this.options.extraFormula, this.getRollData())
|
||||
);
|
||||
}
|
||||
// this.resetFormula();
|
||||
}
|
||||
|
||||
constructFormula(config) {
|
||||
this.terms = [];
|
||||
this.createBaseDice();
|
||||
this.configureModifiers();
|
||||
this.resetFormula();
|
||||
return this._formula;
|
||||
}
|
||||
|
||||
applyBaseBonus() {
|
||||
this.options.roll.modifiers = [
|
||||
this.options.roll.modifiers = [];
|
||||
if(!this.options.roll.bonus) return;
|
||||
this.options.roll.modifiers.push(
|
||||
{
|
||||
label: 'Bonus to Hit',
|
||||
value: Roll.replaceFormulaData('@attackBonus', this.data)
|
||||
value: this.options.roll.bonus
|
||||
// value: Roll.replaceFormulaData('@attackBonus', this.data)
|
||||
}
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
|
|
@ -242,26 +265,22 @@ export class D20Roll extends DHRoll {
|
|||
const difficulty = config.roll.difficulty ?? target.difficulty ?? target.evasion;
|
||||
target.hit = this.isCritical || roll.total >= difficulty;
|
||||
});
|
||||
} else if (config.roll.difficulty)
|
||||
config.roll.success = roll.isCritical || roll.total >= config.roll.difficulty;
|
||||
} else if (config.roll.difficulty) config.roll.success = roll.isCritical || roll.total >= config.roll.difficulty;
|
||||
config.roll.advantage = {
|
||||
type: config.advantage,
|
||||
type: config.roll.advantage,
|
||||
dice: roll.dAdvantage?.denomination,
|
||||
value: roll.dAdvantage?.total
|
||||
};
|
||||
config.roll.modifierTotal = config.roll.modifiers.reduce((a, c) => a + Number(c.value), 0);
|
||||
config.roll.extra = roll.dice.filter(d => !roll.baseTerms.includes(d)).map(d => {
|
||||
return {
|
||||
dice: d.denomination,
|
||||
value: d.total
|
||||
}
|
||||
|
||||
getRollData() {
|
||||
return this.options.data;
|
||||
})
|
||||
config.roll.modifierTotal = 0;
|
||||
for(let i = 0; i < roll.terms.length; i++) {
|
||||
if(roll.terms[i] instanceof foundry.dice.terms.NumericTerm && !!roll.terms[i-1] && roll.terms[i-1] instanceof foundry.dice.terms.OperatorTerm) config.roll.modifierTotal += Number(`${roll.terms[i-1].operator}${roll.terms[i].total}`);
|
||||
}
|
||||
|
||||
formatModifier(modifier) {
|
||||
const numTerm = modifier < 0 ? '-' : '+';
|
||||
return [
|
||||
new foundry.dice.terms.OperatorTerm({ operator: numTerm }),
|
||||
new foundry.dice.terms.NumericTerm({ number: Math.abs(modifier) })
|
||||
];
|
||||
}
|
||||
|
||||
resetFormula() {
|
||||
|
|
@ -270,6 +289,8 @@ export class D20Roll extends DHRoll {
|
|||
}
|
||||
|
||||
export class DualityRoll extends D20Roll {
|
||||
_advantageFaces = 6;
|
||||
|
||||
constructor(formula, data = {}, options = {}) {
|
||||
super(formula, data, options);
|
||||
}
|
||||
|
|
@ -287,7 +308,7 @@ export class DualityRoll extends D20Roll {
|
|||
|
||||
set dHope(faces) {
|
||||
if (!(this.dice[0] instanceof CONFIG.Dice.daggerheart.DualityDie)) this.createBaseDice();
|
||||
this.terms[0].faces = faces;
|
||||
this.terms[0].faces = this.getFaces(faces);
|
||||
// this.#hopeDice = `d${face}`;
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +321,7 @@ export class DualityRoll extends D20Roll {
|
|||
|
||||
set dFear(faces) {
|
||||
if (!(this.dice[1] instanceof CONFIG.Dice.daggerheart.DualityDie)) this.createBaseDice();
|
||||
this.dice[1].faces = faces;
|
||||
this.dice[1].faces = this.getFaces(faces);
|
||||
// this.#fearDice = `d${face}`;
|
||||
}
|
||||
|
||||
|
|
@ -308,6 +329,14 @@ export class DualityRoll extends D20Roll {
|
|||
return this.dice[2];
|
||||
}
|
||||
|
||||
get advantageFaces() {
|
||||
return this._advantageFaces;
|
||||
}
|
||||
|
||||
set advantageFaces(faces) {
|
||||
this._advantageFaces = this.getFaces(faces);
|
||||
}
|
||||
|
||||
get isCritical() {
|
||||
if (!this.dHope._evaluated || !this.dFear._evaluated) return;
|
||||
return this.dHope.total === this.dFear.total;
|
||||
|
|
@ -337,25 +366,25 @@ export class DualityRoll extends D20Roll {
|
|||
return game.i18n.localize(label);
|
||||
}
|
||||
|
||||
updateFormula() {
|
||||
|
||||
}
|
||||
|
||||
createBaseDice() {
|
||||
if (
|
||||
this.dice[0] instanceof CONFIG.Dice.daggerheart.DualityDie &&
|
||||
this.dice[1] instanceof CONFIG.Dice.daggerheart.DualityDie
|
||||
)
|
||||
if (this.dice[0] instanceof CONFIG.Dice.daggerheart.DualityDie && this.dice[1] instanceof CONFIG.Dice.daggerheart.DualityDie) {
|
||||
this.terms = [this.terms[0], this.terms[1], this.terms[2]];
|
||||
return;
|
||||
if (!(this.dice[0] instanceof CONFIG.Dice.daggerheart.DualityDie))
|
||||
}
|
||||
this.terms[0] = new CONFIG.Dice.daggerheart.DualityDie();
|
||||
this.terms[1] = new foundry.dice.terms.OperatorTerm({ operator: '+' });
|
||||
if (!(this.dice[2] instanceof CONFIG.Dice.daggerheart.DualityDie))
|
||||
this.terms[2] = new CONFIG.Dice.daggerheart.DualityDie();
|
||||
}
|
||||
|
||||
applyAdvantage() {
|
||||
const dieFaces = 6,
|
||||
const dieFaces = this.advantageFaces,
|
||||
bardRallyFaces = this.hasBarRally,
|
||||
advDie = new foundry.dice.terms.Die({ faces: dieFaces });
|
||||
if (this.hasAdvantage || this.hasDisadvantage || bardRallyFaces)
|
||||
this.terms.push(new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }));
|
||||
if (this.hasAdvantage || this.hasDisadvantage || bardRallyFaces) this.terms.push(new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }));
|
||||
if (bardRallyFaces) {
|
||||
const rallyDie = new foundry.dice.terms.Die({ faces: bardRallyFaces });
|
||||
if (this.hasAdvantage) {
|
||||
|
|
@ -372,12 +401,14 @@ export class DualityRoll extends D20Roll {
|
|||
}
|
||||
|
||||
applyBaseBonus() {
|
||||
this.options.roll.modifiers = [
|
||||
this.options.roll.modifiers = [];
|
||||
if(!this.options.roll.trait) return;
|
||||
this.options.roll.modifiers.push(
|
||||
{
|
||||
label: `DAGGERHEART.Abilities.${this.options.roll.trait}.name`,
|
||||
value: Roll.replaceFormulaData(`@traits.${this.options.roll.trait}.total`, this.data)
|
||||
}
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
/** NOT USED ANYMORE - TO BE DELETED **/
|
||||
|
||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class RollSelectionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
event: event,
|
||||
title: `${this.actor.name} - Reaction Roll`,
|
||||
roll: {
|
||||
modifier: null,
|
||||
// modifier: null,
|
||||
type: 'reaction'
|
||||
},
|
||||
chatMessage: {
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl
|
|||
context.systemFields = this.actor.system.schema.fields;
|
||||
context.systemFields.attack.fields = this.actor.system.attack.schema.fields;
|
||||
context.isNPC = true;
|
||||
console.log(context)
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,3 +105,18 @@ export const diceCompare = {
|
|||
operator: '>'
|
||||
}
|
||||
};
|
||||
|
||||
export const advandtageState = {
|
||||
disadvantage: {
|
||||
label: 'DAGGERHEART.General.Disadvantage.Full',
|
||||
value: -1
|
||||
},
|
||||
neutral: {
|
||||
label: 'DAGGERHEART.General.Neutral.Full',
|
||||
value: 0
|
||||
},
|
||||
advantage: {
|
||||
label: 'DAGGERHEART.General.Advantage.Full',
|
||||
value: 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import CostSelectionDialog from '../../applications/costSelectionDialog.mjs';
|
||||
import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs';
|
||||
import DhpActor from '../../documents/actor.mjs';
|
||||
import D20RollDialog from '../../dialogs/d20RollDialog.mjs';
|
||||
|
|
@ -343,7 +342,9 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
label: 'Attack',
|
||||
type: this.actionType,
|
||||
difficulty: this.roll?.difficulty,
|
||||
formula: this.roll.getFormula()
|
||||
formula: this.roll.getFormula(),
|
||||
bonus: this.roll.bonus,
|
||||
advantage: SYSTEM.ACTIONS.advandtageState[this.roll.advState].value
|
||||
};
|
||||
if (this.roll?.type === 'diceSet') roll.lite = true;
|
||||
|
||||
|
|
@ -372,7 +373,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
|
||||
/* ROLL */
|
||||
get hasRoll() {
|
||||
return !!this.roll?.type;
|
||||
return !!this.roll?.type || !!this.roll?.bonus;
|
||||
}
|
||||
/* ROLL */
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
type: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.GENERAL.rollTypes }),
|
||||
trait: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.ACTOR.abilities }),
|
||||
difficulty: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
|
||||
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
|
||||
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true }),
|
||||
advState: new fields.StringField({ choices: SYSTEM.ACTIONS.advandtageState, initial: 'neutral' }),
|
||||
diceRolling: new fields.SchemaField({
|
||||
multiplier: new fields.StringField({
|
||||
choices: SYSTEM.GENERAL.diceSetNumbers,
|
||||
|
|
@ -62,7 +63,7 @@ export class DHActionDiceData extends foundry.abstract.DataModel {
|
|||
label: 'Multiplier'
|
||||
}),
|
||||
flatMultiplier: new fields.NumberField({ nullable: true, initial: 1, label: 'Flat Multiplier' }),
|
||||
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Formula' }),
|
||||
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Dice' }),
|
||||
bonus: new fields.NumberField({ nullable: true, initial: null, label: 'Bonus' }),
|
||||
custom: new fields.SchemaField({
|
||||
enabled: new fields.BooleanField({ label: 'Custom Formula' }),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { actionsTypes } from '../action/_module.mjs';
|
||||
// import { actionsTypes } from '../action/_module.mjs';
|
||||
|
||||
// Temporary Solution
|
||||
export default class ActionField extends foundry.data.fields.ObjectField {
|
||||
getModel(value) {
|
||||
return actionsTypes[value.type] ?? actionsTypes.attack;
|
||||
return game.system.api.models.actionsTypes[value.type] ?? game.system.api.models.actionsTypes.attack;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { actionsTypes } from '../action/_module.mjs';
|
||||
// import { actionsTypes } from '../action/_module.mjs';
|
||||
|
||||
/**
|
||||
* Describes metadata about the item data model type
|
||||
|
|
@ -60,7 +60,8 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
const actionType = {
|
||||
weapon: 'attack'
|
||||
}[this.constructor.metadata.type],
|
||||
cls = actionsTypes.attack,
|
||||
cls = game.system.api.models.actionsTypes[actionType],
|
||||
// cls = actionsTypes.attack,
|
||||
action = new cls(
|
||||
{
|
||||
_id: foundry.utils.randomID(),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
this.config.experiences = [];
|
||||
|
||||
if (config.source?.action) {
|
||||
this.item = config.data.parent.items.get(config.source.item);
|
||||
console.log(config)
|
||||
this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent;
|
||||
this.action =
|
||||
config.data.attack?._id == config.source.action
|
||||
? config.data.attack
|
||||
|
|
@ -50,15 +51,18 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
console.log(this.config, this.roll)
|
||||
const context = await super._prepareContext(_options);
|
||||
context.hasRoll = !!this.config.roll;
|
||||
context.roll = this.roll;
|
||||
context.rollType = this.roll?.constructor.name;
|
||||
context.experiences = Object.keys(this.config.data.experiences).map(id => ({
|
||||
id,
|
||||
...this.config.data.experiences[id]
|
||||
}));
|
||||
context.selectedExperiences = this.config.experiences;
|
||||
context.advantage = this.config.advantage;
|
||||
/* context.diceOptions = this.diceOptions; */
|
||||
context.advantage = this.config.roll?.advantage;
|
||||
context.diceOptions = SYSTEM.GENERAL.diceTypes;
|
||||
context.canRoll = true;
|
||||
context.isLite = this.config.roll?.lite;
|
||||
if (this.config.costs?.length) {
|
||||
|
|
@ -71,7 +75,9 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
context.uses = this.action.calcUses(this.config.uses);
|
||||
context.canRoll = context.canRoll && this.action.hasUses(context.uses);
|
||||
}
|
||||
context.extraFormula = this.config.extraFormula;
|
||||
context.formula = this.roll.constructFormula(this.config);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
@ -81,12 +87,18 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
this.config.costs = foundry.utils.mergeObject(this.config.costs, rest.costs);
|
||||
}
|
||||
if (this.config.uses) this.config.uses = foundry.utils.mergeObject(this.config.uses, rest.uses);
|
||||
if(rest.roll?.dice) {
|
||||
Object.entries(rest.roll.dice).forEach(([key, value]) => {
|
||||
this.roll[key] = value;
|
||||
})
|
||||
}
|
||||
this.config.extraFormula = rest.extraFormula;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static updateIsAdvantage(_, button) {
|
||||
const advantage = Number(button.dataset.advantage);
|
||||
this.config.advantage = this.config.advantage === advantage ? 0 : advantage;
|
||||
this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage;
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,17 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.title = this.config.title;
|
||||
context.formula = this.config.roll.formula;
|
||||
context.extraFormula = this.config.extraFormula;
|
||||
context.formula = this.roll.constructFormula(this.config);;
|
||||
return context;
|
||||
}
|
||||
|
||||
static updateRollConfiguration(event, _, formData) {
|
||||
const { ...rest } = foundry.utils.expandObject(formData.object);
|
||||
this.config.extraFormula = rest.extraFormula;
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async submitRoll() {
|
||||
await this.close({ submitted: true });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -493,8 +493,9 @@ fieldset.daggerheart.chat {
|
|||
align-items: end;
|
||||
gap: 0.25rem;
|
||||
.dice {
|
||||
.dice-rolls.duality {
|
||||
.dice-rolls {
|
||||
margin-bottom: 0;
|
||||
&.duality {
|
||||
li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -506,6 +507,7 @@ fieldset.daggerheart.chat {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.duality-modifier {
|
||||
display: flex;
|
||||
margin-bottom: 6px;
|
||||
|
|
|
|||
|
|
@ -1786,7 +1786,7 @@ fieldset.daggerheart.chat .daggerheart.chat {
|
|||
align-items: end;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
.theme-colorful .chat-message.duality .message-content .dice-result .dice-tooltip .wrapper .tooltip-part .dice .dice-rolls.duality {
|
||||
.theme-colorful .chat-message.duality .message-content .dice-result .dice-tooltip .wrapper .tooltip-part .dice .dice-rolls {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.theme-colorful .chat-message.duality .message-content .dice-result .dice-tooltip .wrapper .tooltip-part .dice .dice-rolls.duality li {
|
||||
|
|
@ -5376,6 +5376,18 @@ div.daggerheart.views.multiclass {
|
|||
display: flex;
|
||||
gap: 20px;
|
||||
}
|
||||
.application.dh-style fieldset.flex.wrap {
|
||||
flex-wrap: wrap;
|
||||
gap: 10px 20px;
|
||||
}
|
||||
.application.dh-style fieldset.flex .inline-child {
|
||||
flex: 1;
|
||||
}
|
||||
.application.dh-style fieldset.flex .checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
.application.dh-style fieldset.one-column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
|||
|
|
@ -119,6 +119,18 @@
|
|||
&.flex {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
&.wrap {
|
||||
flex-wrap: wrap;
|
||||
gap: 10px 20px;
|
||||
}
|
||||
.inline-child {
|
||||
flex: 1;
|
||||
}
|
||||
.checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
&.one-column {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<div class="wrapper">
|
||||
<section class="tooltip-part">
|
||||
<div class="dice">
|
||||
{{#each roll.dice}}
|
||||
{{#each roll.dice as | dice index |}}
|
||||
<header class="part-header flexrow">
|
||||
<span class="part-formula">{{formula}}</span>
|
||||
<span class="part-total">{{total}}</span>
|
||||
|
|
@ -17,9 +17,11 @@
|
|||
<li class="roll die {{../dice}}{{#if discarded}} discarded{{/if}} min">{{result}}</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
{{#if (eq index 0)}}
|
||||
<div class="attack-roll-advantage-container">
|
||||
{{#if (eq ../roll.advantage.type 1)}}{{localize "DAGGERHEART.General.Advantage.Full"}}{{/if}}{{#if (eq ../roll.advantage.type -1)}}{{localize "DAGGERHEART.General.Disadvantage.Full"}}{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -82,6 +82,30 @@
|
|||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#each roll.extra as | extra | }}
|
||||
<div class="dice">
|
||||
<header class="part-header flexrow">
|
||||
<span class="part-formula">
|
||||
<span>1{{extra.dice}}</span>
|
||||
</span>
|
||||
<span class="part-total">{{extra.value}}</span>
|
||||
</header>
|
||||
<div class="flexrow">
|
||||
<ol class="dice-rolls">
|
||||
<li class="roll die {{extra.dice}}">
|
||||
<div class="dice-container">
|
||||
<div class="dice-inner-container">
|
||||
<div class="dice-wrapper">
|
||||
<img class="dice" src="../icons/svg/{{extra.dice}}-grey.svg"/>
|
||||
</div>
|
||||
<div class="dice-value">{{extra.value}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#if roll.modifierTotal}}<div class="duality-modifier">{{#if (gt roll.modifierTotal 0)}}+{{/if}}{{roll.modifierTotal}}</div>{{/if}}
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
<section
|
||||
class='tab {{tabs.attack.cssClass}} {{tabs.attack.id}}'
|
||||
data-tab='{{tabs.attack.id}}'
|
||||
data-group='{{tabs.attack.group}}'
|
||||
class="tab {{tabs.attack.cssClass}} {{tabs.attack.id}}"
|
||||
data-tab="{{tabs.attack.id}}"
|
||||
data-group="{{tabs.attack.group}}"
|
||||
>
|
||||
<fieldset class="one-column">
|
||||
<legend>{{localize 'DAGGERHEART.General.basics'}}</legend>
|
||||
{{formGroup systemFields.attack.fields.img value=document.img label="Image Path" name="system.attack.img"}}
|
||||
<legend>{{localize "DAGGERHEART.General.basics"}}</legend>
|
||||
{{formGroup systemFields.attack.fields.img value=document.system.attack.img label="Image Path" name="system.attack.img"}}
|
||||
{{formGroup systemFields.attack.fields.name value=document.system.attack.name label="Attack Name" name="system.attack.name"}}
|
||||
</fieldset>
|
||||
<fieldset class="flex">
|
||||
<legend>{{localize "DAGGERHEART.Sheets.Adversary.Attack"}}</legend>
|
||||
{{formField systemFields.attack.fields.roll.fields.bonus value=document.system.attack.roll.bonus label="Attack Bonus" name="system.attack.roll.bonus"}}
|
||||
{{formField systemFields.attack.fields.range value=document.system.attack.range label="Range" name=(concat path "range") localize=true}}
|
||||
{{formField systemFields.attack.fields.range value=document.system.attack.range label="Range" name="system.attack.range" localize=true}}
|
||||
{{#if systemFields.attack.fields.target.fields}}
|
||||
{{#if (and document.system.target.type (not (eq document.system.target.type 'self')))}}
|
||||
{{ formField systemFields.attack.fields.target.fields.amount value=document.system.target.amount label="Amount" name=(concat path "target.amount") }}
|
||||
{{ formField systemFields.attack.fields.target.fields.type value=document.system.attack.target.type label="Target" name="system.attack.target.type" localize=true }}
|
||||
{{#if (and document.system.attack.target.type (not (eq document.system.attack.target.type 'self')))}}
|
||||
{{ formField systemFields.attack.fields.target.fields.amount value=document.system.attack.target.amount label="Amount" name="system.attack.target.amount" }}
|
||||
{{/if}}
|
||||
{{ formField systemFields.attack.fields.target.fields.type value=document.system.target.type label="Target" name=(concat path "target.type") localize=true }}
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
{{> 'systems/daggerheart/templates/views/actionTypes/damage.hbs' fields=systemFields.attack.fields.damage.fields.parts.element.fields source=document.system.attack.damage path="system.attack."}}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,8 @@
|
|||
</fieldset>
|
||||
</div>
|
||||
<div class="tab {{this.tabs.config.cssClass}}" data-group="primary" data-tab="config">
|
||||
{{#unless isNPC}}
|
||||
{{> 'systems/daggerheart/templates/views/actionTypes/uses.hbs' fields=fields.uses.fields source=source.uses}}
|
||||
{{> 'systems/daggerheart/templates/views/actionTypes/cost.hbs' fields=fields.cost.element.fields source=source.cost}}
|
||||
{{/unless}}
|
||||
{{#if fields.target}}{{> 'systems/daggerheart/templates/views/actionTypes/range-target.hbs' fields=(object range=fields.range target=fields.target.fields) source=(object target=source.target range=source.range)}}{{/if}}
|
||||
</div>
|
||||
<div class="tab {{this.tabs.effect.cssClass}}" data-group="primary" data-tab="effect">
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
<fieldset class="action-category">
|
||||
<legend class="action-category-label" data-action="toggleSection" data-section="effects">
|
||||
<div>Damage</div>
|
||||
</legend>
|
||||
<div class="action-category-data open">
|
||||
{{#unless @root.isNPC}}
|
||||
<fieldset class="flex wrap">
|
||||
<legend>Damage</legend>
|
||||
{{#unless (eq path 'system.attack.')}}
|
||||
<div class="fas fa-plus icon-button" data-action="addDamage"></div>
|
||||
{{/unless}}
|
||||
{{#unless @root.isNPC}}
|
||||
{{#if @root.hasBaseDamage}}
|
||||
<div>
|
||||
{{formField @root.fields.damage.fields.includeBase value=@root.source.damage.includeBase label="Include Item Damage" name="damage.includeBase" }}
|
||||
|
|
@ -14,16 +13,14 @@
|
|||
{{/unless}}
|
||||
{{#each source.parts as |dmg index|}}
|
||||
{{#if @root.isNPC}}
|
||||
{{formField ../fields.value.fields.custom.fields.enabled value=dmg.value.custom.enabled name=(concat ../path "damage.parts." index ".value.custom.enabled")}}
|
||||
{{formField ../fields.value.fields.custom.fields.enabled value=dmg.value.custom.enabled name=(concat ../path "damage.parts." index ".value.custom.enabled") classes="checkbox"}}
|
||||
<input type="hidden" name="{{../path}}damage.parts.{{index}}.value.multiplier" value="{{dmg.value.multiplier}}">
|
||||
{{#if dmg.value.custom.enabled}}
|
||||
{{formField ../fields.value.fields.custom.fields.formula value=dmg.value.custom.formula name=(concat ../path "damage.parts." index ".value.custom.formula") localize=true}}
|
||||
{{else}}
|
||||
<div class="multi-display">
|
||||
{{formField ../fields.value.fields.flatMultiplier value=dmg.value.flatMultiplier name=(concat ../path "damage.parts." index ".value.flatMultiplier") label="Multiplier" }}
|
||||
{{formField ../fields.value.fields.dice value=dmg.value.dice name=(concat ../path "damage.parts." index ".value.dice")}}
|
||||
{{formField ../fields.value.fields.bonus value=dmg.value.bonus name=(concat ../path "damage.parts." index ".value.bonus") localize=true}}
|
||||
</div>
|
||||
{{formField ../fields.value.fields.flatMultiplier value=dmg.value.flatMultiplier name=(concat ../path "damage.parts." index ".value.flatMultiplier") label="Multiplier" classes="inline-child" }}
|
||||
{{formField ../fields.value.fields.dice value=dmg.value.dice name=(concat ../path "damage.parts." index ".value.dice") classes="inline-child"}}
|
||||
{{formField ../fields.value.fields.bonus value=dmg.value.bonus name=(concat ../path "damage.parts." index ".value.bonus") localize=true classes="inline-child"}}
|
||||
{{/if}}
|
||||
{{formField ../fields.type value=dmg.type name=(concat ../path "damage.parts." index ".type") localize=true}}
|
||||
{{else}}
|
||||
|
|
@ -55,7 +52,6 @@
|
|||
{{/with}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{{#*inline "formula"}}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,8 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#unless (eq source.type "diceSet")}}
|
||||
{{formField fields.advState label= "Advantage State" name="roll.advState" value=source.advState localize=true}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
@ -2,7 +2,11 @@
|
|||
<div class="form-group">
|
||||
<label><strong>{{title}}</strong></label>
|
||||
<div class="form-fields">
|
||||
<input type="text" value="{{formula}}" disabled />
|
||||
{{!-- <input type="text" value="{{formula}}" disabled /> --}}
|
||||
<div>{{@root.formula}}</div>
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" value="{{extraFormula}}" name="extraFormula" placeholder="Situational Bonus">
|
||||
</div>
|
||||
</div>
|
||||
{{!-- {{#each bonusDamage as |damage index|}}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
{{#if @root.hasRoll}}
|
||||
<div class="roll-dialog-container">
|
||||
<div class="flexcol">
|
||||
<div>
|
||||
{{!-- <input type="text" value="{{@root.formula}}" disabled> --}}
|
||||
<div>{{@root.formula}}</div>
|
||||
</div>
|
||||
{{#unless @root.isLite}}
|
||||
<div class="roll-dialog-experience-container">
|
||||
{{#each experiences}}
|
||||
|
|
@ -17,10 +21,39 @@
|
|||
<button class="disadvantage flex1 {{#if (eq advantage 1)}}selected{{/if}}" data-action="updateIsAdvantage" data-advantage="1">{{localize "DAGGERHEART.General.Advantage.Full"}}</button>
|
||||
<button class="disadvantage flex1 {{#if (eq advantage -1)}}selected{{/if}}" data-action="updateIsAdvantage" data-advantage="-1">{{localize "DAGGERHEART.General.Disadvantage.Full"}}</button>
|
||||
</div>
|
||||
{{/unless}}
|
||||
<div>
|
||||
<input type="text" value="{{@root.formula}}" disabled>
|
||||
{{#if (eq @root.rollType 'D20Roll')}}
|
||||
<div class="flexrow">
|
||||
<select name="roll.dice.d20">
|
||||
{{selectOptions diceOptions selected=@root.roll.d20.denomination}}
|
||||
</select>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if (eq @root.rollType 'DualityRoll')}}
|
||||
<div class="flexrow">
|
||||
<div>Hope Dice</div>
|
||||
<select name="roll.dice.dHope">
|
||||
{{selectOptions diceOptions selected=@root.roll.dHope.denomination}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="flexrow">
|
||||
<div>Fear Dice</div>
|
||||
<select name="roll.dice.dFear">
|
||||
{{selectOptions diceOptions selected=@root.roll.dFear.denomination}}
|
||||
</select>
|
||||
</div>
|
||||
{{#if roll.advantage}}
|
||||
<div class="flexrow">
|
||||
<div>Adv/Disadv Dice</div>
|
||||
<select name="roll.dice.advantageFaces">
|
||||
{{selectOptions diceOptions selected=@root.roll.dAdvantage.denomination}}
|
||||
</select>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<div>
|
||||
<input type="text" value="{{extraFormula}}" name="extraFormula" placeholder="Situational Bonus">
|
||||
</div>
|
||||
{{/unless}}
|
||||
{{!-- {{#if (not isNpc)}} --}}
|
||||
{{!-- <div class="form-group">
|
||||
<label>Hope</label>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue