mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 19:51:08 +01:00
First PR
This commit is contained in:
parent
7178148c80
commit
fad34ae975
26 changed files with 688 additions and 371 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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' } )
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue