mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 16:09:03 +01:00
Merged with main
This commit is contained in:
commit
130b2bf100
65 changed files with 1085 additions and 860 deletions
|
|
@ -12,7 +12,10 @@ export default class CostField extends fields.ArrayField {
|
|||
value: new fields.NumberField({ nullable: true, initial: 1, min: 0 }),
|
||||
scalable: new fields.BooleanField({ initial: false }),
|
||||
step: new fields.NumberField({ nullable: true, initial: null }),
|
||||
consumeOnSuccess: new fields.BooleanField({ initial: false, label: "DAGGERHEART.ACTIONS.Settings.consumeOnSuccess.label" })
|
||||
consumeOnSuccess: new fields.BooleanField({
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.ACTIONS.Settings.consumeOnSuccess.label'
|
||||
})
|
||||
});
|
||||
super(element, options, context);
|
||||
}
|
||||
|
|
@ -47,6 +50,7 @@ export default class CostField extends fields.ArrayField {
|
|||
static hasCost(costs) {
|
||||
const realCosts = CostField.getRealCosts.call(this, costs),
|
||||
hasFearCost = realCosts.findIndex(c => c.key === 'fear');
|
||||
|
||||
if (hasFearCost > -1) {
|
||||
const fearCost = realCosts.splice(hasFearCost, 1)[0];
|
||||
if (
|
||||
|
|
@ -70,7 +74,9 @@ export default class CostField extends fields.ArrayField {
|
|||
}
|
||||
|
||||
static getResources(costs) {
|
||||
const actorResources = this.actor.system.resources;
|
||||
const actorResources = foundry.utils.deepClone(this.actor.system.resources);
|
||||
if (this.actor.system.partner)
|
||||
actorResources.hope = foundry.utils.deepClone(this.actor.system.partner.system.resources.hope);
|
||||
const itemResources = {};
|
||||
for (let itemResource of costs) {
|
||||
if (itemResource.keyIsID) {
|
||||
|
|
@ -89,7 +95,13 @@ export default class CostField extends fields.ArrayField {
|
|||
|
||||
static getRealCosts(costs) {
|
||||
const realCosts = costs?.length ? costs.filter(c => c.enabled) : [];
|
||||
return realCosts;
|
||||
let mergedCosts = [];
|
||||
realCosts.forEach(c => {
|
||||
const getCost = Object.values(mergedCosts).find(gc => gc.key === c.key);
|
||||
if (getCost) getCost.total += c.total;
|
||||
else mergedCosts.push(c);
|
||||
});
|
||||
return mergedCosts;
|
||||
}
|
||||
|
||||
static formatMax(max) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export default class TargetField extends fields.SchemaField {
|
|||
|
||||
static prepareConfig(config) {
|
||||
if (!this.target?.type) return [];
|
||||
config.hasTarget = true;
|
||||
let targets;
|
||||
if (this.target?.type === CONFIG.DH.GENERAL.targetTypes.self.id)
|
||||
targets = [this.actor.token ?? this.actor.prototypeToken];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue