mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Cost & Range #1
This commit is contained in:
parent
f983ae392f
commit
7f8799f2dc
10 changed files with 112 additions and 47 deletions
|
|
@ -62,6 +62,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
if (!!this.action.effects) context.effects = this.action.effects.map(e => this.action.item.effects.get(e._id));
|
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;
|
if (this.action.damage?.hasOwnProperty('includeBase')) context.hasBaseDamage = !!this.action.parent.damage;
|
||||||
context.getRealIndex = this.getRealIndex.bind(this);
|
context.getRealIndex = this.getRealIndex.bind(this);
|
||||||
|
console.log(context)
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,6 +133,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
data = this.action.toObject();
|
data = this.action.toObject();
|
||||||
data.effects.push({ _id: created._id });
|
data.effects.push({ _id: created._id });
|
||||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||||
|
this.action.item.effects.get(created._id).sheet.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ export default class DhActiveEffectConfig extends ActiveEffectConfig {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
console.log(context, partContext)
|
||||||
|
|
||||||
return partContext;
|
return partContext;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
const context = await super._prepareContext(_options);
|
const context = await super._prepareContext(_options);
|
||||||
context.document = this.document;
|
context.document = this.document;
|
||||||
context.tabs = super._getTabs(this.constructor.TABS);
|
context.tabs = super._getTabs(this.constructor.TABS);
|
||||||
|
console.log(context)
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,16 @@ export const targetTypes = {
|
||||||
id: 'self',
|
id: 'self',
|
||||||
label: 'Self'
|
label: 'Self'
|
||||||
},
|
},
|
||||||
other: {
|
friendly: {
|
||||||
id: 'other',
|
id: 'friendly',
|
||||||
label: 'Other'
|
label: 'Friendly'
|
||||||
|
},
|
||||||
|
adversary: {
|
||||||
|
id: 'adversary',
|
||||||
|
label: 'Adversary'
|
||||||
|
},
|
||||||
|
any: {
|
||||||
|
id: 'any',
|
||||||
|
label: 'Any'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,27 @@ export const abilityCosts = {
|
||||||
},
|
},
|
||||||
stress: {
|
stress: {
|
||||||
id: 'stress',
|
id: 'stress',
|
||||||
label: 'Stress'
|
label: 'DAGGERHEART.HealingType.Stress.Name'
|
||||||
|
},
|
||||||
|
armor: {
|
||||||
|
id: 'armor',
|
||||||
|
label: 'Armor Stack'
|
||||||
|
},
|
||||||
|
hp: {
|
||||||
|
id: 'hp',
|
||||||
|
label: 'DAGGERHEART.HealingType.HitPoints.Name'
|
||||||
|
},
|
||||||
|
prayer: {
|
||||||
|
id: 'prayer',
|
||||||
|
label: 'Prayer Dice'
|
||||||
|
},
|
||||||
|
favor: {
|
||||||
|
id: 'favor',
|
||||||
|
label: 'Favor Points'
|
||||||
|
},
|
||||||
|
slayer: {
|
||||||
|
id: 'slayer',
|
||||||
|
label: 'Slayer Dice'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,6 @@
|
||||||
import { abilities } from '../../config/actorConfig.mjs';
|
import { abilities } from '../../config/actorConfig.mjs';
|
||||||
import { DHActionDiceData, DHDamageData, DHDamageField } from './actionDice.mjs';
|
import { DHActionDiceData, DHDamageData, DHDamageField } from './actionDice.mjs';
|
||||||
|
|
||||||
export default class DHAction extends foundry.abstract.DataModel {
|
|
||||||
static defineSchema() {
|
|
||||||
const fields = foundry.data.fields;
|
|
||||||
return {
|
|
||||||
id: new fields.DocumentIdField(),
|
|
||||||
name: new fields.StringField({ initial: 'New Action' }),
|
|
||||||
damage: new fields.SchemaField({
|
|
||||||
type: new fields.StringField({ choices: SYSTEM.GENERAL.damageTypes, nullable: true, initial: null }),
|
|
||||||
value: new fields.StringField({})
|
|
||||||
}),
|
|
||||||
healing: new fields.SchemaField({
|
|
||||||
type: new fields.StringField({ choices: SYSTEM.GENERAL.healingTypes, nullable: true, initial: null }),
|
|
||||||
value: new fields.StringField()
|
|
||||||
}),
|
|
||||||
conditions: new fields.ArrayField(
|
|
||||||
new fields.SchemaField({
|
|
||||||
name: new fields.StringField(),
|
|
||||||
icon: new fields.StringField(),
|
|
||||||
description: new fields.StringField()
|
|
||||||
})
|
|
||||||
),
|
|
||||||
cost: new fields.SchemaField({
|
|
||||||
type: new fields.StringField({ choices: SYSTEM.GENERAL.abilityCosts, nullable: true, initial: null }),
|
|
||||||
value: new fields.NumberField({ nullable: true, initial: null })
|
|
||||||
}),
|
|
||||||
target: new fields.SchemaField({
|
|
||||||
type: new fields.StringField({
|
|
||||||
choices: SYSTEM.ACTIONS.targetTypes,
|
|
||||||
initial: SYSTEM.ACTIONS.targetTypes.other.id
|
|
||||||
})
|
|
||||||
})
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -57,6 +22,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
_id: new fields.DocumentIdField(),
|
_id: new fields.DocumentIdField(),
|
||||||
type: new fields.StringField({ initial: undefined, readonly: true, required: true }),
|
type: new fields.StringField({ initial: undefined, readonly: true, required: true }),
|
||||||
name: new fields.StringField({ initial: undefined }),
|
name: new fields.StringField({ initial: undefined }),
|
||||||
|
description: new fields.HTMLField(),
|
||||||
img: new fields.FilePathField({ initial: undefined, categories: ['IMAGE'], base64: false }),
|
img: new fields.FilePathField({ initial: undefined, categories: ['IMAGE'], base64: false }),
|
||||||
actionType: new fields.StringField({ choices: SYSTEM.ITEM.actionTypes, initial: 'action', nullable: true }),
|
actionType: new fields.StringField({ choices: SYSTEM.ITEM.actionTypes, initial: 'action', nullable: true }),
|
||||||
cost: new fields.ArrayField(
|
cost: new fields.ArrayField(
|
||||||
|
|
@ -128,6 +94,16 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
async use(event) {
|
async use(event) {
|
||||||
|
if(this.cost?.length) {
|
||||||
|
const hasCost = await this.checkCost();
|
||||||
|
if(!hasCost) return ui.notifications.warn("You don't have the resources to use that action.");
|
||||||
|
}
|
||||||
|
if(this.target?.type) {
|
||||||
|
const hasTarget = await this.checkTarget();
|
||||||
|
}
|
||||||
|
if(this.range) {
|
||||||
|
const hasRange = await this.checkRange();
|
||||||
|
}
|
||||||
if (this.roll.type && this.roll.trait) {
|
if (this.roll.type && this.roll.trait) {
|
||||||
const modifierValue = this.actor.system.traits[this.roll.trait].value;
|
const modifierValue = this.actor.system.traits[this.roll.trait].value;
|
||||||
const config = {
|
const config = {
|
||||||
|
|
@ -156,6 +132,50 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
return this.actor.diceRoll(config);
|
return this.actor.diceRoll(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async checkCost() {
|
||||||
|
if(!this.cost.length || !this.actor) return true;
|
||||||
|
console.log(this.actor, this.cost)
|
||||||
|
return this.cost.reduce((a, c) => a && this.actor.system.resources[c.type]?.value >= (c.value * (c.scalable ? c.step : 1)), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkTarget() {
|
||||||
|
/* targets = Array.from(game.user.targets).map(x => {
|
||||||
|
const target = {
|
||||||
|
id: x.id,
|
||||||
|
name: x.actor.name,
|
||||||
|
img: x.actor.img,
|
||||||
|
difficulty: x.actor.system.difficulty,
|
||||||
|
evasion: x.actor.system.evasion?.value
|
||||||
|
};
|
||||||
|
|
||||||
|
target.hit = target.difficulty ? roll.total >= target.difficulty : roll.total >= target.evasion;
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}); */
|
||||||
|
const targets = targets = Array.from(game.user.targets).map(x => {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
name: this.actor.name,
|
||||||
|
img: x.actor.img,
|
||||||
|
difficulty: x.actor.system.difficulty,
|
||||||
|
evasion: x.actor.system.evasion?.value
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(this.target)
|
||||||
|
if(this.target.type === SYSTEM.ACTIONS.targetTypes.self.id) return this.actor;
|
||||||
|
if(this.target.amount) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkRange() {
|
||||||
|
console.log(this.range)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tmpTargetObject = () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const extraDefineSchema = (field, option) => {
|
const extraDefineSchema = (field, option) => {
|
||||||
|
|
@ -173,8 +193,10 @@ const extraDefineSchema = (field, option) => {
|
||||||
target: new fields.SchemaField({
|
target: new fields.SchemaField({
|
||||||
type: new fields.StringField({
|
type: new fields.StringField({
|
||||||
choices: SYSTEM.ACTIONS.targetTypes,
|
choices: SYSTEM.ACTIONS.targetTypes,
|
||||||
initial: SYSTEM.ACTIONS.targetTypes.other.id
|
initial: SYSTEM.ACTIONS.targetTypes.any.id,
|
||||||
})
|
nullable: true, initial: null
|
||||||
|
}),
|
||||||
|
amount: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 })
|
||||||
}),
|
}),
|
||||||
effects: new fields.ArrayField( // ActiveEffect
|
effects: new fields.ArrayField( // ActiveEffect
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { getTier } from '../../helpers/utils.mjs';
|
import { getTier } from '../../helpers/utils.mjs';
|
||||||
import DHAction from '../action/action.mjs';
|
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
import ActionField from '../fields/actionField.mjs';
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,7 @@ export default class DhpActor extends Actor {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Move to action-scope?
|
//Move to action-scope?
|
||||||
async useAction(action) {
|
/* async useAction(action) {
|
||||||
const userTargets = Array.from(game.user.targets);
|
const userTargets = Array.from(game.user.targets);
|
||||||
const otherTarget = action.target.type === SYSTEM.ACTIONS.targetTypes.other.id;
|
const otherTarget = action.target.type === SYSTEM.ACTIONS.targetTypes.other.id;
|
||||||
if (otherTarget && userTargets.length === 0) {
|
if (otherTarget && userTargets.length === 0) {
|
||||||
|
|
@ -614,5 +614,5 @@ export default class DhpActor extends Actor {
|
||||||
|
|
||||||
cls.create(msg.toObject());
|
cls.create(msg.toObject());
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,14 @@
|
||||||
{{formField fields.actionType value=source.actionType label="Type" name="actionType" localize=true}}
|
{{formField fields.actionType value=source.actionType label="Type" name="actionType" localize=true}}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{#if fields.roll}}{{> 'systems/daggerheart/templates/views/actionTypes/roll.hbs' fields=fields.roll.fields source=source.roll}}{{/if}}
|
<fieldset class="action-category">
|
||||||
|
<legend class="action-category-label" data-action="toggleSection" data-section="identity">
|
||||||
|
<div>Description</div>
|
||||||
|
</legend>
|
||||||
|
<div class="action-category-data open">
|
||||||
|
{{formInput fields.description value=source.description name="description" }}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab {{this.tabs.config.cssClass}}" data-group="primary" data-tab="config">
|
<div class="tab {{this.tabs.config.cssClass}}" data-group="primary" data-tab="config">
|
||||||
{{> 'systems/daggerheart/templates/views/actionTypes/uses.hbs' fields=fields.uses.fields source=source.uses}}
|
{{> 'systems/daggerheart/templates/views/actionTypes/uses.hbs' fields=fields.uses.fields source=source.uses}}
|
||||||
|
|
@ -30,6 +37,7 @@
|
||||||
{{#if fields.target}}{{> 'systems/daggerheart/templates/views/actionTypes/range-target.hbs' fields=(object range=fields.range target=fields.target.fields) source=(object target=source.target range=source.range)}}{{/if}}
|
{{#if fields.target}}{{> 'systems/daggerheart/templates/views/actionTypes/range-target.hbs' fields=(object range=fields.range target=fields.target.fields) source=(object target=source.target range=source.range)}}{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="tab {{this.tabs.effect.cssClass}}" data-group="primary" data-tab="effect">
|
<div class="tab {{this.tabs.effect.cssClass}}" data-group="primary" data-tab="effect">
|
||||||
|
{{#if fields.roll}}{{> 'systems/daggerheart/templates/views/actionTypes/roll.hbs' fields=fields.roll.fields source=source.roll}}{{/if}}
|
||||||
{{#if fields.damage}}{{> 'systems/daggerheart/templates/views/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=source.damage}}{{/if}}
|
{{#if fields.damage}}{{> 'systems/daggerheart/templates/views/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=source.damage}}{{/if}}
|
||||||
{{#if fields.healing}}{{> 'systems/daggerheart/templates/views/actionTypes/healing.hbs' fields=fields.healing.fields source=source.healing}}{{/if}}
|
{{#if fields.healing}}{{> 'systems/daggerheart/templates/views/actionTypes/healing.hbs' fields=fields.healing.fields source=source.healing}}{{/if}}
|
||||||
{{#if fields.resource}}{{> 'systems/daggerheart/templates/views/actionTypes/resource.hbs' fields=fields.resource.fields source=source.resource}}{{/if}}
|
{{#if fields.resource}}{{> 'systems/daggerheart/templates/views/actionTypes/resource.hbs' fields=fields.resource.fields source=source.resource}}{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,12 @@
|
||||||
</div>
|
</div>
|
||||||
{{#if fields.target}}
|
{{#if fields.target}}
|
||||||
<div class="action-category-data open">
|
<div class="action-category-data open">
|
||||||
{{formField fields.target.type value=source.target.type label="Target" name="target.type" localize=true}}
|
<div class="multi-display">
|
||||||
|
{{#if (and source.target.type (not (eq source.target.type 'self')))}}
|
||||||
|
{{ formField fields.target.amount value=source.target.amount label="Amount" name="target.amount" }}
|
||||||
|
{{/if}}
|
||||||
|
{{ formField fields.target.type value=source.target.type label="Target" name="target.type" localize=true }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue