mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Beastform Improvements (#294)
* BeastformEffect is editable. Added SubjectTexture field. * Using handlebars disabled helper
This commit is contained in:
parent
61f04df765
commit
861dfd977d
7 changed files with 81 additions and 32 deletions
|
|
@ -1129,6 +1129,7 @@
|
||||||
"examples": { "label": "Examples" },
|
"examples": { "label": "Examples" },
|
||||||
"advantageOn": { "label": "Gain Advantage On" },
|
"advantageOn": { "label": "Gain Advantage On" },
|
||||||
"tokenImg": { "label": "Token Image" },
|
"tokenImg": { "label": "Token Image" },
|
||||||
|
"tokenRingImg": { "label": "Subject Texture" },
|
||||||
"tokenSize": {
|
"tokenSize": {
|
||||||
"placeholder": "Using character dimensions",
|
"placeholder": "Using character dimensions",
|
||||||
"height": { "label": "Height" },
|
"height": { "label": "Height" },
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,17 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
* @param {HTMLElement} el
|
* @param {HTMLElement} el
|
||||||
* @returns {foundry.documents.Item?}
|
* @returns {foundry.documents.Item?}
|
||||||
*/
|
*/
|
||||||
const getItem = el => this.actor.items.get(el.closest('[data-item-id]')?.dataset.itemId);
|
const getItem = element => {
|
||||||
|
const listElement = (element.target ?? element).closest('[data-item-id]');
|
||||||
|
const itemId = listElement.dataset.itemId;
|
||||||
|
|
||||||
|
switch (listElement.dataset.type) {
|
||||||
|
case 'effect':
|
||||||
|
return this.document.effects.get(itemId);
|
||||||
|
default:
|
||||||
|
return this.document.items.get(itemId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,17 @@ export default class BeastformSheet extends DHBaseItemSheet {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**@inheritdoc */
|
/**@inheritdoc */
|
||||||
async _preparePartContext(partId, context) {
|
async _prepareContext(_options) {
|
||||||
await super._preparePartContext(partId, context);
|
const context = await super._prepareContext(_options);
|
||||||
|
|
||||||
|
context.document = context.document.toObject();
|
||||||
|
context.document.effects = this.document.effects.map(effect => {
|
||||||
|
const data = effect.toObject();
|
||||||
|
data.id = effect.id;
|
||||||
|
if (effect.type === 'beastform') data.mandatory = true;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,11 @@ export default class BeastformEffect extends foundry.abstract.TypeDataModel {
|
||||||
base64: false,
|
base64: false,
|
||||||
nullable: true
|
nullable: true
|
||||||
}),
|
}),
|
||||||
|
tokenRingImg: new fields.FilePathField({
|
||||||
|
initial: 'icons/svg/mystery-man.svg',
|
||||||
|
categories: ['IMAGE'],
|
||||||
|
base64: false
|
||||||
|
}),
|
||||||
tokenSize: new fields.SchemaField({
|
tokenSize: new fields.SchemaField({
|
||||||
height: new fields.NumberField({ integer: true, nullable: true }),
|
height: new fields.NumberField({ integer: true, nullable: true }),
|
||||||
width: new fields.NumberField({ integer: true, nullable: true })
|
width: new fields.NumberField({ integer: true, nullable: true })
|
||||||
|
|
@ -28,6 +33,11 @@ export default class BeastformEffect extends foundry.abstract.TypeDataModel {
|
||||||
width: this.characterTokenData.tokenSize.width,
|
width: this.characterTokenData.tokenSize.width,
|
||||||
texture: {
|
texture: {
|
||||||
src: this.characterTokenData.tokenImg
|
src: this.characterTokenData.tokenImg
|
||||||
|
},
|
||||||
|
ring: {
|
||||||
|
subject: {
|
||||||
|
texture: this.characterTokenData.tokenRingImg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayFie
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
|
|
||||||
export default class DHBeastform extends BaseDataItem {
|
export default class DHBeastform extends BaseDataItem {
|
||||||
static LOCALIZATION_PREFIXES = ['DAGGERHEART.Sheets.Beastform'];
|
static LOCALIZATION_PREFIXES = ['DAGGERHEART.ITEMS.Beastform'];
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
static get metadata() {
|
static get metadata() {
|
||||||
|
|
@ -29,12 +29,17 @@ export default class DHBeastform extends BaseDataItem {
|
||||||
categories: ['IMAGE'],
|
categories: ['IMAGE'],
|
||||||
base64: false
|
base64: false
|
||||||
}),
|
}),
|
||||||
|
tokenRingImg: new fields.FilePathField({
|
||||||
|
initial: 'icons/svg/mystery-man.svg',
|
||||||
|
categories: ['IMAGE'],
|
||||||
|
base64: false
|
||||||
|
}),
|
||||||
tokenSize: new fields.SchemaField({
|
tokenSize: new fields.SchemaField({
|
||||||
height: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true }),
|
height: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true }),
|
||||||
width: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true })
|
width: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true })
|
||||||
}),
|
}),
|
||||||
examples: new fields.StringField(),
|
examples: new fields.StringField(),
|
||||||
advantageOn: new fields.ArrayField(new fields.StringField()),
|
advantageOn: new fields.StringField(),
|
||||||
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -56,40 +61,54 @@ export default class DHBeastform extends BaseDataItem {
|
||||||
'Item',
|
'Item',
|
||||||
this.features.map(x => x.toObject())
|
this.features.map(x => x.toObject())
|
||||||
);
|
);
|
||||||
const effects = await this.parent.parent.createEmbeddedDocuments(
|
|
||||||
|
const extraEffects = await this.parent.parent.createEmbeddedDocuments(
|
||||||
'ActiveEffect',
|
'ActiveEffect',
|
||||||
this.parent.effects.map(x => x.toObject())
|
this.parent.effects.filter(x => x.type !== 'beastform').map(x => x.toObject())
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.parent.parent.createEmbeddedDocuments('ActiveEffect', [
|
const beastformEffect = this.parent.effects.find(x => x.type === 'beastform');
|
||||||
{
|
await beastformEffect.updateSource({
|
||||||
type: 'beastform',
|
system: {
|
||||||
name: game.i18n.localize('DAGGERHEART.ITEMS.Beastform.beastformEffect'),
|
characterTokenData: {
|
||||||
img: 'icons/creatures/abilities/paw-print-pair-purple.webp',
|
tokenImg: this.parent.parent.prototypeToken.texture.src,
|
||||||
system: {
|
tokenRingImg: this.parent.parent.prototypeToken.ring.subject.texture,
|
||||||
isBeastform: true,
|
tokenSize: {
|
||||||
characterTokenData: {
|
height: this.parent.parent.prototypeToken.height,
|
||||||
tokenImg: this.parent.parent.prototypeToken.texture.src,
|
width: this.parent.parent.prototypeToken.width
|
||||||
tokenSize: {
|
}
|
||||||
height: this.parent.parent.prototypeToken.height,
|
},
|
||||||
width: this.parent.parent.prototypeToken.width
|
advantageOn: this.advantageOn,
|
||||||
}
|
featureIds: features.map(x => x.id),
|
||||||
},
|
effectIds: extraEffects.map(x => x.id)
|
||||||
advantageOn: this.advantageOn,
|
|
||||||
featureIds: features.map(x => x.id),
|
|
||||||
effectIds: effects.map(x => x.id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]);
|
});
|
||||||
|
|
||||||
|
await this.parent.parent.createEmbeddedDocuments('ActiveEffect', [beastformEffect.toObject()]);
|
||||||
|
|
||||||
await updateActorTokens(this.parent.parent, {
|
await updateActorTokens(this.parent.parent, {
|
||||||
height: this.tokenSize.height,
|
height: this.tokenSize.height,
|
||||||
width: this.tokenSize.width,
|
width: this.tokenSize.width,
|
||||||
texture: {
|
texture: {
|
||||||
src: this.tokenImg
|
src: this.tokenImg
|
||||||
|
},
|
||||||
|
ring: {
|
||||||
|
subject: {
|
||||||
|
texture: this.tokenRingImg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onCreate() {
|
||||||
|
this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||||
|
{
|
||||||
|
type: 'beastform',
|
||||||
|
name: game.i18n.localize('DAGGERHEART.ITEMS.Beastform.beastformEffect'),
|
||||||
|
img: 'icons/creatures/abilities/paw-print-pair-purple.webp'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<span>{{effect.name}}</span>
|
<span>{{effect.name}}</span>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<a data-action="editDoc" data-type="ActiveEffect" data-doc-id="{{effect.id}}"><i class="fa-solid fa-pen-to-square"></i></a>
|
<a data-action="editDoc" data-type="ActiveEffect" data-doc-id="{{effect.id}}"><i class="fa-solid fa-pen-to-square"></i></a>
|
||||||
<a data-action="deleteDoc" data-type="ActiveEffect" data-doc-id="{{effect.id}}"><i class="fa-solid fa-trash"></i></a>
|
<a data-action="deleteDoc" data-type="ActiveEffect" data-doc-id="{{effect.id}}" {{disabled effect.mandatory}}><i class="fa-solid fa-trash icon-button {{disabled effect.mandatory}}"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,7 @@
|
||||||
{{formGroup systemFields.examples value=source.system.examples localize=true}}
|
{{formGroup systemFields.examples value=source.system.examples localize=true}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<fieldset class="two-columns">
|
{{formGroup systemFields.advantageOn value=source.system.advantageOn localize=true}}
|
||||||
<legend>{{localize "DAGGERHEART.ITEMS.Beastform.FIELDS.advantageOn.label"}}</legend>
|
|
||||||
|
|
||||||
{{!-- {{formGroup systemFields.examples value=source.system.examples localize=true}} --}}
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset class="two-columns even">
|
<fieldset class="two-columns even">
|
||||||
<legend>{{localize "DAGGERHEART.ITEMS.Beastform.tokenTitle"}}</legend>
|
<legend>{{localize "DAGGERHEART.ITEMS.Beastform.tokenTitle"}}</legend>
|
||||||
|
|
@ -21,6 +17,10 @@
|
||||||
{{formGroup systemFields.tokenImg value=source.system.tokenImg localize=true}}
|
{{formGroup systemFields.tokenImg value=source.system.tokenImg localize=true}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="full-width">
|
||||||
|
{{formGroup systemFields.tokenRingImg value=source.system.tokenRingImg localize=true}}
|
||||||
|
</div>
|
||||||
|
|
||||||
{{formGroup systemFields.tokenSize.fields.height value=source.system.tokenSize.height localize=true placeholder=(localize "DAGGERHEART.ITEMS.Beastform.FIELDS.tokenSize.placeholder") }}
|
{{formGroup systemFields.tokenSize.fields.height value=source.system.tokenSize.height localize=true placeholder=(localize "DAGGERHEART.ITEMS.Beastform.FIELDS.tokenSize.placeholder") }}
|
||||||
{{formGroup systemFields.tokenSize.fields.width value=source.system.tokenSize.width localize=true placeholder=(localize "DAGGERHEART.ITEMS.Beastform.FIELDS.tokenSize.placeholder")}}
|
{{formGroup systemFields.tokenSize.fields.width value=source.system.tokenSize.width localize=true placeholder=(localize "DAGGERHEART.ITEMS.Beastform.FIELDS.tokenSize.placeholder")}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue