Merged with main

This commit is contained in:
WBHarry 2025-07-02 23:50:29 +02:00
commit 978d45b931
44 changed files with 653 additions and 373 deletions

View file

@ -1,4 +1,3 @@
import CostSelectionDialog from '../../applications/costSelectionDialog.mjs';
import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs';
import DhpActor from '../../documents/actor.mjs';
import D20RollDialog from '../../dialogs/d20RollDialog.mjs';
@ -349,7 +348,9 @@ export class DHBaseAction extends foundry.abstract.DataModel {
label: 'Attack',
type: this.actionType,
difficulty: this.roll?.difficulty,
formula: this.roll.getFormula()
formula: this.roll.getFormula(),
bonus: this.roll.bonus,
advantage: SYSTEM.ACTIONS.advandtageState[this.roll.advState].value
};
if (this.roll?.type === 'diceSet') roll.lite = true;
@ -378,7 +379,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
/* ROLL */
get hasRoll() {
return !!this.roll?.type;
return !!this.roll?.type || !!this.roll?.bonus;
}
/* ROLL */

View file

@ -11,7 +11,8 @@ export class DHActionRollData extends foundry.abstract.DataModel {
type: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.GENERAL.rollTypes }),
trait: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.ACTOR.abilities }),
difficulty: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true }),
advState: new fields.StringField({ choices: SYSTEM.ACTIONS.advandtageState, initial: 'neutral' }),
diceRolling: new fields.SchemaField({
multiplier: new fields.StringField({
choices: SYSTEM.GENERAL.diceSetNumbers,
@ -62,7 +63,7 @@ export class DHActionDiceData extends foundry.abstract.DataModel {
label: 'Multiplier'
}),
flatMultiplier: new fields.NumberField({ nullable: true, initial: 1, label: 'Flat Multiplier' }),
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Formula' }),
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Dice' }),
bonus: new fields.NumberField({ nullable: true, initial: null, label: 'Bonus' }),
custom: new fields.SchemaField({
enabled: new fields.BooleanField({ label: 'Custom Formula' }),

View file

@ -1,4 +1,4 @@
import { DHBaseAction } from "../action/action.mjs";
import { DHBaseAction } from '../action/action.mjs';
const fields = foundry.data.fields;
@ -42,6 +42,9 @@ export default class DHAdversaryRoll extends foundry.abstract.TypeDataModel {
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;
this.currentTargets =
this.targetSelection !== true
? Array.from(game.user.targets).map(t => DHBaseAction.formatTarget(t))
: this.targets;
}
}

View file

@ -3,7 +3,7 @@ export default class DHDamageRoll extends foundry.abstract.TypeDataModel {
const fields = foundry.data.fields;
return {
messageType: new fields.StringField({initial: 'damage'}),
messageType: new fields.StringField({ initial: 'damage' }),
title: new fields.StringField(),
roll: new fields.DataField({}),
targets: new fields.ArrayField(
@ -28,7 +28,7 @@ export default class DHDamageRoll extends foundry.abstract.TypeDataModel {
action: new fields.StringField(),
message: new fields.StringField()
}),
directDamage: new fields.BooleanField({initial: true})
directDamage: new fields.BooleanField({ initial: true })
};
}
@ -38,6 +38,9 @@ export default class DHDamageRoll extends foundry.abstract.TypeDataModel {
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;
this.currentTargets =
this.targetSelection !== true
? Array.from(game.user.targets).map(t => DHBaseAction.formatTarget(t))
: this.targets;
}
}

View file

@ -1,4 +1,4 @@
import DHAdversaryRoll from "./adversaryRoll.mjs";
import DHAdversaryRoll from './adversaryRoll.mjs';
export default class DHDualityRoll extends DHAdversaryRoll {
get messageTemplate() {

View file

@ -36,7 +36,8 @@ class DhCountdownData extends foundry.abstract.DataModel {
})
})
)
})
}),
window: new fields.SchemaField({})
};
}

View file

@ -1,9 +1,9 @@
import { actionsTypes } from '../action/_module.mjs';
// import { actionsTypes } from '../action/_module.mjs';
// Temporary Solution
export default class ActionField extends foundry.data.fields.ObjectField {
getModel(value) {
return actionsTypes[value.type] ?? actionsTypes.attack;
return game.system.api.models.actionsTypes[value.type] ?? game.system.api.models.actionsTypes.attack;
}
/* -------------------------------------------- */

View file

@ -1,4 +1,4 @@
import { actionsTypes } from '../action/_module.mjs';
// import { actionsTypes } from '../action/_module.mjs';
/**
* Describes metadata about the item data model type
@ -60,7 +60,8 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
const actionType = {
weapon: 'attack'
}[this.constructor.metadata.type],
cls = actionsTypes.attack,
cls = game.system.api.models.actionsTypes[actionType],
// cls = actionsTypes.attack,
action = new cls(
{
_id: foundry.utils.randomID(),