mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Adversary Attack
This commit is contained in:
parent
5a8aed73d2
commit
2981aab917
19 changed files with 269 additions and 499 deletions
|
|
@ -2,6 +2,7 @@ import DamageSelectionDialog from '../../applications/damageSelectionDialog.mjs'
|
|||
import CostSelectionDialog from '../../applications/costSelectionDialog.mjs';
|
||||
import { abilities } from '../../config/actorConfig.mjs';
|
||||
import { DHActionDiceData, DHDamageData, DHDamageField } from './actionDice.mjs';
|
||||
import DhpActor from '../../documents/actor.mjs';
|
||||
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
choices: SYSTEM.GENERAL.range,
|
||||
required: false,
|
||||
blank: true,
|
||||
initial: null
|
||||
// initial: null
|
||||
}),
|
||||
...this.defineExtraSchema()
|
||||
};
|
||||
|
|
@ -99,7 +100,8 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
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 })
|
||||
difficulty: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
|
||||
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 })
|
||||
}),
|
||||
save: new fields.SchemaField({
|
||||
trait: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.ACTOR.abilities }),
|
||||
|
|
@ -150,7 +152,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
}
|
||||
|
||||
get actor() {
|
||||
return this.item?.actor;
|
||||
return this.item instanceof DhpActor ? this.item : this.item?.actor;
|
||||
}
|
||||
|
||||
get chatTemplate() {
|
||||
|
|
@ -197,6 +199,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
source: {
|
||||
item: this.item._id,
|
||||
action: this._id
|
||||
// action: this
|
||||
},
|
||||
type: this.type,
|
||||
hasDamage: !!this.damage?.parts?.length,
|
||||
|
|
@ -229,25 +232,25 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
this.spendCost(config.costs.values);
|
||||
this.spendUses(config.uses);
|
||||
|
||||
// console.log(config)
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/* ROLL */
|
||||
hasRoll() {
|
||||
return this.roll?.type && this.roll?.trait;
|
||||
// return this.roll?.type && this.roll?.trait;
|
||||
return this.roll?.type;
|
||||
}
|
||||
|
||||
async proceedRoll(config) {
|
||||
if (!this.hasRoll()) return config;
|
||||
const modifierValue = this.actor.system.traits[this.roll.trait].value;
|
||||
// const modifierValue = this.actor.system.traits[this.roll.trait].value;
|
||||
config = {
|
||||
...config,
|
||||
roll: {
|
||||
modifiers: [],
|
||||
trait: this.roll?.trait,
|
||||
label: game.i18n.localize(abilities[this.roll.trait].label),
|
||||
// label: game.i18n.localize(abilities[this.roll.trait].label),
|
||||
label: 'Attack',
|
||||
type: this.actionType,
|
||||
difficulty: this.roll?.difficulty
|
||||
}
|
||||
|
|
@ -347,7 +350,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
name: actor.actor.name,
|
||||
img: actor.actor.img,
|
||||
difficulty: actor.actor.system.difficulty,
|
||||
evasion: actor.actor.system.evasion?.value
|
||||
evasion: actor.actor.system.evasion?.total
|
||||
}
|
||||
}
|
||||
/* TARGET */
|
||||
|
|
@ -363,7 +366,6 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
async applyEffects(event, data, force=false) {
|
||||
if(!this.effects?.length || !data.system.targets.length) return;
|
||||
data.system.targets.forEach(async (token) => {
|
||||
// console.log(token, force)
|
||||
if(!token.hit && !force) return;
|
||||
this.effects.forEach(async (e) => {
|
||||
const actor = canvas.tokens.get(token.id)?.actor,
|
||||
|
|
@ -417,7 +419,7 @@ export class DHDamageAction extends DHBaseAction {
|
|||
|
||||
async rollDamage(event, data) {
|
||||
let formula = this.damage.parts.map(p => p.getFormula(this.actor)).join(' + ');
|
||||
|
||||
|
||||
if (!formula || formula == '') return;
|
||||
let roll = { formula: formula, total: formula },
|
||||
bonusDamage = [];
|
||||
|
|
@ -427,7 +429,7 @@ export class DHDamageAction extends DHBaseAction {
|
|||
formula,
|
||||
targets: (data.system?.targets ?? data.targets).map(x => ({ id: x.id, name: x.name, img: x.img, hit: true }))
|
||||
}
|
||||
|
||||
|
||||
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config)
|
||||
}
|
||||
}
|
||||
|
|
@ -479,7 +481,6 @@ export class DHHealingAction extends DHBaseAction {
|
|||
}
|
||||
|
||||
async rollHealing(event, data) {
|
||||
console.log(event, data)
|
||||
let formula = this.healing.value.getFormula(this.actor);
|
||||
|
||||
if (!formula || formula == '') return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue