Changed from 'area' to 'areas'

This commit is contained in:
WBHarry 2026-04-21 19:00:47 +02:00
parent 06535b0e91
commit 6d355e342e
14 changed files with 27 additions and 29 deletions

View file

@ -28,7 +28,7 @@ export default class DHActionConfig extends DHActionBaseConfig {
game.system.api.data.activeEffects.BaseEffect.getDefaultObject({ transfer: false })
]);
if (areaIndex !== undefined) data.area[areaIndex].effects.push(created[0]._id);
if (areaIndex !== undefined) data.areas[areaIndex].effects.push(created[0]._id);
else data.effects.push({ _id: created[0]._id });
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
this.action.item.effects.get(created[0]._id).sheet.render(true);
@ -58,9 +58,9 @@ export default class DHActionConfig extends DHActionBaseConfig {
const { areaIndex, index } = button.dataset;
let effectId = null;
if (areaIndex !== undefined) {
effectId = this.action.area[areaIndex].effects[index];
effectId = this.action.areas[areaIndex].effects[index];
const data = this.action.toObject();
data.area[areaIndex].effects.splice(index, 1);
data.areas[areaIndex].effects.splice(index, 1);
this.constructor.updateForm.call(this, null, null, { object: foundry.utils.flattenObject(data) });
} else {
effectId = this.action.effects[index]._id;

View file

@ -40,7 +40,7 @@ export default class DHActionSettingsConfig extends DHActionBaseConfig {
this.sheetUpdate(data, effectData);
this.effects = [...this.effects, effectData];
if (areaIndex !== undefined) data.area[areaIndex].effects.push(effectData.id);
if (areaIndex !== undefined) data.areas[areaIndex].effects.push(effectData.id);
else data.effects.push({ _id: effectData.id });
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
@ -51,9 +51,9 @@ export default class DHActionSettingsConfig extends DHActionBaseConfig {
const { areaIndex, index } = button.dataset;
let effectId = null;
if (areaIndex !== undefined) {
effectId = this.action.area[areaIndex].effects[index];
effectId = this.action.areas[areaIndex].effects[index];
const data = this.action.toObject();
data.area[areaIndex].effects.splice(index, 1);
data.areas[areaIndex].effects.splice(index, 1);
this.constructor.updateForm.call(this, null, null, { object: foundry.utils.flattenObject(data) });
} else {
effectId = this.action.effects[index]._id;

View file

@ -107,17 +107,16 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
const settings = canvas.scene?.rangeSettings;
const rangeNumber = Number(range);
const length =
(!Number.isNaN(rangeNumber) ? rangeNumber : settings ? settings[range] : 0) * dimensionConstant;
const length = (!Number.isNaN(rangeNumber) ? rangeNumber : settings ? settings[range] : 0) * dimensionConstant;
/*----*/
const shapeData = {
...canvas.mousePosition,
type: type,
direction: direction ?? 0,
direction: direction ?? 0
};
switch(type) {
switch (type) {
case rectangle.id:
shapeData.width = length;
shapeData.height = length;

View file

@ -15,7 +15,7 @@ const fields = foundry.data.fields;
*/
export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel) {
static extraSchemas = ['area', 'cost', 'uses', 'range'];
static extraSchemas = ['areas', 'cost', 'uses', 'range'];
/** @inheritDoc */
static defineSchema() {

View file

@ -1,4 +1,4 @@
export { default as AreaField } from './areaField.mjs';
export { default as AreasField } from './areasField.mjs';
export { default as CostField } from './costField.mjs';
export { default as CountdownField } from './countdownField.mjs';
export { default as UsesField } from './usesField.mjs';

View file

@ -1,6 +1,6 @@
const fields = foundry.data.fields;
export default class AreaField extends fields.ArrayField {
export default class AreasField extends fields.ArrayField {
/**
* Action Workflow order
*/

View file

@ -281,7 +281,7 @@ export function ActionMixin(Base) {
name: this.name,
img: this.baseAction ? this.parent.parent.img : this.img,
tags: this.tags ? this.tags : ['Spell', 'Arcana', 'Lv 10'],
area: this.area,
areas: this.areas,
summon: this.summon
},
source: {

View file

@ -145,7 +145,7 @@ export default class DHRoll extends Roll {
roll: this,
parent: chatData.parent,
targetMode: chatData.targetMode,
areas: chatData.action?.area,
areas: chatData.action?.areas,
metagamingSettings
});
}

View file

@ -282,14 +282,14 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
);
};
if (this.system.action.area.length === 1) createArea(this.system.action.area[0]);
else if (this.system.action.area.length > 1) {
if (this.system.action.areas.length === 1) createArea(this.system.action.areas[0]);
else if (this.system.action.areas.length > 1) {
new foundry.applications.ux.ContextMenu.implementation(
event.target,
'.action-areas',
this.system.action.area.map((area, index) => ({
this.system.action.areas.map(area => ({
label: area.name,
onClick: () => createArea(this.system.action.area[index])
onClick: () => createArea(area)
})),
{
jQuery: false,

View file

@ -29,7 +29,7 @@ export const preloadHandlebarsTemplates = async function () {
'systems/daggerheart/templates/actionTypes/uses.hbs',
'systems/daggerheart/templates/actionTypes/roll.hbs',
'systems/daggerheart/templates/actionTypes/save.hbs',
'systems/daggerheart/templates/actionTypes/area.hbs',
'systems/daggerheart/templates/actionTypes/areas.hbs',
'systems/daggerheart/templates/actionTypes/cost.hbs',
'systems/daggerheart/templates/actionTypes/range-target.hbs',
'systems/daggerheart/templates/actionTypes/effect.hbs',

View file

@ -1,4 +1,4 @@
<fieldset class="one-column" data-key="area">
<fieldset class="one-column" data-key="areas">
<legend>
{{localize "DAGGERHEART.ACTIONS.Config.area.sectionTitle"}}
<a><i class="fa-solid fa-plus icon-button" data-action="addElement"></i></a>
@ -7,13 +7,13 @@
{{#each source as |area index|}}
{{#unless @first}}<line-div></line-div>{{/unless}}
<div class="nest-inputs">
{{formField ../fields.name value=area.name name=(concat "area." index ".name") localize=true}}
{{formField ../fields.name value=area.name name=(concat "areas." index ".name") localize=true}}
<a class="btn" data-tooltip="{{localize "CONTROLS.CommonDelete"}}" data-action="removeElement" data-index="{{index}}"><i class="fas fa-trash"></i></a>
</div>
<div class="nest-inputs">
{{formField ../fields.type value=area.type name=(concat "area." index ".type") localize=true}}
{{formField ../fields.shape value=area.shape name=(concat "area." index ".shape") localize=true}}
{{formField ../fields.size value=area.size name=(concat "area." index ".size") localize=true}}
{{formField ../fields.type value=area.type name=(concat "areas." index ".type") localize=true}}
{{formField ../fields.shape value=area.shape name=(concat "areas." index ".shape") localize=true}}
{{formField ../fields.size value=area.size name=(concat "areas." index ".size") localize=true}}
</div>
<div class="sub-section-header">
@ -22,7 +22,7 @@
</div>
<div class="two-columns even" style="width: 100%;">
{{#each area.effects as |effectId index|}}
<input type="hidden" name={{concat "area." @../key ".effects." index}} value="{{effectId}}">
<input type="hidden" name={{concat "areas." @../key ".effects." index}} value="{{effectId}}">
<div class="inventory-item single-img bordered" data-effect-id="{{effectId}}" data-area-index="{{index}}" data-action="editEffect">
<div class="inventory-item-header">

View file

@ -6,5 +6,5 @@
{{> 'systems/daggerheart/templates/actionTypes/uses.hbs' fields=fields.uses.fields source=source.uses}}
{{> 'systems/daggerheart/templates/actionTypes/cost.hbs' fields=fields.cost.element.fields source=source.cost costOptions=costOptions}}
{{> 'systems/daggerheart/templates/actionTypes/range-target.hbs' fields=(object range=fields.range target=fields.target.fields) source=(object target=source.target range=source.range)}}
{{> 'systems/daggerheart/templates/actionTypes/area.hbs' fields=fields.area.element.fields source=source.area}}
{{> 'systems/daggerheart/templates/actionTypes/areas.hbs' fields=fields.areas.element.fields source=source.areas}}
</section>

View file

@ -24,7 +24,6 @@
<span>{{localize "DAGGERHEART.GENERAL.damage"}}</span>
</button>
{{/if}}
{{!-- {{#if action.cost.value}}<div class="ability-card-action-cost">{{action.cost.value}} {{action.cost.type}}</div>{{/if}} --}}
{{/each}}
</footer>
</div>

View file

@ -26,7 +26,7 @@
{{/if}}
</div>
</details>
{{#if action.area.length}}
{{#if action.areas.length}}
<div class="roll-buttons action-roll-buttons">
<button class="action-areas end-button"><i class="fa-solid fa-crosshairs"></i></button>
</div>