mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-23 16:03:39 +02:00
Items now copy over their features to Character
This commit is contained in:
parent
261867a4cc
commit
3d735e6a09
13 changed files with 167 additions and 103 deletions
23
lang/en.json
23
lang/en.json
|
|
@ -966,29 +966,6 @@
|
||||||
"Description": "This weapon can also be used with these statistics—{characterTrait}, {range}, {damage}."
|
"Description": "This weapon can also be used with these statistics—{characterTrait}, {range}, {damage}."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Feature": {
|
|
||||||
"Type": {
|
|
||||||
"ancestry": "Ancestry",
|
|
||||||
"community": "Community",
|
|
||||||
"class": "Class",
|
|
||||||
"subclass": "Subclass",
|
|
||||||
"classHope": "Class Hope",
|
|
||||||
"domainCard": "Domain Card",
|
|
||||||
"equipment": "Equipment"
|
|
||||||
},
|
|
||||||
"ValueType": {
|
|
||||||
"Normal": "Normal",
|
|
||||||
"Input": "Input",
|
|
||||||
"Dice": "Dice"
|
|
||||||
},
|
|
||||||
"Max": "Max",
|
|
||||||
"NewEffect": "New Effect"
|
|
||||||
},
|
|
||||||
"FeatureType": {
|
|
||||||
"Normal": "Normal",
|
|
||||||
"Input": "Input",
|
|
||||||
"Ticks": "Ticks"
|
|
||||||
},
|
|
||||||
"Application": {
|
"Application": {
|
||||||
"Downtime": {
|
"Downtime": {
|
||||||
"TakeDowntime": "Take Downtime"
|
"TakeDowntime": "Take Downtime"
|
||||||
|
|
|
||||||
|
|
@ -349,8 +349,8 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
||||||
}
|
}
|
||||||
|
|
||||||
static async finish() {
|
static async finish() {
|
||||||
const embeddedAncestries = await this.character.createEmbeddedDocuments('Item', [this.setup.ancestry]);
|
await this.character.createEmbeddedDocuments('Item', [this.setup.ancestry]);
|
||||||
const embeddedCommunities = await this.character.createEmbeddedDocuments('Item', [this.setup.community]);
|
await this.character.createEmbeddedDocuments('Item', [this.setup.community]);
|
||||||
await this.character.createEmbeddedDocuments('Item', [this.setup.class]);
|
await this.character.createEmbeddedDocuments('Item', [this.setup.class]);
|
||||||
await this.character.createEmbeddedDocuments('Item', [this.setup.subclass]);
|
await this.character.createEmbeddedDocuments('Item', [this.setup.subclass]);
|
||||||
await this.character.createEmbeddedDocuments('Item', Object.values(this.setup.domainCards));
|
await this.character.createEmbeddedDocuments('Item', Object.values(this.setup.domainCards));
|
||||||
|
|
@ -379,9 +379,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
||||||
await this.character.update({
|
await this.character.update({
|
||||||
system: {
|
system: {
|
||||||
traits: this.setup.traits,
|
traits: this.setup.traits,
|
||||||
experiences: this.setup.experiences,
|
experiences: this.setup.experiences
|
||||||
ancestry: embeddedAncestries[0].uuid,
|
|
||||||
community: embeddedCommunities[0].uuid
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -307,13 +307,9 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
getItem(element) {
|
getItem(element) {
|
||||||
const listElement = (element.target ?? element).closest('[data-item-id]');
|
const listElement = (element.target ?? element).closest('[data-item-id]');
|
||||||
const itemId = listElement.dataset.itemId;
|
const itemId = listElement.dataset.itemId;
|
||||||
if (listElement.dataset.type === 'effect') {
|
return listElement.dataset.type === 'effect'
|
||||||
return this.document.effects.get(itemId);
|
? this.document.effects.get(itemId)
|
||||||
} else if (['armor', 'weapon', 'feature', 'consumable', 'miscellaneous'].includes(listElement.dataset.type)) {
|
: this.document.items.get(itemId);
|
||||||
return this.document.items.get(itemId);
|
|
||||||
} else {
|
|
||||||
return this.document.system[listElement.dataset.type].system.actions.find(x => x.id === itemId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static triggerContextMenu(event, button) {
|
static triggerContextMenu(event, button) {
|
||||||
|
|
|
||||||
|
|
@ -656,31 +656,47 @@ export const weaponFeatures = {
|
||||||
export const featureTypes = {
|
export const featureTypes = {
|
||||||
ancestry: {
|
ancestry: {
|
||||||
id: 'ancestry',
|
id: 'ancestry',
|
||||||
label: 'DAGGERHEART.Feature.Type.ancestry'
|
label: 'TYPES.Item.ancestry'
|
||||||
},
|
},
|
||||||
community: {
|
community: {
|
||||||
id: 'community',
|
id: 'community',
|
||||||
label: 'DAGGERHEART.Feature.Type.community'
|
label: 'TYPES.Item.community'
|
||||||
|
},
|
||||||
|
companion: {
|
||||||
|
id: 'companion',
|
||||||
|
label: 'TYPES.Actor.companion'
|
||||||
},
|
},
|
||||||
class: {
|
class: {
|
||||||
id: 'class',
|
id: 'class',
|
||||||
label: 'DAGGERHEART.Feature.Type.class'
|
label: 'TYPES.Item.class'
|
||||||
},
|
},
|
||||||
subclass: {
|
subclass: {
|
||||||
id: 'subclass',
|
id: 'subclass',
|
||||||
label: 'DAGGERHEART.Feature.Type.subclass'
|
label: 'TYPES.Item.subclass'
|
||||||
},
|
|
||||||
classHope: {
|
|
||||||
id: 'classHope',
|
|
||||||
label: 'DAGGERHEART.Feature.Type.classHope'
|
|
||||||
},
|
},
|
||||||
domainCard: {
|
domainCard: {
|
||||||
id: 'domainCard',
|
id: 'domainCard',
|
||||||
label: 'DAGGERHEART.Feature.Type.domainCard'
|
label: 'TYPES.Item.domainCard'
|
||||||
},
|
},
|
||||||
equipment: {
|
armor: {
|
||||||
id: 'equipment',
|
id: 'armor',
|
||||||
label: 'DAGGERHEART.Feature.Type.equipment'
|
label: 'TYPES.Item.armor'
|
||||||
|
},
|
||||||
|
weapon: {
|
||||||
|
id: 'weapon',
|
||||||
|
label: 'TYPES.Item.weapon'
|
||||||
|
},
|
||||||
|
consumable: {
|
||||||
|
id: 'consumable',
|
||||||
|
label: 'TYPES.Item.consumable'
|
||||||
|
},
|
||||||
|
miscellaneous: {
|
||||||
|
id: 'miscellaneous',
|
||||||
|
label: 'TYPES.Item.miscellaneous'
|
||||||
|
},
|
||||||
|
beastform: {
|
||||||
|
if: 'beastform',
|
||||||
|
label: 'TYPES.Item.beastform'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,68 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
return this.parent.items.find(x => x.type === 'armor' && x.system.equipped);
|
return this.parent.items.find(x => x.type === 'armor' && x.system.equipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get sheetLists() {
|
||||||
|
const ancestryFeatures = [],
|
||||||
|
communityFeatures = [],
|
||||||
|
classFeatures = [],
|
||||||
|
subclassFeatures = [],
|
||||||
|
companionFeatures = [],
|
||||||
|
features = [];
|
||||||
|
|
||||||
|
for (var item of this.parent.items) {
|
||||||
|
if (item.system.type === CONFIG.DH.ITEM.featureTypes.ancestry.id) {
|
||||||
|
ancestryFeatures.push(item);
|
||||||
|
} else if (item.system.type === CONFIG.DH.ITEM.featureTypes.community.id) {
|
||||||
|
communityFeatures.push(item);
|
||||||
|
} else if (item.system.type === CONFIG.DH.ITEM.featureTypes.class.id) {
|
||||||
|
classFeatures.push(item);
|
||||||
|
} else if (item.system.type === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
||||||
|
const subclassState = this.class.subclass.system.featureState;
|
||||||
|
const identifier = item.system.identifier;
|
||||||
|
if (
|
||||||
|
identifier === 'foundationFeature' ||
|
||||||
|
(identifier === 'specializationFeature' && subclassState >= 2) ||
|
||||||
|
(identifier === 'masterFeature' && subclassState >= 3)
|
||||||
|
) {
|
||||||
|
subclassFeatures.push(item);
|
||||||
|
}
|
||||||
|
} else if (item.system.type === CONFIG.DH.ITEM.featureTypes.companion.id) {
|
||||||
|
companionFeatures.push(item);
|
||||||
|
} else if (item.type === 'feature' && !item.system.type) {
|
||||||
|
features.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
ancestryFeatures: {
|
||||||
|
title: `${game.i18n.localize('TYPES.Item.ancestry')} - ${this.ancestry?.name}`,
|
||||||
|
type: 'ancestry',
|
||||||
|
values: ancestryFeatures
|
||||||
|
},
|
||||||
|
communityFeatures: {
|
||||||
|
title: `${game.i18n.localize('TYPES.Item.community')} - ${this.community?.name}`,
|
||||||
|
type: 'community',
|
||||||
|
values: communityFeatures
|
||||||
|
},
|
||||||
|
classFeatures: {
|
||||||
|
title: `${game.i18n.localize('TYPES.Item.class')} - ${this.class.value?.name}`,
|
||||||
|
type: 'class',
|
||||||
|
values: classFeatures
|
||||||
|
},
|
||||||
|
subclassFeatures: {
|
||||||
|
title: `${game.i18n.localize('TYPES.Item.subclass')} - ${this.class.subclass?.name}`,
|
||||||
|
type: 'subclass',
|
||||||
|
values: subclassFeatures
|
||||||
|
},
|
||||||
|
companionFeatures: {
|
||||||
|
title: game.i18n.localize('DAGGERHEART.Sheets.PC.CompanionFeatures'),
|
||||||
|
type: 'companion',
|
||||||
|
values: companionFeatures
|
||||||
|
},
|
||||||
|
features: { title: game.i18n.localize('DAGGERHEART.Sheets.PC.Features'), type: 'feature', values: features }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
get primaryWeapon() {
|
get primaryWeapon() {
|
||||||
return this.parent.items.find(x => x.type === 'weapon' && x.system.equipped && !x.system.secondary);
|
return this.parent.items.find(x => x.type === 'weapon' && x.system.equipped && !x.system.secondary);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,4 +74,32 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
||||||
);
|
);
|
||||||
this.updateSource({ actions: [action] });
|
this.updateSource({ actions: [action] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onCreate(data) {
|
||||||
|
if (!this.actor || this.actor.type !== 'character' || !this.features) return;
|
||||||
|
|
||||||
|
this.actor.createEmbeddedDocuments(
|
||||||
|
'Item',
|
||||||
|
this.features.map(feature => ({
|
||||||
|
...feature,
|
||||||
|
system: {
|
||||||
|
...feature.system,
|
||||||
|
type: this.parent.type,
|
||||||
|
originId: data._id,
|
||||||
|
identifier: feature.identifier
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async _preDelete() {
|
||||||
|
if (!this.actor || this.actor.type !== 'character') return;
|
||||||
|
|
||||||
|
const items = this.actor.items.filter(item => item.system.originId === this.parent.id);
|
||||||
|
if (items.length > 0)
|
||||||
|
await this.actor.deleteEmbeddedDocuments(
|
||||||
|
'Item',
|
||||||
|
items.map(x => x.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,7 @@ export default class DHBeastform extends BaseDataItem {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async _preCreate(data, options, user) {
|
async _preCreate() {
|
||||||
const allowed = await super._preCreate(data, options, user);
|
|
||||||
if (allowed === false) return;
|
|
||||||
|
|
||||||
if (!this.actor) return;
|
if (!this.actor) return;
|
||||||
|
|
||||||
if (this.actor.type !== 'character') {
|
if (this.actor.type !== 'character') {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ export default class DHClass extends BaseDataItem {
|
||||||
return this.hopeFeatures.length > 0 ? this.hopeFeatures[0] : null;
|
return this.hopeFeatures.length > 0 ? this.hopeFeatures[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get features() {
|
||||||
|
return [...this.hopeFeatures.filter(x => x), ...this.classFeatures.filter(x => x)];
|
||||||
|
}
|
||||||
|
|
||||||
async _preCreate(data, options, user) {
|
async _preCreate(data, options, user) {
|
||||||
const allowed = await super._preCreate(data, options, user);
|
const allowed = await super._preCreate(data, options, user);
|
||||||
if (allowed === false) return;
|
if (allowed === false) return;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ export default class DHFeature extends BaseDataItem {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
|
type: new fields.StringField({ choices: CONFIG.DH.ITEM.featureTypes, nullable: true, initial: null }),
|
||||||
|
originId: new fields.StringField({ nullable: true, initial: null }),
|
||||||
|
identifier: new fields.StringField(),
|
||||||
actions: new fields.ArrayField(new ActionField())
|
actions: new fields.ArrayField(new ActionField())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ export default class DHSubclass extends BaseDataItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
get features() {
|
get features() {
|
||||||
return {
|
return [
|
||||||
foundation: this.foundationFeature,
|
{ ...this.foundationFeature.toObject(), identifier: 'foundationFeature' },
|
||||||
specialization: this.featureState >= 2 ? this.specializationFeature : null,
|
{ ...this.specializationFeature.toObject(), identifier: 'specializationFeature' },
|
||||||
mastery: this.featureState === 3 ? this.masteryFeature : null
|
{ ...this.masteryFeature.toObject(), identifier: 'masteryFeature' }
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async _preCreate(data, options, user) {
|
async _preCreate(data, options, user) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,12 @@
|
||||||
data-group='{{tabs.features.group}}'
|
data-group='{{tabs.features.group}}'
|
||||||
>
|
>
|
||||||
<div class="features-sections">
|
<div class="features-sections">
|
||||||
{{#if document.system.class.value}}
|
{{#each document.system.sheetLists}}
|
||||||
|
{{#if this.values}}
|
||||||
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=this.title values=this.values}}
|
||||||
|
{{/if}}
|
||||||
|
{{/each}}
|
||||||
|
{{!-- {{#if document.system.class.value}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(concat (localize 'TYPES.Item.class') ' - ' document.system.class.value.name) type='class'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(concat (localize 'TYPES.Item.class') ' - ' document.system.class.value.name) type='class'}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if document.system.class.subclass}}
|
{{#if document.system.class.subclass}}
|
||||||
|
|
@ -21,6 +26,6 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if document.system.ancestry}}
|
{{#if document.system.ancestry}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(concat (localize 'TYPES.Item.ancestry') ' - ' document.system.ancestry.name) type='ancestry'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(concat (localize 'TYPES.Item.ancestry') ' - ' document.system.ancestry.name) type='ancestry'}}
|
||||||
{{/if}}
|
{{/if}} --}}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -2,51 +2,29 @@
|
||||||
<legend>{{title}}</legend>
|
<legend>{{title}}</legend>
|
||||||
<ul class="items-list">
|
<ul class="items-list">
|
||||||
{{#unless (eq cardView 'card') }}
|
{{#unless (eq cardView 'card') }}
|
||||||
{{#each document.items as |item|}}
|
{{#if (eq type 'domainCard')}}
|
||||||
{{#if (eq item.type ../type)}}
|
{{#each document.items as |item|}}
|
||||||
{{#unless (or (eq ../type 'ancestry') (eq item.type 'class') (eq item.type 'subclass') (and (eq ../type 'domainCard') (or (and item.system.inVault (not ../isVault)) (and (not item.system.inVault) ../isVault))))}}
|
{{#if (eq item.type ../type)}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=item type=../type}}
|
{{#unless (and (eq ../type 'domainCard') (or (and item.system.inVault (not ../isVault)) (and (not item.system.inVault) ../isVault)))}}
|
||||||
{{/unless}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=item type=../type}}
|
||||||
|
{{/unless}}
|
||||||
|
{{/if}}
|
||||||
|
{{/each}}
|
||||||
|
{{else}}
|
||||||
|
{{#if (eq type 'effect')}}
|
||||||
|
{{#each document.effects as |effect|}}
|
||||||
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=effect type=../type}}
|
||||||
|
{{/each}}
|
||||||
|
{{else}}
|
||||||
|
{{#each values}}
|
||||||
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=this type=../type }}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
{{#each adversaries as |adversary|}}
|
||||||
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=adversary type='adversary' hideControls=true isActor=true categoryAdversary=@../key}}
|
||||||
|
{{/each}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/if}}
|
||||||
{{#each document.system.ancestry.system.actions as |action|}}
|
|
||||||
{{#if (or (eq ../type 'ancestry'))}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=action type=../type}}
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
{{#each document.system.class.value.system.classFeatures as |classFeature|}}
|
|
||||||
{{#if (or (eq ../type 'class'))}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=classFeature type=../type}}
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
{{#each document.system.class.value.system.classFeatures as |classFeature|}}
|
|
||||||
{{#if (or (eq ../type 'class'))}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=classFeature type=../type}}
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
{{#each document.appliedEffects as |effect|}}
|
|
||||||
{{#if (or (eq ../type 'effect'))}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=effect type=../type}}
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
{{#each document.system.actions as |action|}}
|
|
||||||
{{#if (or (eq ../type 'action'))}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=action type=../type}}
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
{{#each document.system.features as |feature|}}
|
|
||||||
{{#if (or (eq ../type 'features'))}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=feature}}
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
{{#each document.system.companionFeatures as |feature|}}
|
|
||||||
{{#if (or (eq ../type 'companionFeatures'))}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=feature companion=true}}
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
{{#each adversaries as |adversary|}}
|
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=adversary type='adversary' hideControls=true isActor=true categoryAdversary=@../key}}
|
|
||||||
{{/each}}
|
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-type="{{type}}" data-companion="{{companion}}">
|
<li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-type="{{type}}">
|
||||||
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}} />
|
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}} />
|
||||||
<div class="item-label">
|
<div class="item-label">
|
||||||
{{#if isCompanion}}
|
{{#if isCompanion}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue