This commit is contained in:
Dapoolp 2025-06-12 22:36:55 +02:00
parent 7178148c80
commit fad34ae975
26 changed files with 688 additions and 371 deletions

View file

@ -124,7 +124,26 @@ Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => {
});
const renderDualityButton = async event => {
const button = event.currentTarget;
const button = event.currentTarget,
attributeValue = button.dataset.attribute?.toLowerCase(),
target = getCommandTarget();
if (!target) return;
const config = {
event: event,
title: button.dataset.label,
roll: {
modifier: attributeValue ? target.system.attributes[attributeValue].data.value : null,
type: button.dataset.actionType ?? null, // Need check
},
chatMessage: {
template: 'systems/daggerheart/templates/chat/attack-roll.hbs'
}
};
await target.diceRoll(config);
// Delete when new roll logic test done
/* const button = event.currentTarget;
const attributeValue = button.dataset.attribute?.toLowerCase();
const target = getCommandTarget();
@ -160,7 +179,7 @@ const renderDualityButton = async event => {
rolls: [roll]
};
await cls.create(msgData);
await cls.create(msgData); */
};
Hooks.on('renderChatMessageHTML', (_, element) => {
@ -293,6 +312,9 @@ const preloadHandlebarsTemplates = async function () {
'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs',
'systems/daggerheart/templates/ui/combat/combatTrackerSection.hbs',
'systems/daggerheart/templates/views/actionTypes/damage.hbs',
'systems/daggerheart/templates/views/actionTypes/healing.hbs',
'systems/daggerheart/templates/views/actionTypes/resource.hbs',
'systems/daggerheart/templates/views/actionTypes/uuid.hbs',
'systems/daggerheart/templates/views/actionTypes/uses.hbs',
'systems/daggerheart/templates/views/actionTypes/roll.hbs',
'systems/daggerheart/templates/views/actionTypes/cost.hbs',

View file

@ -47,17 +47,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
const tabs = {
base: { active: true, cssClass: '', group: 'primary', id: 'base', icon: null, label: 'Base' },
config: { active: false, cssClass: '', group: 'primary', id: 'config', icon: null, label: 'Configuration' },
effect: { active: false, cssClass: '', group: 'primary', id: 'effect', icon: null, label: 'Effect' },
// effects: { active: true, cssClass: '', group: 'primary', id: 'effects', icon: null, label: 'Effects' },
// useage: { active: false, cssClass: '', group: 'primary', id: 'useage', icon: null, label: 'Useage' },
// conditions: {
// active: false,
// cssClass: '',
// group: 'primary',
// id: 'conditions',
// icon: null,
// label: 'Conditions'
// }
effect: { active: false, cssClass: '', group: 'primary', id: 'effect', icon: null, label: 'Effect' }
};
for (const v of Object.values(tabs)) {
@ -74,8 +64,8 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
context.openSection = this.openSection;
context.tabs = this._getTabs();
context.config = SYSTEM;
context.effects = this.action.effects.map(e => this.action.item.effects.get(e._id));
context.hasBaseDamage = !!this.action.parent.damage;
if(!!this.action.effects) context.effects = this.action.effects.map(e => this.action.item.effects.get(e._id));
if(this.action.damage?.hasOwnProperty('includeBase')) context.hasBaseDamage = !!this.action.parent.damage;
context.getRealIndex = this.getRealIndex.bind(this);
console.log(context, this.action)

View file

@ -14,7 +14,7 @@ export default class NpcRollSelectionDialog extends HandlebarsApplicationMixin(A
}
get title() {
return game.i18n.localize('DAGGERHEART.Application.Settings.Title');
return game.i18n.localize('DAGGERHEART.Application.RollSelection.Title');
}
static DEFAULT_OPTIONS = {

View file

@ -16,7 +16,7 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
hope: ['d12'],
fear: ['d12'],
advantage: null,
disadvantage: null,
// disadvantage: null,
hopeResource: hopeResource
};
}
@ -30,9 +30,10 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
height: 'auto'
},
actions: {
updateIsAdvantage: this.updateIsAdvantage,
selectExperience: this.selectExperience,
setAdvantage: this.setAdvantage,
setDisadvantage: this.setDisadvantage,
// setAdvantage: this.setAdvantage,
// setDisadvantage: this.setDisadvantage,
finish: this.finish
},
form: {
@ -61,7 +62,7 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
context.hope = this.data.hope;
context.fear = this.data.fear;
context.advantage = this.data.advantage;
context.disadvantage = this.data.disadvantage;
// context.disadvantage = this.data.disadvantage;
context.experiences = Object.keys(this.experiences).map(id => ({ id, ...this.experiences[id] }));
context.hopeResource = this.data.hopeResource + 1;
@ -85,7 +86,13 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
this.render();
}
static setAdvantage() {
static updateIsAdvantage(_, button) {
const advantage = Boolean(button.dataset.advantage);
this.data.advantage = this.data.advantage === advantage ? null : advantage;
this.render();
}
/* static setAdvantage() {
this.data.advantage = this.data.advantage ? null : 'd6';
this.data.disadvantage = null;
@ -97,7 +104,7 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
this.data.disadvantage = this.data.disadvantage ? null : 'd6';
this.render(true);
}
} */
static async finish() {
const { diceOptions, ...rest } = this.data;

View file

@ -61,7 +61,23 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
}
static async reactionRoll(event) {
const { roll, diceResults, modifiers } = await this.actor.diceRoll(
const config = {
event: event,
title: `${this.actor.name} - Reaction Roll`,
roll: {
modifier: 0,
type: 'reaction'
},
chatMessage: {
type: 'adversaryRoll',
template: 'systems/daggerheart/templates/chat/adversary-roll.hbs',
mute: true
}
};
this.actor.diceRoll(config);
// Delete when new roll logic test done
/* const { roll, diceResults, modifiers } = await this.actor.diceRoll(
{ title: `${this.actor.name} - Reaction Roll`, value: 0 },
event.shiftKey
);
@ -83,12 +99,33 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
rolls: [roll]
});
cls.create(msg.toObject());
cls.create(msg.toObject()); */
}
static async attackRoll() {
const { modifier, damage, name: attackName } = this.actor.system.attack;
const { roll, dice, advantageState, modifiers } = await this.actor.diceRoll(
static async attackRoll(event) {
const { modifier, damage, name: attackName } = this.actor.system.attack,
config = {
event: event,
title: attackName,
roll: {
modifier: modifier,
type: 'action'
},
chatMessage: {
type: 'adversaryRoll',
template: 'systems/daggerheart/templates/chat/adversary-attack-roll.hbs'
},
damage: {
value: damage.value,
type: damage.type
},
checkTarget: true
};
this.actor.diceRoll(config);
// Delete when new roll logic test done
/* const { modifier, damage, name: attackName } = this.actor.system.attack;
const { roll, dice, advantageState, modifiers } = await this.actor.diceRollOld(
{ title: `${this.actor.name} - Attack Roll`, value: modifier },
event.shiftKey
);
@ -105,11 +142,12 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
const systemData = {
title: attackName,
origin: this.document.id,
roll: roll._formula,
roll,
// roll: roll._formula,
advantageState,
total: roll._total,
// total: roll._total,
modifiers: modifiers,
dice: dice,
// dice: dice,
targets: targets,
damage: { value: damage.value, type: damage.type }
};
@ -124,7 +162,7 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
rolls: [roll]
});
cls.create(msg.toObject());
cls.create(msg.toObject()); */
}
static async addExperience() {

View file

@ -33,6 +33,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
selectAncestry: this.selectAncestry,
selectCommunity: this.selectCommunity,
viewObject: this.viewObject,
useItem: this.useItem,
useFeature: this.useFeature,
takeShortRest: this.takeShortRest,
takeLongRest: this.takeLongRest,
@ -150,6 +151,10 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
super._attachPartListeners(partId, htmlElement, options);
htmlElement.querySelector('.level-value').addEventListener('change', this.onLevelChange.bind(this));
// To Remove when ContextMenu Handler is made
htmlElement
.querySelectorAll('[data-item-id]')
.forEach(element => element.addEventListener('contextmenu', this.editItem.bind(this)));
}
async _prepareContext(_options) {
@ -280,7 +285,22 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
}
static async rollAttribute(event, button) {
const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll(
const config = {
event: event,
title: game.i18n.format('DAGGERHEART.Chat.DualityRoll.AbilityCheckTitle', {
ability: game.i18n.localize(abilities[button.dataset.attribute].label)
}),
roll: {
modifier: button.dataset.value
},
chatMessage: {
template: 'systems/daggerheart/templates/chat/duality-roll.hbs'
}
};
this.document.diceRoll(config);
// Delete when new roll logic test done
/* const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll(
{ title: game.i18n.localize(abilities[button.dataset.attribute].label), value: button.dataset.value },
event.shiftKey
);
@ -310,7 +330,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
systemContent
),
rolls: [roll]
});
}); */
}
static async toggleMarks(_, button) {
@ -348,51 +368,8 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
static async attackRoll(event, button) {
const weapon = await fromUuid(button.dataset.weapon);
const damage = {
value: `${this.document.system.proficiency}${weapon.system.damage.value}`,
type: weapon.system.damage.type
};
const modifier = this.document.system.traits[weapon.system.trait].value;
const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll(
{ title: game.i18n.localize(abilities[weapon.system.trait].label), value: modifier },
event.shiftKey
);
const targets = Array.from(game.user.targets).map(x => ({
id: x.id,
name: x.actor.name,
img: x.actor.img,
difficulty: x.actor.system.difficulty,
evasion: x.actor.system.evasion
}));
const systemData = new DHDualityRoll({
title: weapon.name,
origin: this.document.id,
roll: roll._formula,
modifiers: modifiers,
hope: hope,
fear: fear,
advantage: advantage,
disadvantage: disadvantage,
damage: damage,
targets: targets
});
const cls = getDocumentClass('ChatMessage');
const msg = new cls({
type: 'dualityRoll',
sound: CONFIG.sounds.dice,
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/attack-roll.hbs',
systemData
),
rolls: [roll]
});
await cls.create(msg.toObject());
if(!weapon) return;
weapon.use(event);
}
static openLevelUp() {
@ -470,6 +447,12 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
(await game.packs.get('daggerheart.communities'))?.render(true);
}
static useItem(event) {
const uuid = event.target.closest('[data-item-id]').dataset.itemId,
item = this.document.items.find(i => i.uuid === uuid);
item.use(event);
}
static async viewObject(_, button) {
const object = await fromUuid(button.dataset.value);
if (!object) return;
@ -482,6 +465,16 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
object.sheet.render(true);
}
editItem(event) {
const uuid = event.target.closest('[data-item-id]').dataset.itemId,
item = this.document.items.find(i => i.uuid === uuid);
if (!item) return;
if (item.sheet.editMode) item.sheet.editMode = false;
item.sheet.render(true);
}
static async takeShortRest() {
await new DhpDowntime(this.document, true).render(true);
await this.minimize();

View file

@ -9,6 +9,11 @@ export const actionTypes = {
name: 'DAGGERHEART.Actions.Types.Spellcast.Name',
icon: "fa-book-sparkles"
},
healing: {
id: 'healing',
name: 'DAGGERHEART.Actions.Types.Healing.Name',
icon: "fa-kit-medical"
},
resource: {
id: 'resource',
name: 'DAGGERHEART.Actions.Types.Resource.Name',
@ -19,11 +24,6 @@ export const actionTypes = {
name: 'DAGGERHEART.Actions.Types.Damage.Name',
icon: "fa-bone-break"
},
healing: {
id: 'healing',
name: 'DAGGERHEART.Actions.Types.Healing.Name',
icon: "fa-kit-medical"
},
summon: {
id: 'summon',
name: 'DAGGERHEART.Actions.Types.Summon.Name',

View file

@ -1,6 +1,4 @@
import DHDamageData from "./damage.mjs";
import { abilities } from "../../config/actorConfig.mjs";
// import DHWeapon from "../item/weapon.mjs";
import { DHActionDiceData, DHDamageData, DHDamageField } from "./actionDice.mjs";
export default class DHAction extends foundry.abstract.DataModel {
static defineSchema() {
@ -39,8 +37,12 @@ export default class DHAction extends foundry.abstract.DataModel {
const fields = foundry.data.fields;
// Create Roll Field
// Create Damage Field
/*
ToDo
- Apply ActiveEffect => Add to Chat message like Damage Button ?
- Add Drag & Drop for documentUUID field (Macro & Summon)
- Add optionnal Role for Healing ?
*/
export class DHBaseAction extends foundry.abstract.DataModel {
static defineSchema() {
@ -50,11 +52,6 @@ export class DHBaseAction extends foundry.abstract.DataModel {
name: new fields.StringField({ initial: undefined }),
img: new fields.FilePathField({ initial: undefined, categories: ["IMAGE"], base64: false }),
actionType: new fields.StringField({ choices: SYSTEM.ITEM.actionTypes, initial: 'action', nullable: true }),
roll: new fields.SchemaField({
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 })
}),
cost: new fields.ArrayField(
new fields.SchemaField({
type: new fields.StringField({ choices: SYSTEM.GENERAL.abilityCosts, nullable: false, required: true, initial: 'hope' }),
@ -62,30 +59,13 @@ export class DHBaseAction extends foundry.abstract.DataModel {
scalable: new fields.BooleanField({ initial: false }),
step: new fields.NumberField({ nullable: true, initial: null }),
})
/* ,
{ initial: [
{ type: "hope", value: 1, scalable: false, step: null },
{ type: "stress", value: 2, scalable: true, step: 2 }
]} */
),
uses: new fields.SchemaField({
value: new fields.NumberField({ nullable: true, initial: null }),
max: new fields.NumberField({ nullable: true, initial: null }),
recovery: new fields.StringField({ choices: SYSTEM.GENERAL.refreshTypes, initial: null, nullable: true })
}),
/* duration: new fields.SchemaField({
value: new fields.NumberField({ nullable: true, initial: null }),
units: new fields.StringField({ required: true, blank: false, initial: "instant" })
}), */
target: new fields.SchemaField({
type: new fields.StringField({ choices: SYSTEM.ACTIONS.targetTypes, initial: SYSTEM.ACTIONS.targetTypes.other.id })
}),
range: new fields.StringField({ choices: SYSTEM.GENERAL.range, required: true, blank: false, initial: "self" }),
effects: new fields.ArrayField( // ActiveEffect
new fields.SchemaField({
'_id': new fields.DocumentIdField()
})
)
range: new fields.StringField({ choices: SYSTEM.GENERAL.range, required: true, blank: false, initial: "self" })
}
}
@ -103,6 +83,10 @@ export class DHBaseAction extends foundry.abstract.DataModel {
return this.item?.actor;
}
get chatTemplate() {
return 'systems/daggerheart/templates/chat/attack-roll.hbs';
}
static getRollType() {
return 'ability';
}
@ -123,94 +107,66 @@ export class DHBaseAction extends foundry.abstract.DataModel {
}
async use(event) {
console.log(this)
// console.log(this.item.getRollData(), this.item.actor.getRollData())
// const weapon = await fromUuid(button.dataset.weapon);
let damage, modifier, roll, hope, fear, advantage, disadvantage, modifiers, bonusDamageString, targets;
if(this.damage.parts.length) {
damage = {
value: `${this.actor.system[this.damage.parts[0].multiplier].value}${this.damage.parts[0].dice}`,
type: this.damage.parts[0].type,
bonusDamage: [this.damage.parts[0].bonus ?? 0, ...this.actor.system.bonuses.damage]
};
damage.value = damage.value.concat(bonusDamageString);
}
if(this.roll.type && this.roll.trait) {
modifier = this.actor.system.traits[this.roll.trait].value;
({roll, hope, fear, advantage, disadvantage, modifiers, bonusDamageString} =
await this.actor.dualityRoll(
{ title: game.i18n.localize(abilities[this.roll.trait].label), value: modifier },
event.shiftKey,
damage?.bonusDamage ?? 0
));
const config = {
event: event,
title: this.item.name,
roll: {
modifier: this.actor.system.traits[this.roll.trait].value,
type: this.actionType,
difficulty: this.roll?.difficulty
},
chatMessage: {
template: this.chatTemplate
}
};
if(this.target?.type) config.checkTarget = true;
if(this.damage.parts.length) {
config.damage = {
value: this.damage.parts.map(p => p.getFormula(this.actor)).join(' + '),
type: this.damage.parts[0].type
};
}
if(this.effects.length) {
// Apply Active Effects. In Chat Message ?
}
return this.actor.diceRoll(config);
}
console.log(roll, hope, fear, advantage, disadvantage, modifiers, bonusDamageString)
// if(this.target?.type) {
targets = Array.from(game.user.targets).map(x => ({
id: x.id,
name: x.actor.name,
img: x.actor.img,
difficulty: x.actor.system.difficulty,
evasion: x.actor.system.evasion.value
}));
// }
const systemData = {
title: this.item.name,
origin: this.actor.id,
roll: roll._formula,
modifiers: modifiers,
hope: hope,
fear: fear,
advantage: advantage,
disadvantage: disadvantage,
damage: damage,
targets: targets
};
const cls = getDocumentClass('ChatMessage');
const msg = new cls({
type: 'dualityRoll',
sound: CONFIG.sounds.dice,
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/attack-roll.hbs',
systemData
),
rolls: [roll]
});
await cls.create(msg.toObject());
}
}
const extraDefineSchema = (field, option) => {
return {
[field] : {
// damage: new fields.SchemaField({
// parts: new fields.ArrayField(new fields.EmbeddedDataField(DHDamageData))
// }),
damage: new DHDamageField(option),
roll: new fields.SchemaField({
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 })
}),
target: new fields.SchemaField({
type: new fields.StringField({ choices: SYSTEM.ACTIONS.targetTypes, initial: SYSTEM.ACTIONS.targetTypes.other.id })
}),
effects: new fields.ArrayField( // ActiveEffect
new fields.SchemaField({
'_id': new fields.DocumentIdField()
})
)
}[field]
};
}
export class DHAttackAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
/* attack: new fields.SchemaField({
trait: new fields.StringField({ required: true, choices: SYSTEM.ACTOR.abilities, initial: 'agility' }),
bonus: new fields.NumberField({ nullable: true, initial: null })
}), */
/* damage: new fields.SchemaField({
baseDamage: new fields.BooleanField({ initial: true }), // Add damage from source item ?
parts: new fields.ArrayField(
new fields.SchemaField({ // Create DamageField
type: new fields.StringField({
choices: SYSTEM.GENERAL.damageTypes,
initial: 'physical'
}),
value: new FormulaField({ initial: 'd6' }),
bonus: new fields.NumberField({ nullable: true, initial: null }),
base: new fields.BooleanField({ initial: false, readonly: true })
})
)
}) */
damage: new fields.SchemaField({
parts: new fields.ArrayField(new fields.EmbeddedDataField(DHDamageData)),
includeBase: new fields.BooleanField({ initial: true })
})
...extraDefineSchema('damage', true),
...extraDefineSchema('roll'),
...extraDefineSchema('target'),
...extraDefineSchema('effects')
}
}
@ -235,12 +191,21 @@ export class DHAttackAction extends DHBaseAction {
base: true
};
}
// Temporary until full formula parser
// getDamageFormula() {
// return this.damage.parts.map(p => p.formula).join(' + ');
// }
}
export class DHSpellCastAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
...extraDefineSchema('damage'),
...extraDefineSchema('roll'),
...extraDefineSchema('target'),
...extraDefineSchema('effects')
}
}
@ -249,33 +214,97 @@ export class DHSpellCastAction extends DHBaseAction {
}
}
export class DHResourceAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
resource: new fields.SchemaField({
target: new fields.StringField({ choices: [], required: true, blank: false, initial: "" }),
value: new fields.NumberField({ initial: 0 })
})
}
}
}
export class DHDamageAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
damage: new fields.SchemaField({})
...extraDefineSchema('damage', false),
...extraDefineSchema('target'),
...extraDefineSchema('effects')
}
}
async use(event) {
const formula = this.damage.parts.map(p => p.getFormula(this.actor)).join(' + ');
if(!formula || formula == '') return;
let roll = { formula: formula, total: formula };
if (isNaN(formula)) {
roll = await new Roll(formula).evaluate();
}
const cls = getDocumentClass('ChatMessage');
const msg = new cls({
user: game.user.id,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/damage-roll.hbs',
{
roll: roll.formula,
total: roll.total,
type: this.damage.parts.map(p => p.type)
}
)
});
cls.create(msg.toObject());
}
}
export class DHHealingAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
type: new fields.StringField({ choices: SYSTEM.GENERAL.healingTypes, required: true, blan: false, initial: SYSTEM.GENERAL.healingTypes.health.id }),
healing: new fields.SchemaField({})
healing: new fields.SchemaField({
type: new fields.StringField({ choices: SYSTEM.GENERAL.healingTypes, required: true, blank: false, initial: SYSTEM.GENERAL.healingTypes.health.id, label: "Healing" }),
value: new fields.EmbeddedDataField(DHActionDiceData)
}),
...extraDefineSchema('target'),
...extraDefineSchema('effects')
}
}
async use(event) {
const formula = this.healing.value.getFormula(this.actor);
if(!formula || formula == '') return;
// const roll = await super.use(event);
let roll = { formula: formula, total: formula };
if (isNaN(formula)) {
roll = await new Roll(formula).evaluate();
}
const cls = getDocumentClass('ChatMessage');
const msg = new cls({
user: game.user.id,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/healing-roll.hbs',
{
roll: roll.formula,
total: roll.total,
type: this.healing.type
}
)
});
cls.create(msg.toObject());
}
get chatTemplate() {
return 'systems/daggerheart/templates/chat/healing-roll.hbs';
}
}
export class DHResourceAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
// ...extraDefineSchema('roll'),
...extraDefineSchema('target'),
...extraDefineSchema('effects'),
resource: new fields.SchemaField({
type: new fields.StringField({ choices: [], initial: "", label: "Resource" }),
value: new fields.NumberField({ initial: 0, label: "Value" })
})
}
}
}
@ -284,7 +313,7 @@ export class DHSummonAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
healing: new fields.SchemaField({})
documentUUID: new fields.StringField({ blank: true, initial: "", placeholder:'Enter a Creature UUID' })
}
}
}
@ -292,7 +321,8 @@ export class DHSummonAction extends DHBaseAction {
export class DHEffectAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema()
...super.defineSchema(),
...extraDefineSchema('effects')
}
}
}
@ -300,7 +330,20 @@ export class DHEffectAction extends DHBaseAction {
export class DHMacroAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema()
...super.defineSchema(),
documentUUID: new fields.StringField({ blank: true, initial: "", placeholder:'Enter a macro UUID' })
}
}
async use(event) {
const fixUUID = !this.documentUUID.includes('Macro.') ? `Macro.${this.documentUUID}` : this.documentUUID,
macro = await fromUuid(fixUUID);
try {
if(!macro) throw new Error(`No macro found for the UUID: ${this.documentUUID}.`);
macro.execute();
} catch (error) {
ui.notifications.error(error);
}
}
}

View file

@ -2,13 +2,40 @@ import FormulaField from "../fields/formulaField.mjs";
const fields = foundry.data.fields;
export default class DHDamageData extends foundry.abstract.DataModel {
export class DHActionDiceData extends foundry.abstract.DataModel {
/** @override */
static defineSchema() {
return {
multiplier: new fields.StringField({ choices: SYSTEM.GENERAL.multiplierTypes, initial: 'proficiency', label: 'Multiplier' }),
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Formula' }),
bonus: new fields.NumberField({ nullable: true, initial: null, label: 'Bonus' }),
custom: new fields.SchemaField({
enabled: new fields.BooleanField({ label: 'Custom Formula' }),
formula: new FormulaField( { label: 'Formula' } )
})
}
}
getFormula(actor) {
return this.custom.enabled ? this.custom.formula : `${(actor.system[this.multiplier] ?? 1)}${this.dice}${this.bonus ? (this.bonus < 0 ? ` - ${Math.abs(this.bonus)}` : ` + ${this.bonus}`) : ''}`;
}
}
export class DHDamageField extends fields.SchemaField {
constructor(hasBase, options, context={}) {
const damageFields = {
parts: new fields.ArrayField(new fields.EmbeddedDataField(DHDamageData))
}
if(hasBase) damageFields.includeBase = new fields.BooleanField({ initial: true })
super(damageFields, options, context);
}
}
export class DHDamageData extends DHActionDiceData {
/** @override */
static defineSchema() {
return {
...super.defineSchema(),
base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }),
type: new fields.StringField({
choices: SYSTEM.GENERAL.damageTypes,
@ -16,10 +43,6 @@ export default class DHDamageData extends foundry.abstract.DataModel {
label: 'Type',
nullable: false,
required: true
}),
custom: new fields.SchemaField({
enabled: new fields.BooleanField({ label: 'Custom Formula' }),
formula: new FormulaField( { label: 'Formula' } )
})
}
}

View file

@ -18,7 +18,8 @@ export default class DHDualityRoll extends foundry.abstract.TypeDataModel {
return {
title: new fields.StringField(),
origin: new fields.StringField({ required: true }),
roll: new fields.StringField({}),
// roll: new fields.StringField({}),
roll: new fields.DataField({}),
modifiers: new fields.ArrayField(
new fields.SchemaField({
value: new fields.NumberField({ integer: true }),
@ -28,8 +29,10 @@ export default class DHDualityRoll extends foundry.abstract.TypeDataModel {
),
hope: diceField(),
fear: diceField(),
advantageState: new fields.NumberField({ integer: true }),
advantage: diceField(),
disadvantage: diceField(),
// advantage: diceField(),
// disadvantage: diceField(),
targets: new fields.ArrayField(
new fields.SchemaField({
id: new fields.StringField({}),
@ -65,12 +68,13 @@ export default class DHDualityRoll extends foundry.abstract.TypeDataModel {
}
get total() {
const advantage = this.advantage.value
? this.advantage.value
: this.disadvantage.value
? -this.disadvantage.value
: 0;
return this.diceTotal + advantage + this.modifierTotal.value;
// const advantage = this.advantage.value
// ? this.advantage.value
// : this.disadvantage.value
// ? -this.disadvantage.value
// : 0;
// return this.diceTotal + advantage + this.modifierTotal.value;
return this.roll.total;
}
get diceTotal() {

View file

@ -1,11 +1,47 @@
import { actionsTypes } from "../action/_module.mjs";
// Temporary Solution
export default class ActionField extends foundry.data.fields.EmbeddedDataField {
export default class ActionField extends foundry.data.fields.ObjectField {
/** @override */
initialize(value, model, options={}) {
this.model = actionsTypes[value?.type] ?? actionsTypes.attack;
this.fields = this._initialize(this.model.defineSchema());
return super.initialize(value, model, options)
// initialize(value, model, options={}) {
// console.log('initialize', value.type)
// this.model = actionsTypes[value?.type] ?? actionsTypes.attack;
// this.fields = this._initialize(this.model.defineSchema());
// return super.initialize(value, model, options)
// }
getModel(value) {
return actionsTypes[value.type] ?? actionsTypes.attack;
}
/* -------------------------------------------- */
/** @override */
_cleanType(value, options) {
if ( !(typeof value === "object") ) value = {};
const cls = this.getModel(value);
if ( cls ) return cls.cleanData(value, options);
return value;
}
/* -------------------------------------------- */
/** @override */
initialize(value, model, options = {}) {
const cls = this.getModel(value);
if ( cls ) return new cls(value, { parent: model, ...options });
return foundry.utils.deepClone(value);
}
/* -------------------------------------------- */
/**
* Migrate this field's candidate source data.
* @param {object} sourceData Candidate source data of the root model.
* @param {any} fieldData The value of this field within the source data.
*/
migrateSource(sourceData, fieldData) {
const cls = this.getModel(fieldData);
if ( cls ) cls.migrateDataSafe(fieldData);
}
}

View file

@ -36,8 +36,8 @@ export default class DHWeapon extends BaseDataItem {
})
}),
feature: new fields.StringField({ choices: SYSTEM.ITEM.weaponFeatures, blank: true }),
actions: new fields.ArrayField(new fields.EmbeddedDataField(DHAttackAction))
// actions: new fields.ArrayField(new ActionField(DHBaseAction))
// actions: new fields.ArrayField(new fields.EmbeddedDataField(DHAttackAction))
actions: new fields.ArrayField(new ActionField())
};
}
}

View file

@ -3,6 +3,7 @@ import NpcRollSelectionDialog from '../applications/npcRollSelectionDialog.mjs';
import RollSelectionDialog from '../applications/rollSelectionDialog.mjs';
import { GMUpdateEvent, socketEvent } from '../helpers/socket.mjs';
import { setDiceSoNiceForDualityRoll } from '../helpers/utils.mjs';
import DHDualityRoll from '../data/chat-message/dualityRoll.mjs';
export default class DhpActor extends Actor {
async _preCreate(data, options, user) {
@ -123,7 +124,160 @@ export default class DhpActor extends Actor {
});
}
async diceRoll(modifier, shiftKey) {
/**
* @param {object} config
* @param {Event} config.event
* @param {string} config.title
* @param {object} config.roll
* @param {number} config.roll.modifier
* @param {boolean} [config.roll.simple=false]
* @param {string} [config.roll.type]
* @param {number} [config.roll.difficulty]
* @param {any} [config.damage]
* @param {object} [config.chatMessage]
* @param {string} config.chatMessage.template
* @param {boolean} [config.chatMessage.mute]
* @param {boolean} [config.checkTarget]
*/
async diceRoll(config) {
let hopeDice = 'd12',
fearDice = 'd12',
advantageDice = 'd6',
disadvantageDice = 'd6',
advantage = config.event.altKey ?? config.event.ctrlKey ? false : null,
targets,
damage = config.damage,
modifiers = this.formatRollModifier(config.roll.modifier),
rollConfig,
formula,
hope,
fear;
if (!config.event.shiftKey && !config.event.altKey && !config.event.ctrlKey) {
const dialogClosed = new Promise((resolve, _) => {
this.type === 'character' ? new RollSelectionDialog(this.system.experiences, this.system.resources.hope.value, resolve).render(true) : new NpcRollSelectionDialog(this.system.experiences, resolve).render(true);
});
rollConfig = await dialogClosed;
// advantageDice = result.advantage;
// disadvantageDice = result.disadvantage;
advantage = rollConfig.advantage;
hopeDice = rollConfig.hope;
fearDice = rollConfig.fear;
rollConfig.experiences.forEach(x =>
modifiers.push({
value: x.value,
label: x.value >= 0 ? `+${x.value}` : `-${x.value}`,
title: x.description
})
);
if(this.type === 'character') {
const automateHope = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope);
if (automateHope && result.hopeUsed) {
await this.update({
'system.resources.hope.value': this.system.resources.hope.value - result.hopeUsed
});
}
}
}
if(this.type === 'character') {
formula = `1${hopeDice} + 1${fearDice}${advantage === true ? ` + 1d6` : advantage === false ? ` - 1d6` : ''}`
} else {
formula = `${advantage === true || advantage === false ? 2 : 1}d20${advantage === true ? 'kh' : advantage === false ? 'kl' : ''}`
}
formula += ` ${modifiers.map(x => `+ ${x.value}`).join(' ')}`;
const roll = await Roll.create(formula).evaluate();
if(this.type === 'character') {
setDiceSoNiceForDualityRoll(roll, advantageDice, disadvantageDice);
hope = roll.dice[0].results[0].result;
fear = roll.dice[1].results[0].result;
if(game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope) && config.roll.type === 'action') {
if(hope > fear) {
await this.update({
'system.resources.hope.value': Math.min(
this.system.resources.hope.value + 1,
this.system.resources.hope.max
)
});
} else if(hope === fear) {
await this.update({
'system.resources': {
'hope.value': Math.min(this.system.resources.hope.value + 1, this.system.resources.hope.max),
'stress.value': Math.max(this.system.resources.stress.value - 1, 0)
}
});
}
}
}
if(config.checkTarget) {
targets = Array.from(game.user.targets).map(x => ({
id: x.id,
name: x.actor.name,
img: x.actor.img,
difficulty: x.actor.system.difficulty,
evasion: x.actor.system.evasion.value ?? x.actor.system.evasion
}));
}
if(config.chatMessage) {
const configRoll = {
title: config.title,
origin: this.id,
roll,
modifiers,
advantageState: advantage
};
if(this.type === 'character') {
configRoll.hope = { dice: hopeDice, value: hope };
configRoll.fear = { dice: fearDice, value: fear };
configRoll.advantage = { dice: advantageDice, value: roll.dice[2]?.results[0].result ?? null }
/* advantage: { dice: advantageDice, value: advantage },
disadvantage: { dice: disadvantageDice, value: disadvantage } */
}
if(damage) configRoll.damage = damage;
if(targets) configRoll.targets = targets;
const systemData = this.type === 'character' && !config.roll.simple ? new DHDualityRoll(configRoll) : configRoll,
cls = getDocumentClass('ChatMessage'),
msg = new cls({
type: config.chatMessage.type ?? 'dualityRoll',
sound: config.chatMessage.mute ? null : CONFIG.sounds.dice,
system: systemData,
// user: config.chatMessage.user ?? game.user.id,
content: await foundry.applications.handlebars.renderTemplate(
config.chatMessage.template,
systemData
),
rolls: [roll]
});
console.log(systemData)
await cls.create(msg.toObject());
}
return roll;
}
formatRollModifier(modifier) {
return modifier.value !== null ? [
{
value: modifier.value ? Number.parseInt(modifier.value) : 0,
label:
modifier.value >= 0
? `${modifier.title} +${modifier.value}`
: `${modifier.title} ${modifier.value}`,
title: modifier.title
}
]
: [];
}
// Delete when new roll logic test done
/* async diceRollOld(modifier, shiftKey) {
if (this.type === 'character') {
return await this.dualityRoll(modifier, shiftKey);
} else {
@ -156,7 +310,7 @@ export default class DhpActor extends Actor {
})
);
}
const roll = Roll.create(
`${advantage === true || advantage === false ? 2 : 1}d20${advantage === true ? 'kh' : advantage === false ? 'kl' : ''} ${modifiers.map(x => `+ ${x.value}`).join(' ')}`
);
@ -265,7 +419,7 @@ export default class DhpActor extends Actor {
disadvantage: { dice: disadvantageDice, value: disadvantage },
modifiers: modifiers
};
}
} */
async damageRoll(title, damage, targets, shiftKey) {
let rollString = damage.value;

View file

@ -120,23 +120,23 @@ export default class DhpItem extends Item {
}
async use(event) {
const actions = this.system.actions;
const actions = this.system.actions
let response;
if(actions?.length) {
let action = actions[0];
if(actions.length > 1 && !event?.shiftKey) {
// Actions Choice Dialog
action = await this.selectActionDialog();
}
if(!action) return;
if(action) response = action.use(event);
// Check Target
// If action.roll => Roll Dialog
// Else If action.cost => Cost Dialog
// Then
// Apply Cost
// Apply Effect
return action.use(event);
}
// Display Item Card in chat
return response;
}
}

View file

@ -126,10 +126,12 @@ export const setDiceSoNiceForDualityRoll = (rollResult, advantage, disadvantage)
const diceSoNicePresets = getDiceSoNicePresets();
rollResult.dice[0].options.appearance = diceSoNicePresets.hope;
rollResult.dice[1].options.appearance = diceSoNicePresets.fear;
if (advantage) {
rollResult.dice[2].options.appearance = diceSoNicePresets.advantage;
} else if (disadvantage) {
rollResult.dice[2].options.appearance = diceSoNicePresets.disadvantage;
if(rollResult.dice[2]) {
if (advantage) {
rollResult.dice[2].options.appearance = diceSoNicePresets.advantage;
} else if (disadvantage) {
rollResult.dice[2].options.appearance = diceSoNicePresets.disadvantage;
}
}
};
@ -222,3 +224,11 @@ export const getDeleteKeys = (property, innerProperty, innerPropertyDefaultValue
return acc;
}, {});
};
// Fix on Foundry native formula replacement for DH
const nativeReplaceFormulaData = Roll.replaceFormulaData;
Roll.replaceFormulaData = function(formula, data, {missing, warn=false}={}) {
const terms = [{term: 'prof', default: 1}, {term: 'cast', default: 1}];
formula = terms.reduce((a,c) => a.replaceAll(`@${c.term}`, data[c.term] ?? c.default), formula);
return nativeReplaceFormulaData(formula, data, {missing, warn});
}

View file

@ -1,30 +1,32 @@
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
<div class="dice-flavor">{{localize "DAGGERHEART.Chat.AttackRoll.Title" attack=this.title}}</div>
<div class="dice-result">
<div class="dice-formula">{{roll}}</div>
<div class="dice-formula">{{roll.formula}}</div>
<div class="dice-tooltip">
<div class="wrapper">
<section class="tooltip-part">
<div class="dice">
{{#each roll.dice}}
<header class="part-header flexrow">
<span class="part-formula">{{this.dice.rolls.length}}{{this.dice.type}}</span>
<span class="part-total">{{this.dice.rollTotal}}</span>
<span class="part-formula">{{number}}{{denomination}}</span>
<span class="part-total">{{total}}</span>
</header>
<div class="flexrow">
<ol class="dice-rolls">
{{#each this.dice.rolls}}
<li class="roll die {{../dice.type}} {{#if this.discarded}}discarded{{/if}} min">{{this.value}}</li>
{{#each results}}
<li class="roll die {{../denomination}}{{#if discarded}} discarded{{/if}} min">{{result}}</li>
{{/each}}
</ol>
<div class="attack-roll-advantage-container">{{#if (eq this.advantageState 1)}}{{localize "DAGGERHEART.General.Advantage.Full"}}{{/if}}{{#if (eq this.advantageState 2)}}{{localize "DAGGERHEART.General.Disadvantage.Full"}}{{/if}}</div>
</div>
<div class="attack-roll-advantage-container">{{#if (eq ../advantageState 1)}}{{localize "DAGGERHEART.General.Advantage.Full"}}{{/if}}{{#if (eq ../advantageState 2)}}{{localize "DAGGERHEART.General.Disadvantage.Full"}}{{/if}}</div>
</div>
{{/each}}
</div>
</section>
</div>
</div>
<div class="dice-total">
<div class="dice-total-value">{{this.total}}</div>
<div class="dice-total-value">{{roll.total}}</div>
</div>
{{#if (gt targets.length 0)}}
<div class="target-section">
@ -39,7 +41,7 @@
</div>
{{/if}}
<div class="flexrow">
<button class="duality-action" data-value="{{this.total.normal}}" data-damage="{{this.damage.value}}" data-damage-type="{{this.damage.type}}" {{#if this.damage.disabled}}disabled{{/if}}><span>Roll Damage</span></button>
<button class="duality-action" data-value="{{roll.total}}" data-damage="{{damage.value}}" data-damage-type="{{damage.type}}"{{#if damage.disabled}} disabled{{/if}}><span>Roll Damage</span></button>
</div>
</div>
</div>

View file

@ -1,22 +1,24 @@
<div class="dice-roll daggerheart chat roll">
<div class="dice-result">
<div class="dice-formula">{{roll}}</div>
<div class="dice-formula">{{roll.formula}}</div>
<div class="dice-tooltip">
<ol class="dice-rolls">
<div class="dice-hope-container">
{{#each diceResults}}
<li class="roll die d20 {{#if this.discarded}}discarded{{/if}}">{{this.value}}</li>
{{#each roll.dice}}
{{#each results}}
<li class="roll die {{../denomination}}{{#if discarded}} discarded{{/if}}">{{result}}</li>
{{/each}}
{{/each}}
</div>
<div class="modifiers-container">
{{#each modifiers}}
<li class="modifier-value" data-value="{{this.value}}" title="{{this.title}}">{{this.label}}</li>
<li class="modifier-value" data-value="{{value}}" title="{{title}}">{{label}}</li>
{{/each}}
</div>
</ol>
</div>
<div class="dice-total">
<div class="dice-total-value">{{total}}</div>
<div class="dice-total-value">{{roll.total}}</div>
</div>
</div>
</div>

View file

@ -1,27 +1,27 @@
{{#if this.colorful}}
{{#if colorful}}
<div class="daggerheart chat roll" data-action="expandRoll">
<div class="duality-data">
<div class="duality-title">
<div>{{localize "DAGGERHEART.Chat.AttackRoll.Title" attack=this.title}}</div>
<div>{{localize "DAGGERHEART.Chat.AttackRoll.Title" attack=title}}</div>
</div>
<div class="duality-modifiers">
{{#each this.modifiers}}
{{#each modifiers}}
<div class="duality-modifier">
{{this.label}}
{{label}}
</div>
{{/each}}
{{#if this.advantage.value}}
{{#if (eq advantageState 1)}}
<div class="duality-modifier">
{{localize "DAGGERHEART.General.Advantage.Full"}}
</div>
{{/if}}
{{#if this.disadvantage.value}}
{{#if (eq advantageState 2)}}
<div class="duality-modifier">
{{localize "DAGGERHEART.General.Disadvantage.Full"}}
</div>
{{/if}}
</div>
<div class="duality-line {{#if (not this.damage.value)}}simple{{/if}}">
<div class="duality-line {{#if (not damage.value)}}simple{{/if}}">
<div class="dice-outer-container">
<div class="dice-container">
<div class="dice-title">{{localize "DAGGERHEART.General.Hope"}}</div>
@ -41,27 +41,27 @@
<div class="dice-value">{{fear.value}}</div>
</div>
</div>
{{#if this.advantage.value}}
{{#if (eq advantageState 1)}}
<div class="advantage-container advantage">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/d6-grey.svg"/>
<div class="dice-value">{{this.advantage.value}}</div>
<div class="dice-value">{{advantage.value}}</div>
</div>
</div>
{{/if}}
{{#if this.disadvantage.value}}
{{#if (eq advantageState 2)}}
<div class="advantage-container disadvantage">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/d6-grey.svg"/>
<div class="dice-value">{{this.disadvantage.value}}</div>
<div class="dice-value">{{advantage.value}}</div>
</div>
</div>
{{/if}}
{{#if this.modifierTotal.value}}<div class="duality-modifier">{{this.modifierTotal.label}}</div>{{/if}}
{{#if modifierTotal.value}}<div class="duality-modifier">{{modifierTotal.label}}</div>{{/if}}
</div>
{{#if (not this.damage.value)}}
{{#if (not damage.value)}}
<div class="duality-result">
<div>{{this.total}} {{#if (eq dualityResult 1)}}With Hope{{else}}{{#if (eq dualityResult 2)}}With Fear{{else}}Critical Success{{/if}}{{/if}}</div>
<div>{{total}} {{#if (eq dualityResult 1)}}With Hope{{else}}{{#if (eq dualityResult 2)}}With Fear{{else}}Critical Success{{/if}}{{/if}}</div>
</div>
{{/if}}
</div>
@ -78,18 +78,18 @@
{{/each}}
</div>
{{/if}}
{{#if this.damage.value}}
{{#if damage.value}}
<div class="duality-actions">
<button class="duality-action" data-value="{{this.total}}" data-damage="{{this.damage.value}}" data-damage-type="{{this.damage.type}}" {{#if this.damage.disabled}}disabled{{/if}}><span>Roll Damage</span></button>
<button class="duality-action" data-value="{{total}}" data-damage="{{damage.value}}" data-damage-type="{{damage.type}}" {{#if damage.disabled}}disabled{{/if}}><span>Roll Damage</span></button>
<div class="duality-result">
<div>{{this.total}} {{#if (eq dualityResult 1)}}With Hope{{else}}{{#if (eq dualityResult 2)}}With Fear{{else}}Critical Success{{/if}}{{/if}}</div>
<div>{{total}} {{#if (eq dualityResult 1)}}With Hope{{else}}{{#if (eq dualityResult 2)}}With Fear{{else}}Critical Success{{/if}}{{/if}}</div>
</div>
</div>
{{/if}}
</div>
{{else}}
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
<div class="dice-flavor">{{localize "DAGGERHEART.Chat.AttackRoll.Title" attack=this.title}}</div>
<div class="dice-flavor">{{localize "DAGGERHEART.Chat.AttackRoll.Title" attack=title}}</div>
<div class="dice-result">
<div class="dice-formula">{{roll}}</div>
@ -103,7 +103,7 @@
|
<span>1{{fear.dice}}</span>
</span>
<span class="part-total">{{this.diceTotal}}</span>
<span class="part-total">{{diceTotal}}</span>
</header>
<div class="flexrow">
<ol class="dice-rolls duality">
@ -112,7 +112,7 @@
</ol>
</div>
</div>
{{#if advantage.value}}
{{#if (eq advantageState 1)}}
<div class="dice">
<header class="part-header flexrow">
<span class="part-formula">
@ -127,17 +127,17 @@
</div>
</div>
{{/if}}
{{#if disadvantage.value}}
{{#if (eq advantageState 2)}}
<div class="dice">
<header class="part-header flexrow">
<span class="part-formula">
<span>1{{disadvantage.dice}}</span>
<span>1{{advantage.dice}}</span>
</span>
<span class="part-total">{{disadvantage.value}}</span>
<span class="part-total">{{advantage.value}}</span>
</header>
<div class="flexrow">
<ol class="dice-rolls">
<li class="roll die {{disadvantage.dice}} hope min">{{disadvantage.value}}</li>
<li class="roll die {{advantage.dice}} hope min">{{advantage.value}}</li>
</ol>
</div>
</div>
@ -148,7 +148,7 @@
<div class="dice-total duality {{#if fear.discarded}}hope{{else}}{{#if hope.discarded}}fear{{else}}critical{{/if}}{{/if}}">
<div class="dice-total-label">{{totalLabel}}</div>
<div class="dice-total-value">
{{this.total}}
{{total}}
</div>
</div>
{{#if (gt targets.length 0)}}
@ -164,7 +164,7 @@
</div>
{{/if}}
<div class="dice-actions">
<button class="duality-action" data-value="{{this.total}}" data-damage="{{this.damage.value}}" data-damage-type="{{this.damage.type}}" {{#if this.damage.disabled}}disabled{{/if}}><span>{{localize "DAGGERHEART.Chat.AttackRoll.RollDamage"}}</span></button>
<button class="duality-action" data-value="{{total}}" data-damage="{{damage.value}}" data-damage-type="{{damage.type}}" {{#if damage.disabled}}disabled{{/if}}><span>{{localize "DAGGERHEART.Chat.AttackRoll.RollDamage"}}</span></button>
</div>
</div>
</div>

View file

@ -1,7 +1,7 @@
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
<div class="dice-flavor">{{this.title}}</div>
<div class="dice-flavor">{{title}}</div>
<div class="dice-result">
<div class="dice-formula">{{this.roll}}</div>
<div class="dice-formula">{{roll}}</div>
<div class="dice-tooltip">
<div class="wrapper">
@ -9,12 +9,12 @@
{{#each dice}}
<div class="dice">
<header class="part-header flexrow">
<span class="part-formula">{{this.rolls.length}}{{this.type}}</span>
<span class="part-formula">{{rolls.length}}{{type}}</span>
<span class="part-total">{{this.rollTotal}}</span>
<span class="part-total">{{rollTotal}}</span>
</header>
<ol class="dice-rolls">
{{#each this.rolls}}
{{#each rolls}}
<li class="roll die {{../type}} min">{{this}}</li>
{{/each}}
</ol>
@ -23,9 +23,9 @@
</section>
</div>
</div>
<div class="dice-total">{{this.damage.total}}</div>
<div class="dice-total">{{total}}</div>
<div class="dice-actions">
<button class="damage-button" data-target-hit="true" {{#if (eq this.targets.length 0)}}disabled{{/if}}>{{localize "DAGGERHEART.Chat.DamageRoll.DealDamageToTargets"}}</button>
<button class="damage-button" data-target-hit="true" {{#if (eq targets.length 0)}}disabled{{/if}}>{{localize "DAGGERHEART.Chat.DamageRoll.DealDamageToTargets"}}</button>
<button class="damage-button">{{localize "DAGGERHEART.Chat.DamageRoll.DealDamage"}}</button>
</div>
</div>

View file

@ -1,27 +1,27 @@
{{#if this.colorful}}
{{#if colorful}}
<div class="daggerheart chat roll" data-action="expandRoll">
<div class="duality-data">
<div class="duality-title">
<div>{{this.title}}</div>
<div>{{title}}</div>
</div>
<div class="duality-modifiers">
{{#each this.modifiers}}
{{#each modifiers}}
<div class="duality-modifier">
{{this.label}}
{{label}}
</div>
{{/each}}
{{#if this.advantage.value}}
{{#if (eq advantageState 1)}}
<div class="duality-modifier">
{{localize "DAGGERHEART.General.Advantage.Full"}}
</div>
{{/if}}
{{#if this.disadvantage.value}}
{{#if (eq advantageState 2)}}
<div class="duality-modifier">
{{localize "DAGGERHEART.General.Disadvantage.Full"}}
</div>
{{/if}}
</div>
<div class="duality-line {{#if (not this.damage.value)}}simple{{/if}}">
<div class="duality-line {{#if (not damage.value)}}simple{{/if}}">
<div class="dice-outer-container">
<div class="dice-container">
<div class="dice-title">{{localize "DAGGERHEART.General.Hope"}}</div>
@ -41,32 +41,32 @@
<div class="dice-value">{{fear.value}}</div>
</div>
</div>
{{#if this.advantage.value}}
{{#if (eq advantageState 1)}}
<div class="advantage-container advantage">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/d6-grey.svg"/>
<div class="dice-value">{{this.advantage.value}}</div>
<div class="dice-value">{{advantage.value}}</div>
</div>
</div>
{{/if}}
{{#if this.disadvantage.value}}
{{#if (eq advantageState 2)}}
<div class="advantage-container disadvantage">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/d6-grey.svg"/>
<div class="dice-value">{{this.disadvantage.value}}</div>
<div class="dice-value">{{advantage.value}}</div>
</div>
</div>
{{/if}}
{{#if this.modifierTotal.value}}<div class="duality-modifier">{{this.modifierTotal.label}}</div>{{/if}}
{{#if modifierTotal.value}}<div class="duality-modifier">{{modifierTotal.label}}</div>{{/if}}
</div>
{{#if (not this.damage.value)}}
{{#if (not damage.value)}}
<div class="duality-result">
<div>{{this.total}} {{#if (eq dualityResult 1)}}With Hope{{else}}{{#if (eq dualityResult 2)}}With Fear{{else}}Critical Success{{/if}}{{/if}}</div>
<div>{{total}} {{#if (eq dualityResult 1)}}With Hope{{else}}{{#if (eq dualityResult 2)}}With Fear{{else}}Critical Success{{/if}}{{/if}}</div>
</div>
{{/if}}
</div>
</div>
{{#if this.damage.value}}
{{#if damage.value}}
<div class="duality-actions">
<div></div>
<div class="duality-result">
@ -77,7 +77,7 @@
</div>
{{else}}
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
<div class="dice-flavor">{{this.title}}</div>
<div class="dice-flavor">{{title}}</div>
<div class="dice-result">
<div class="dice-formula">{{roll}}</div>
<div class="dice-tooltip">
@ -90,7 +90,7 @@
|
<span>1{{fear.dice}}</span>
</span>
<span class="part-total">{{this.diceTotal}}</span>
<span class="part-total">{{diceTotal}}</span>
</header>
<div class="flexrow">
<ol class="dice-rolls duality">
@ -99,7 +99,7 @@
</ol>
</div>
</div>
{{#if advantage.value}}
{{#if (eq advantageState 1)}}
<div class="dice">
<header class="part-header flexrow">
<span class="part-formula">
@ -114,17 +114,17 @@
</div>
</div>
{{/if}}
{{#if disadvantage.value}}
{{#if (eq advantageState 2)}}
<div class="dice">
<header class="part-header flexrow">
<span class="part-formula">
<span>1{{disadvantage.dice}}</span>
<span>1{{advantage.dice}}</span>
</span>
<span class="part-total">{{disadvantage.value}}</span>
<span class="part-total">{{advantage.value}}</span>
</header>
<div class="flexrow">
<ol class="dice-rolls">
<li class="roll die {{disadvantage.dice}} hope min">{{disadvantage.value}}</li>
<li class="roll die {{advantage.dice}} hope min">{{advantage.value}}</li>
</ol>
</div>
</div>

View file

@ -22,72 +22,19 @@
{{formField fields.actionType value=source.actionType label="Type" name="actionType" localize=true}}
</div>
</fieldset>
{{> 'systems/daggerheart/templates/views/actionTypes/roll.hbs' fields=fields.roll.fields source=source.roll}}
{{#if fields.roll}}{{> 'systems/daggerheart/templates/views/actionTypes/roll.hbs' fields=fields.roll.fields source=source.roll}}{{/if}}
</div>
<div class="tab {{this.tabs.config.cssClass}}" data-group="primary" data-tab="config">
{{> '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}}
{{> '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 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">
{{#if source.damage}}
{{> 'systems/daggerheart/templates/views/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=source.damage}}
{{/if}}
{{!-- {{#switch source.type}}
{{#case 'attack'}}
{{> 'systems/daggerheart/templates/views/actionTypes/damage.hbs' fields=fields.damage.element.fields source=source.damage}}
{{/case}}
{{#case 'spellcast'}}
<div>SpellCast</div>
{{/case}}
{{/switch}} --}}
{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs'}}
{{#if fields.damage}}{{> 'systems/daggerheart/templates/views/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=source.damage}}{{/if}}
{{#if fields.healing}}{{> 'systems/daggerheart/templates/views/actionTypes/healing.hbs' fields=fields.healing.fields source=source.healing}}{{/if}}
{{#if fields.resource}}{{> 'systems/daggerheart/templates/views/actionTypes/resource.hbs' fields=fields.resource.fields source=source.resource}}{{/if}}
{{#if fields.documentUUID}}{{> 'systems/daggerheart/templates/views/actionTypes/uuid.hbs' fields=fields.documentUUID source=source.documentUUID}}{{/if}}
{{#if fields.effects}}{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs'}}{{/if}}
</div>
{{!-- <div class="tab {{this.tabs.effects.cssClass}}" data-group="primary" data-tab="effects">
<fieldset class="action-category">
<legend class="action-category-label" data-action="toggleSection" data-section="damage">
<div>Damage</div>
</legend>
<div class="action-category-data open">
{{formField fields.damage.fields.type value=source.damage.type label="Damage Type" name="damage.type" rootId=partId localize=true}}
{{formField fields.damage.fields.value value=source.damage.value label="Damage" name="damage.value" rootId=partId localize=true}}
</div>
</fieldset>
<fieldset class="action-category">
<legend class="action-category-label" data-action="toggleSection" data-section="healing">
<div>Healing</div>
</legend>
<div class="action-category-data open ">
{{formField fields.healing.fields.type value=source.healing.type label="Healing Type" name="healing.type" rootId=partId localize=true}}
{{formField fields.healing.fields.value value=source.healing.value label="Healing" name="healing.value" rootId=partId localize=true}}
</div>
</fieldset>
</div>
<div class="tab {{this.tabs.useage.cssClass}}" data-group="primary" data-tab="useage">
<fieldset class="action-category">
<legend class="action-category-label" data-action="toggleSection" data-section="cost">
<div>Cost</div>
</legend>
<div class="action-category-data open ">
{{formField fields.cost.fields.type value=source.cost.type label="Cost Type" name="cost.type" rootId=partId}}
{{formField fields.cost.fields.value value=source.cost.value label="Value" name="cost.value" rootId=partId}}
</div>
</fieldset>
{{formField fields.target.fields.type value=source.target.type label="Target Type" name="target.type" rootId=partId}}
</div>
<div class="tab {{this.tabs.conditions.cssClass}}" data-group="primary" data-tab="conditions">
<h2>
{{localize "Conditions"}}
<select class="effect-select">
{{selectOptions this.config.effectTypes selected=this.selectedEffectType labelAttr="name" localize=true blank=""}}
</select>
<i class="fa-solid fa-plus icon-button {{#if (not this.selectedEffectType)}}disabled{{/if}}" data-action="addCondition"></i>
</h2>
</div> --}}
</section>
{{!-- <button type="submit">Save</button> --}}
</div>

View file

@ -0,0 +1,21 @@
<fieldset class="action-category">
<legend class="action-category-label" data-action="toggleSection" data-section="effects">
<div>Healing</div>
</legend>
<div class="action-category-data open">
<fieldset>
{{formField fields.type value=source.type name="healing.type" localize=true}}
<div class="multi-display">
{{formField fields.value.fields.custom.fields.enabled value=source.value.custom.enabled name="healing.value.custom.enabled"}}
{{#if source.value.custom.enabled}}
{{formField fields.value.fields.custom.fields.formula value=source.value.custom.formula name="healing.value.custom.formula" localize=true}}
{{else}}
{{formField fields.value.fields.multiplier value=source.value.multiplier name="healing.value.multiplier" localize=true}}
{{formField fields.value.fields.dice value=source.value.dice name="healing.value.dice"}}
{{formField fields.value.fields.bonus value=source.value.bonus name="healing.value.bonus" localize=true}}
{{/if}}
</div>
</fieldset>
</div>
</fieldset>

View file

@ -1,11 +1,13 @@
<fieldset class="action-category">
<legend class="action-category-label" data-action="toggleSection" data-section="range">
<div>Range & Target</div>
<div>Range{{#if fields.target}} & Target{{/if}}</div>
</legend>
<div class="action-category-data open">
{{formField fields.range value=source.range label="Range" name="range" localize=true}}
</div>
{{#if fields.target}}
<div class="action-category-data open">
{{formField fields.target.type value=source.target.type label="Target" name="target.type" localize=true}}
</div>
{{/if}}
</fieldset>

View file

@ -0,0 +1,14 @@
<fieldset class="action-category">
<legend class="action-category-label" data-action="toggleSection" data-section="effects">
<div>Resource</div>
</legend>
<div class="action-category-data open">
<fieldset>
<div class="multi-display">
{{formField fields.type value=source.type name="resource.type" localize=true}}
{{formField fields.value value=source.value name="resource.value"}}
</div>
</fieldset>
</div>
</fieldset>

View file

@ -0,0 +1,9 @@
<fieldset class="action-category">
<legend class="action-category-label" data-action="toggleSection" data-section="effects">
<div>Macro</div>
</legend>
<div class="action-category-data open">
{{formInput fields value=source name="documentUUID" placeholder=fields.options.placeholder}}
</div>
</fieldset>

View file

@ -12,8 +12,8 @@
{{/each}}
</div>
<div class="flexrow">
<button class="disadvantage flex1 {{#if this.advantage}}selected{{/if}}" data-action="setAdvantage">Advantage</button>
<button class="disadvantage flex1 {{#if this.disadvantage}}selected{{/if}}" data-action="setDisadvantage">Disadvantage</button>
<button class="disadvantage flex1 {{#if this.advantage}}selected{{/if}}" data-action="updateIsAdvantage" data-advantage="true">{{localize "DAGGERHEART.General.Advantage.Full"}}</button>
<button class="disadvantage flex1 {{#if this.disadvantage}}selected{{/if}}" data-action="updateIsAdvantage">{{localize "DAGGERHEART.General.Disadvantage.Full"}}</button>
</div>
{{#if (not this.isNpc)}}
<div class="form-group">