mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/247 auto add yope fear clear stress (#285)
* cleanup * test * Step 1 * #2 * Fix Effect Action & Add Hope tumation settings to hook * remove circular dependency * Snuck in some localization fixes I noticed * Remove success condition for duality roll gain * Changed config.roll.type logic --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
ee4a5d17a6
commit
52be430eff
21 changed files with 187 additions and 160 deletions
|
|
@ -17,6 +17,7 @@ import {
|
||||||
socketRegistration
|
socketRegistration
|
||||||
} from './module/systemRegistration/_module.mjs';
|
} from './module/systemRegistration/_module.mjs';
|
||||||
import { placeables } from './module/canvas/_module.mjs';
|
import { placeables } from './module/canvas/_module.mjs';
|
||||||
|
import { registerRollDiceHooks } from './module/dice/dhRoll.mjs';
|
||||||
|
|
||||||
Hooks.once('init', () => {
|
Hooks.once('init', () => {
|
||||||
CONFIG.DH = SYSTEM;
|
CONFIG.DH = SYSTEM;
|
||||||
|
|
@ -152,6 +153,7 @@ Hooks.on('ready', () => {
|
||||||
registerCountdownHooks();
|
registerCountdownHooks();
|
||||||
socketRegistration.registerSocketHooks();
|
socketRegistration.registerSocketHooks();
|
||||||
registerCountdownApplicationHooks();
|
registerCountdownApplicationHooks();
|
||||||
|
registerRollDiceHooks();
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.once('dicesoniceready', () => {});
|
Hooks.once('dicesoniceready', () => {});
|
||||||
|
|
@ -209,7 +211,7 @@ Hooks.on('chatMessage', (_, message) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = traitValue
|
const title = traitValue
|
||||||
? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilitychecktitle', {
|
? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||||
ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label)
|
ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label)
|
||||||
})
|
})
|
||||||
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
|
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
|
||||||
|
|
|
||||||
|
|
@ -63,18 +63,6 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
const context = await super._prepareContext(_options);
|
const context = await super._prepareContext(_options);
|
||||||
context.rollConfig = this.config;
|
context.rollConfig = this.config;
|
||||||
context.hasRoll = !!this.config.roll;
|
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.roll?.advantage;
|
|
||||||
context.disadvantage = this.config.roll?.disadvantage;
|
|
||||||
context.diceOptions = CONFIG.DH.GENERAL.diceTypes;
|
|
||||||
context.canRoll = true;
|
|
||||||
context.isLite = this.config.roll?.lite;
|
|
||||||
if (this.config.costs?.length) {
|
if (this.config.costs?.length) {
|
||||||
const updatedCosts = this.action.calcCosts(this.config.costs);
|
const updatedCosts = this.action.calcCosts(this.config.costs);
|
||||||
context.costs = updatedCosts;
|
context.costs = updatedCosts;
|
||||||
|
|
@ -85,8 +73,22 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
context.uses = this.action.calcUses(this.config.uses);
|
context.uses = this.action.calcUses(this.config.uses);
|
||||||
context.canRoll = context.canRoll && this.action.hasUses(context.uses);
|
context.canRoll = context.canRoll && this.action.hasUses(context.uses);
|
||||||
}
|
}
|
||||||
context.extraFormula = this.config.extraFormula;
|
if(this.roll) {
|
||||||
context.formula = this.roll.constructFormula(this.config);
|
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.roll?.advantage;
|
||||||
|
context.disadvantage = this.config.roll?.disadvantage;
|
||||||
|
context.diceOptions = CONFIG.DH.GENERAL.diceTypes;
|
||||||
|
context.canRoll = true;
|
||||||
|
context.isLite = this.config.roll?.lite;
|
||||||
|
context.extraFormula = this.config.extraFormula;
|
||||||
|
context.formula = this.roll.constructFormula(this.config);
|
||||||
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -494,7 +494,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
const config = {
|
const config = {
|
||||||
event: event,
|
event: event,
|
||||||
title: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${this.actor.name}`,
|
title: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${this.actor.name}`,
|
||||||
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilitychecktitle', {
|
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||||
ability: abilityLabel
|
ability: abilityLabel
|
||||||
}),
|
}),
|
||||||
roll: {
|
roll: {
|
||||||
|
|
@ -605,7 +605,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
const abilityLabel = game.i18n.localize(abilities[button.dataset.attribute].label);
|
const abilityLabel = game.i18n.localize(abilities[button.dataset.attribute].label);
|
||||||
const config = {
|
const config = {
|
||||||
event: event,
|
event: event,
|
||||||
title: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilitychecktitle', { ability: abilityLabel }),
|
title: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', { ability: abilityLabel }),
|
||||||
roll: {
|
roll: {
|
||||||
trait: button.dataset.attribute
|
trait: button.dataset.attribute
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
const targetSelection = event.target
|
const targetSelection = event.target
|
||||||
.closest('.message-content')
|
.closest('.message-content')
|
||||||
.querySelector('.button-target-selection.target-selected'),
|
.querySelector('.button-target-selection.target-selected'),
|
||||||
isHit = Boolean(targetSelection.dataset.targetHit);
|
isHit = Boolean(targetSelection?.dataset?.targetHit) ?? false;
|
||||||
return {
|
return {
|
||||||
isHit,
|
isHit,
|
||||||
targets: isHit
|
targets: isHit
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,20 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setCombatantSpotlight(combatantId) {
|
||||||
|
const combatant = this.viewed.combatants.get(combatantId);
|
||||||
|
|
||||||
|
const toggleTurn = this.viewed.combatants.contents
|
||||||
|
.sort(this.viewed._sortCombatants)
|
||||||
|
.map(x => x.id)
|
||||||
|
.indexOf(combatantId);
|
||||||
|
|
||||||
|
if (this.viewed.turn !== toggleTurn) Hooks.callAll(CONFIG.DH.HOOKS.spotlight, {});
|
||||||
|
|
||||||
|
await this.viewed.update({ turn: this.viewed.turn === toggleTurn ? null : toggleTurn });
|
||||||
|
await combatant.update({ 'system.spotlight.requesting': false });
|
||||||
|
}
|
||||||
|
|
||||||
static async requestSpotlight(_, target) {
|
static async requestSpotlight(_, target) {
|
||||||
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
|
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
|
||||||
const combatant = this.viewed.combatants.get(combatantId);
|
const combatant = this.viewed.combatants.get(combatantId);
|
||||||
|
|
@ -79,17 +93,7 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
|
||||||
|
|
||||||
static async toggleSpotlight(_, target) {
|
static async toggleSpotlight(_, target) {
|
||||||
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
|
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
|
||||||
const combatant = this.viewed.combatants.get(combatantId);
|
await this.setCombatantSpotlight(combatantId);
|
||||||
|
|
||||||
const toggleTurn = this.viewed.combatants.contents
|
|
||||||
.sort(this.viewed._sortCombatants)
|
|
||||||
.map(x => x.id)
|
|
||||||
.indexOf(combatantId);
|
|
||||||
|
|
||||||
if (this.viewed.turn !== toggleTurn) Hooks.callAll(CONFIG.DH.HOOKS.spotlight, {});
|
|
||||||
|
|
||||||
await this.viewed.update({ turn: this.viewed.turn === toggleTurn ? null : toggleTurn });
|
|
||||||
await combatant.update({ 'system.spotlight.requesting': false });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setActionTokens(_, target) {
|
static async setActionTokens(_, target) {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class Countdowns extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
return game.i18n.format('DAGGERHEART.APPLICATIONS.Countdown.Title', {
|
return game.i18n.format('DAGGERHEART.APPLICATIONS.Countdown.title', {
|
||||||
type: game.i18n.localize(`DAGGERHEART.APPLICATIONS.Countdown.types.${this.basePath}`)
|
type: game.i18n.localize(`DAGGERHEART.APPLICATIONS.Countdown.types.${this.basePath}`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { emitAsGM, GMUpdateEvent, socketEvent } from "../../systemRegistration/socket.mjs";
|
||||||
|
|
||||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,6 +98,7 @@ export default class FearTracker extends HandlebarsApplicationMixin(ApplicationV
|
||||||
}
|
}
|
||||||
|
|
||||||
static async increaseFear(event, target) {
|
static async increaseFear(event, target) {
|
||||||
|
if (!game.user.isGM) return;
|
||||||
let value = target.dataset.increment ?? 0,
|
let value = target.dataset.increment ?? 0,
|
||||||
operator = value.split('')[0] ?? null;
|
operator = value.split('')[0] ?? null;
|
||||||
value = Number(value);
|
value = Number(value);
|
||||||
|
|
@ -103,8 +106,19 @@ export default class FearTracker extends HandlebarsApplicationMixin(ApplicationV
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateFear(value) {
|
async updateFear(value) {
|
||||||
if (!game.user.isGM) return;
|
return emitAsGM(GMUpdateEvent.UpdateFear, game.settings.set.bind(game.settings, CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear), value);
|
||||||
|
/* if(!game.user.isGM)
|
||||||
|
await game.socket.emit(`system.${CONFIG.DH.id}`, {
|
||||||
|
action: socketEvent.GMUpdate,
|
||||||
|
data: {
|
||||||
|
action: GMUpdateEvent.UpdateFear,
|
||||||
|
update: value
|
||||||
|
}
|
||||||
|
});
|
||||||
|
else
|
||||||
|
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear, value); */
|
||||||
|
/* if (!game.user.isGM) return;
|
||||||
value = Math.max(0, Math.min(this.maxFear, value));
|
value = Math.max(0, Math.min(this.maxFear, value));
|
||||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear, value);
|
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear, value); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,10 @@ const fields = foundry.data.fields;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ToDo
|
ToDo
|
||||||
- Add setting and/or checkbox for cost and damage like
|
|
||||||
- Target Check / Target Picker
|
- Target Check / Target Picker
|
||||||
- Range Check
|
- Range Check
|
||||||
- Area of effect and measurement placement
|
- Area of effect and measurement placement
|
||||||
- Summon Action create method
|
- Summon Action create method
|
||||||
|
|
||||||
Other
|
|
||||||
- Auto use action <= Into Roll
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default class DHBaseAction extends foundry.abstract.DataModel {
|
export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
|
|
@ -200,28 +196,23 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
const isFastForward = event.shiftKey || (!this.hasRoll && !this.hasSave);
|
const isFastForward = event.shiftKey || (!this.hasRoll && !this.hasSave);
|
||||||
// Prepare base Config
|
// Prepare base Config
|
||||||
const initConfig = this.initActionConfig(event);
|
const initConfig = this.initActionConfig(event);
|
||||||
// let config = this.initActionConfig(event);
|
|
||||||
|
|
||||||
// Prepare Targets
|
// Prepare Targets
|
||||||
const targetConfig = this.prepareTarget();
|
const targetConfig = this.prepareTarget();
|
||||||
if (isFastForward && !targetConfig) return ui.notifications.warn('Too many targets selected for that actions.');
|
if (isFastForward && !targetConfig) return ui.notifications.warn('Too many targets selected for that actions.');
|
||||||
// config = this.prepareTarget(config);
|
|
||||||
|
|
||||||
// Prepare Range
|
// Prepare Range
|
||||||
const rangeConfig = this.prepareRange();
|
const rangeConfig = this.prepareRange();
|
||||||
// config = this.prepareRange(config);
|
|
||||||
|
|
||||||
// Prepare Costs
|
// Prepare Costs
|
||||||
const costsConfig = this.prepareCost();
|
const costsConfig = this.prepareCost();
|
||||||
if (isFastForward && !this.hasCost(costsConfig))
|
if (isFastForward && !this.hasCost(costsConfig))
|
||||||
return ui.notifications.warn("You don't have the resources to use that action.");
|
return ui.notifications.warn("You don't have the resources to use that action.");
|
||||||
// config = this.prepareUseCost(config)
|
|
||||||
|
|
||||||
// Prepare Uses
|
// Prepare Uses
|
||||||
const usesConfig = this.prepareUse();
|
const usesConfig = this.prepareUse();
|
||||||
if (isFastForward && !this.hasUses(usesConfig))
|
if (isFastForward && !this.hasUses(usesConfig))
|
||||||
return ui.notifications.warn("That action doesn't have remaining uses.");
|
return ui.notifications.warn("That action doesn't have remaining uses.");
|
||||||
// config = this.prepareUseCost(config)
|
|
||||||
|
|
||||||
// Prepare Roll Data
|
// Prepare Roll Data
|
||||||
const actorData = this.getRollData();
|
const actorData = this.getRollData();
|
||||||
|
|
@ -238,8 +229,9 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
||||||
|
|
||||||
// Display configuration window if necessary
|
// Display configuration window if necessary
|
||||||
if (config.dialog?.configure && this.requireConfigurationDialog(config)) {
|
// if (config.dialog?.configure && this.requireConfigurationDialog(config)) {
|
||||||
config = await D20RollDialog.configure(config);
|
if (this.requireConfigurationDialog(config)) {
|
||||||
|
config = await D20RollDialog.configure(null, config);
|
||||||
if (!config) return;
|
if (!config) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,37 +242,6 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
if (!config) return;
|
if (!config) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasSave) {
|
|
||||||
/* config.targets.forEach((t) => {
|
|
||||||
if(t.hit) {
|
|
||||||
const target = game.canvas.tokens.get(t.id),
|
|
||||||
actor = target?.actor;
|
|
||||||
if(!actor) return;
|
|
||||||
actor.saveRoll({
|
|
||||||
event,
|
|
||||||
title: 'Roll Save',
|
|
||||||
roll: {
|
|
||||||
trait: this.save.trait,
|
|
||||||
difficulty: this.save.difficulty
|
|
||||||
},
|
|
||||||
dialog: {
|
|
||||||
configure: false
|
|
||||||
},
|
|
||||||
data: actor.getRollData()
|
|
||||||
}).then(async (result) => {
|
|
||||||
t.saved = result;
|
|
||||||
setTimeout(async () => {
|
|
||||||
const message = ui.chat.collection.get(config.message.id),
|
|
||||||
msgTargets = message.system.targets,
|
|
||||||
msgTarget = msgTargets.find(mt => mt.id === t.id);
|
|
||||||
msgTarget.saved = result;
|
|
||||||
await message.update({'system.targets': msgTargets});
|
|
||||||
},100)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}) */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.doFollowUp()) {
|
if (this.doFollowUp()) {
|
||||||
if (this.rollDamage) await this.rollDamage(event, config);
|
if (this.rollDamage) await this.rollDamage(event, config);
|
||||||
if (this.rollHealing) await this.rollHealing(event, config);
|
if (this.rollHealing) await this.rollHealing(event, config);
|
||||||
|
|
@ -329,12 +290,12 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareTarget() {
|
prepareTarget() {
|
||||||
|
if(!this.target?.type) return [];
|
||||||
let targets;
|
let targets;
|
||||||
if (this.target?.type === CONFIG.DH.ACTIONS.targetTypes.self.id)
|
if (this.target?.type === CONFIG.DH.ACTIONS.targetTypes.self.id)
|
||||||
targets = this.constructor.formatTarget(this.actor.token ?? this.actor.prototypeToken);
|
targets = this.constructor.formatTarget(this.actor.token ?? this.actor.prototypeToken);
|
||||||
targets = Array.from(game.user.targets);
|
targets = Array.from(game.user.targets);
|
||||||
// foundry.CONST.TOKEN_DISPOSITIONS.FRIENDLY
|
if (this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
|
||||||
if (this.target?.type && this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
|
|
||||||
targets = targets.filter(t => this.isTargetFriendly(t));
|
targets = targets.filter(t => this.isTargetFriendly(t));
|
||||||
if (this.target.amount && targets.length > this.target.amount) targets = [];
|
if (this.target.amount && targets.length > this.target.amount) targets = [];
|
||||||
}
|
}
|
||||||
|
|
@ -540,6 +501,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/* SAVE */
|
||||||
|
|
||||||
async updateChatMessage(message, targetId, changes, chain = true) {
|
async updateChatMessage(message, targetId, changes, chain = true) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
|
@ -558,7 +520,6 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* SAVE */
|
|
||||||
|
|
||||||
async toChat(origin) {
|
async toChat(origin) {
|
||||||
const cls = getDocumentClass('ChatMessage');
|
const cls = getDocumentClass('ChatMessage');
|
||||||
|
|
|
||||||
|
|
@ -3,38 +3,16 @@ import DHBaseAction from './baseAction.mjs';
|
||||||
export default class DHEffectAction extends DHBaseAction {
|
export default class DHEffectAction extends DHBaseAction {
|
||||||
static extraSchemas = ['effects', 'target'];
|
static extraSchemas = ['effects', 'target'];
|
||||||
|
|
||||||
async use(event, ...args) {
|
async trigger(event, data) {
|
||||||
const config = await super.use(event, args);
|
if(this.effects.length) {
|
||||||
if (['error', 'warning'].includes(config.type)) return;
|
const cls = getDocumentClass('ChatMessage'),
|
||||||
return await this.chatApplyEffects(event, config);
|
msg = {
|
||||||
}
|
type: 'applyEffect',
|
||||||
|
user: game.user.id,
|
||||||
|
system: data
|
||||||
|
};
|
||||||
|
|
||||||
async chatApplyEffects(event, data) {
|
return await cls.create(msg);
|
||||||
const cls = getDocumentClass('ChatMessage'),
|
} else this.toChat(this.id);
|
||||||
systemData = {
|
|
||||||
title: game.i18n.format('DAGGERHEART.UI.Chat.applyEffect.title', { name: this.name }),
|
|
||||||
origin: this.actor._id,
|
|
||||||
description: '',
|
|
||||||
targets: data.targets.map(x => ({ id: x.id, name: x.name, img: x.img, hit: true })),
|
|
||||||
action: {
|
|
||||||
itemId: this.item._id,
|
|
||||||
actionId: this._id
|
|
||||||
}
|
|
||||||
},
|
|
||||||
msg = new cls({
|
|
||||||
type: 'applyEffect',
|
|
||||||
user: game.user.id,
|
|
||||||
system: systemData,
|
|
||||||
content: await foundry.applications.handlebars.renderTemplate(
|
|
||||||
'systems/daggerheart/templates/ui/chat/apply-effects.hbs',
|
|
||||||
systemData
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
cls.create(msg.toObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
get chatTemplate() {
|
|
||||||
return 'systems/daggerheart/templates/ui/chat/apply-effects.hbs';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
|
import DHBaseAction from "../action/baseAction.mjs";
|
||||||
|
|
||||||
export default class DHApplyEffect extends foundry.abstract.TypeDataModel {
|
export default class DHApplyEffect extends foundry.abstract.TypeDataModel {
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: new fields.StringField(),
|
title: new fields.StringField(),
|
||||||
origin: new fields.StringField({}),
|
|
||||||
description: new fields.StringField({}),
|
|
||||||
targets: new fields.ArrayField(
|
targets: new fields.ArrayField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
id: new fields.StringField({ required: true }),
|
id: new fields.StringField({ required: true }),
|
||||||
|
|
@ -14,10 +14,24 @@ export default class DHApplyEffect extends foundry.abstract.TypeDataModel {
|
||||||
hit: new fields.BooleanField({ initial: false })
|
hit: new fields.BooleanField({ initial: false })
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
action: new fields.SchemaField({
|
targetSelection: new fields.BooleanField({ initial: true }),
|
||||||
itemId: new fields.StringField(),
|
source: new fields.SchemaField({
|
||||||
actionId: new fields.StringField()
|
actor: new fields.StringField(),
|
||||||
|
item: new fields.StringField(),
|
||||||
|
action: new fields.StringField()
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepareDerivedData() {
|
||||||
|
this.hasHitTarget = this.targets.filter(t => t.hit === true).length > 0;
|
||||||
|
this.currentTargets =
|
||||||
|
this.targetSelection !== true
|
||||||
|
? Array.from(game.user.targets).map(t => DHBaseAction.formatTarget(t))
|
||||||
|
: this.targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
get messageTemplate() {
|
||||||
|
return 'systems/daggerheart/templates/ui/chat/apply-effects.hbs';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
import { actionsTypes } from '../action/_module.mjs';
|
|
||||||
|
|
||||||
// Temporary Solution
|
|
||||||
export default class ActionField extends foundry.data.fields.ObjectField {
|
export default class ActionField extends foundry.data.fields.ObjectField {
|
||||||
getModel(value) {
|
getModel(value) {
|
||||||
return actionsTypes[value.type] ?? actionsTypes.attack;
|
return game.system.api.models.actions.actionsTypes[value.type] ?? game.system.api.models.actions.actionsTypes.attack;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,21 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
hope: new fields.BooleanField({ required: true, initial: false }),
|
hope: new fields.BooleanField({
|
||||||
actionPoints: new fields.BooleanField({ required: true, initial: false }),
|
required: true,
|
||||||
countdowns: new fields.BooleanField({ requireD: true, initial: false })
|
initial: false,
|
||||||
|
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hope.label'
|
||||||
|
}), // Label need to be updated into something like "Duality Roll Auto Gain" + a hint
|
||||||
|
actionPoints: new fields.BooleanField({
|
||||||
|
required: true,
|
||||||
|
initial: false,
|
||||||
|
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.actionPoints.label'
|
||||||
|
}),
|
||||||
|
countdowns: new fields.BooleanField({
|
||||||
|
requireD: true,
|
||||||
|
initial: false,
|
||||||
|
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.countdowns.label'
|
||||||
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export default class DHRoll extends Roll {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async buildConfigure(config = {}, message = {}) {
|
static async buildConfigure(config = {}, message = {}) {
|
||||||
config.hooks = [...(config.hooks ?? []), ''];
|
config.hooks = [...this.getHooks(), ''];
|
||||||
config.dialog ??= {};
|
config.dialog ??= {};
|
||||||
for (const hook of config.hooks) {
|
for (const hook of config.hooks) {
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.preRoll${hook.capitalize()}`, config, message) === false) return null;
|
if (Hooks.call(`${CONFIG.DH.id}.preRoll${hook.capitalize()}`, config, message) === false) return null;
|
||||||
|
|
@ -94,6 +94,10 @@ export default class DHRoll extends Roll {
|
||||||
config.dialog.configure ??= !(config.event.shiftKey || config.event.altKey || config.event.ctrlKey);
|
config.dialog.configure ??= !(config.event.shiftKey || config.event.altKey || config.event.ctrlKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getHooks(hooks) {
|
||||||
|
return hooks ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
formatModifier(modifier) {
|
formatModifier(modifier) {
|
||||||
const numTerm = modifier < 0 ? '-' : '+';
|
const numTerm = modifier < 0 ? '-' : '+';
|
||||||
return [
|
return [
|
||||||
|
|
@ -131,3 +135,32 @@ export default class DHRoll extends Roll {
|
||||||
return modifierTotal;
|
return modifierTotal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const registerRollDiceHooks = () => {
|
||||||
|
Hooks.on(`${CONFIG.DH.id}.postRollDuality`, async (config, message) => {
|
||||||
|
if (
|
||||||
|
!game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).hope ||
|
||||||
|
config.roll.type === 'reaction'
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const actor = await fromUuid(config.source.actor),
|
||||||
|
updates = [];
|
||||||
|
if (!actor) return;
|
||||||
|
if (config.roll.isCritical || config.roll.result.duality === 1) updates.push({ type: 'hope', value: 1 });
|
||||||
|
if (config.roll.isCritical) updates.push({ type: 'stress', value: -1 });
|
||||||
|
if (config.roll.result.duality === -1) updates.push({ type: 'fear', value: 1 });
|
||||||
|
|
||||||
|
if (updates.length) actor.modifyResource(updates);
|
||||||
|
|
||||||
|
if (!config.roll.hasOwnProperty('success') && !config.targets.length) return;
|
||||||
|
|
||||||
|
const rollResult = config.roll.success || config.targets.some(t => t.hit),
|
||||||
|
looseSpotlight = !rollResult || config.roll.result.duality === -1;
|
||||||
|
|
||||||
|
if (looseSpotlight && game.combat?.active) {
|
||||||
|
const currentCombatant = game.combat.combatants.get(game.combat.current?.combatantId);
|
||||||
|
if (currentCombatant?.actorId == actor.id) ui.combat.setCombatantSpotlight(currentCombatant.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,10 @@ export default class DualityRoll extends D20Roll {
|
||||||
return game.i18n.localize(label);
|
return game.i18n.localize(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFormula() {}
|
static getHooks(hooks) {
|
||||||
|
|
||||||
|
return [...(hooks ?? []), 'Duality'];
|
||||||
|
}
|
||||||
|
|
||||||
createBaseDice() {
|
createBaseDice() {
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -39,20 +39,16 @@ export const registerSocketHooks = () => {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GMUpdateEvent.UpdateSetting:
|
case GMUpdateEvent.UpdateSetting:
|
||||||
if (game.user.isGM) {
|
await game.settings.set(CONFIG.DH.id, data.uuid, data.update);
|
||||||
await game.settings.set(CONFIG.DH.id, data.uuid, data.update);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GMUpdateEvent.UpdateFear:
|
case GMUpdateEvent.UpdateFear:
|
||||||
if (game.user.isGM) {
|
await game.settings.set(
|
||||||
await game.settings.set(
|
CONFIG.DH.id,
|
||||||
CONFIG.DH.id,
|
CONFIG.DH.SETTINGS.gameSettings.Resources.Fear,
|
||||||
CONFIG.DH.SETTINGS.gameSettings.Resources.Fear,
|
Math.max(0, Math.min(game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxFear, data.update))
|
||||||
Math.max(Math.min(data.update, 6), 0)
|
);
|
||||||
);
|
/* Hooks.callAll(socketEvent.DhpFearUpdate);
|
||||||
Hooks.callAll(socketEvent.DhpFearUpdate);
|
await game.socket.emit(`system.${CONFIG.DH.id}`, { action: socketEvent.DhpFearUpdate }); */
|
||||||
await game.socket.emit(`system.${CONFIG.DH.id}`, { action: socketEvent.DhpFearUpdate });
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,3 +62,22 @@ export const registerSocketHooks = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const emitAsGM = async (eventName, callback, args) => {
|
||||||
|
if(!game.user.isGM) {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const response = await game.socket.emit(`system.${CONFIG.DH.id}`, {
|
||||||
|
action: socketEvent.GMUpdate,
|
||||||
|
data: {
|
||||||
|
action: eventName,
|
||||||
|
update: args
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resolve(response);
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else return callback(args);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4069,10 +4069,11 @@ body.theme-light.application.daggerheart .character-sidebar-sheet .experience-va
|
||||||
.application.sheet.daggerheart.actor.dh-style.character .window-content {
|
.application.sheet.daggerheart.actor.dh-style.character .window-content {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 275px 1fr;
|
grid-template-columns: 275px 1fr;
|
||||||
grid-template-rows: 283px 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
gap: 15px 0;
|
gap: 15px 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
.application.sheet.daggerheart.actor.dh-style.character .window-content .character-sidebar-sheet {
|
.application.sheet.daggerheart.actor.dh-style.character .window-content .character-sidebar-sheet {
|
||||||
grid-row: 1 / span 2;
|
grid-row: 1 / span 2;
|
||||||
|
|
@ -4313,7 +4314,7 @@ body.theme-light.application.daggerheart .character-sidebar-sheet .experience-va
|
||||||
.application.sheet.daggerheart.actor.dh-style.adversary .window-content {
|
.application.sheet.daggerheart.actor.dh-style.adversary .window-content {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 275px 1fr;
|
grid-template-columns: 275px 1fr;
|
||||||
grid-template-rows: 283px 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
gap: 15px 0;
|
gap: 15px 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<div>
|
<div>
|
||||||
{{#if @root.hasRoll}}
|
|
||||||
<div class="roll-dialog-container">
|
<div class="roll-dialog-container">
|
||||||
|
{{#if @root.hasRoll}}
|
||||||
{{#unless @root.isLite}}
|
{{#unless @root.isLite}}
|
||||||
<div class="dices-section">
|
<div class="dices-section">
|
||||||
{{#if (eq @root.rollType 'D20Roll')}}
|
{{#if (eq @root.rollType 'D20Roll')}}
|
||||||
|
|
@ -121,6 +121,10 @@
|
||||||
<i class="fa-solid fa-dice"></i>
|
<i class="fa-solid fa-dice"></i>
|
||||||
<span class="label">Roll</span>
|
<span class="label">Roll</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
{{else}}
|
||||||
|
<button class="sunmit-btn" data-action="submitRoll"{{#unless canRoll}} disabled{{/unless}}>
|
||||||
|
<span class="label">Continue</span>
|
||||||
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1,22 +1,7 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="form-group">
|
{{formGroup settingFields.schema.fields.hope value=settingFields._source.hope localize=true}}
|
||||||
<label>{{localize "DAGGERHEART.SETTINGS.Automation.FIELDS.hope.label"}}</label>
|
{{formGroup settingFields.schema.fields.actionPoints value=settingFields._source.actionPoints localize=true}}
|
||||||
<div class="form-fields">
|
{{formGroup settingFields.schema.fields.countdowns value=settingFields._source.countdowns localize=true}}
|
||||||
{{formInput settingFields.schema.fields.hope value=settingFields._source.hope }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>{{localize "DAGGERHEART.SETTINGS.Automation.FIELDS.actionPoints.label"}}</label>
|
|
||||||
<div class="form-fields">
|
|
||||||
{{formInput settingFields.schema.fields.actionPoints value=settingFields._source.actionPoints }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>{{localize "DAGGERHEART.SETTINGS.Automation.FIELDS.countdowns.label"}}</label>
|
|
||||||
<div class="form-fields">
|
|
||||||
{{formInput settingFields.schema.fields.countdowns value=settingFields._source.countdowns }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<footer class="form-footer">
|
<footer class="form-footer">
|
||||||
<button data-action="reset">
|
<button data-action="reset">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
|
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
|
||||||
<div class="dice-flavor">{{title}}</div>
|
<div class="dice-flavor">{{title}}</div>
|
||||||
<div>{{{description}}}</div>
|
<div>{{{description}}}</div>
|
||||||
|
</div>
|
||||||
|
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
|
||||||
<div class="dice-result">
|
<div class="dice-result">
|
||||||
<div class="dice-actions">
|
<div class="dice-actions">
|
||||||
<button class="duality-action-effect">{{localize "DAGGERHEART.UI.Chat.attackRoll.applyEffect"}}</button>
|
<button class="duality-action-effect">{{localize "DAGGERHEART.UI.Chat.attackRoll.applyEffect"}}</button>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<div class="combat-tracker">
|
<div class="combat-tracker">
|
||||||
{{#if (gt this.characters.length 0)}}
|
{{#if (gt this.characters.length 0)}}
|
||||||
{{> 'systems/daggerheart/templates/ui/combat/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Character.plural") turns=this.characters}}
|
{{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Character.plural") turns=this.characters}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (gt this.adversaries.length 0)}}
|
{{#if (gt this.adversaries.length 0)}}
|
||||||
{{> 'systems/daggerheart/templates/ui/combat/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Adversary.plural") turns=this.adversaries}}
|
{{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Adversary.plural") turns=this.adversaries}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div>{{fear}}</div>
|
<div>{{fear}}</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="encounter-countdowns" data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.Countdown.Title" type=(localize "DAGGERHEART.APPLICATIONS.Countdown.types.encounter")}}" data-action="openCountdowns"><i class="fa-solid fa-stopwatch"></i></a>
|
<a class="encounter-countdowns" data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.Countdown.title" type=(localize "DAGGERHEART.APPLICATIONS.Countdown.types.encounter")}}" data-action="openCountdowns"><i class="fa-solid fa-stopwatch"></i></a>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue