mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
* Updated the background image for the system * Fixed so Weapon/Armor features are added again * Fixed so fear is available as a resource to be deducted by actions (#757) * Changed to use the config labels and src * Updated Weapons * Fixed so the decrease button of simple fear tracker is not visible when not hovered * Fixed so armor preUpdate doesn't fail if no system changes are made * Updated .gitignore and author details (#777) * Add author details and name mapping for chrisryan10 (#773) Co-authored-by: Chris Ryan <chrisr@blackhole> * Add build to ignore for my linux dev (#775) Co-authored-by: Chris Ryan <chrisr@blackhole> --------- Co-authored-by: Chris Ryan <chrisr@blackhole> * Corrected sneak attack active effect (#780) * Fixed a spelling error (#779) * Fix bardic rally showing in damage dialog when it should not (#783) * update spelling (#786) * Translating inventory descriptions (#782) * updated credits for 1.0.1 release (#797) * updated credits for 1.0.1 release * further updated artwork credits * Chagned handlebarhelper rollparsed to be more defensive (#794) * Added missing scene refreshType (#790) * Remove ability use buttons for not owned abilities (#795) * [Fix] PrayerDice Fixed (#799) * Fixed prayer dice, and wheelchair images * Fixed -settings data sources * Dragging features from one adversary to another (#788) * [Fix] Levelup Fixes (#787) * Fixed crash on experience selection. Fixed subclass error on multiclassing * Fixed so multiclasses do not gain the hope feature for the class * Fixed so Class/Subclass features are properly deleted on delevel * Removed automatic deletion of features on delevel when not using levelup auto * Fixed so custom domains can be selected in levelup when multiclassing * Changed so encounter countdowns is a button (#804) * Fixed so that dropping on class/subclass...creates the item on the character (#803) * [BUG] - Importing All Adversaries/Environments (#814) Fixes #774 Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> * Bug/671 reaction roll chat title (#809) * Update Reaction Roll Chat Message Title * Removed console log --------- Co-authored-by: WBHarry <williambjrklund@gmail.com> * Improve Trait tooltip display (#817) Fixes #806 Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> * [BUG] - Combat Tracker d12 logo not found (#812) Fixes #764 Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> * Compendium Browser (#821) * Corrected timbending description localization (#816) * [Fix] Compendium Item (#810) * Corrected Emberwoven Armor * Fixed subclass regression * Fixed so character's with wildcard images don't break beastform (#815) * Fix roll result based duality damage (#822) --------- Co-authored-by: Chris Ryan <73275196+chrisryan10@users.noreply.github.com> Co-authored-by: Chris Ryan <chrisr@blackhole> Co-authored-by: Dapoulp <74197441+Dapoulp@users.noreply.github.com> Co-authored-by: IrkTheImp <41175833+IrkTheImp@users.noreply.github.com> Co-authored-by: CPTN_Cosmo <cptncosmo@gmail.com> Co-authored-by: Josh Q. <jshqntnr13@gmail.com> Co-authored-by: joaquinpereyra98 <24190917+joaquinpereyra98@users.noreply.github.com> Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
111 lines
4.3 KiB
JavaScript
111 lines
4.3 KiB
JavaScript
import ItemLinkFields from '../fields/itemLinkFields.mjs';
|
|
import BaseDataItem from './base.mjs';
|
|
|
|
export default class DHSubclass extends BaseDataItem {
|
|
/** @inheritDoc */
|
|
static get metadata() {
|
|
return foundry.utils.mergeObject(super.metadata, {
|
|
label: 'TYPES.Item.subclass',
|
|
type: 'subclass',
|
|
hasDescription: true
|
|
});
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields;
|
|
return {
|
|
...super.defineSchema(),
|
|
spellcastingTrait: new fields.StringField({
|
|
choices: CONFIG.DH.ACTOR.abilities,
|
|
integer: false,
|
|
nullable: true,
|
|
initial: null,
|
|
label: 'DAGGERHEART.ITEMS.Subclass.spellcastingTrait'
|
|
}),
|
|
features: new ItemLinkFields(),
|
|
featureState: new fields.NumberField({ required: true, initial: 1, min: 1 }),
|
|
isMulticlass: new fields.BooleanField({ initial: false })
|
|
};
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/**@override */
|
|
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/laurels.svg';
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
get foundationFeatures() {
|
|
return this.features.filter(x => x.type === CONFIG.DH.ITEM.featureSubTypes.foundation).map(x => x.item);
|
|
}
|
|
|
|
get specializationFeatures() {
|
|
return this.features.filter(x => x.type === CONFIG.DH.ITEM.featureSubTypes.specialization).map(x => x.item);
|
|
}
|
|
|
|
get masteryFeatures() {
|
|
return this.features.filter(x => x.type === CONFIG.DH.ITEM.featureSubTypes.mastery).map(x => x.item);
|
|
}
|
|
|
|
async _preCreate(data, options, user) {
|
|
if (this.actor?.type === 'character') {
|
|
const dataUuid =
|
|
data.uuid ?? (data.folder ? `Compendium.daggerheart.subclasses.Item.${data._id}` : `Item.${data._id}`);
|
|
if (this.actor.system.class.subclass) {
|
|
if (this.actor.system.multiclass.subclass) {
|
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassesAlreadyPresent'));
|
|
return false;
|
|
} else {
|
|
const multiclass = this.actor.items.find(x => x.type === 'class' && x.system.isMulticlass);
|
|
if (!multiclass) {
|
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingMulticlass'));
|
|
return false;
|
|
}
|
|
|
|
if (multiclass.system.subclasses.every(x => x.uuid !== dataUuid)) {
|
|
ui.notifications.error(
|
|
game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInMulticlass')
|
|
);
|
|
return false;
|
|
}
|
|
|
|
await this.updateSource({ isMulticlass: true });
|
|
}
|
|
} else {
|
|
const actorClass = this.actor.items.find(x => x.type === 'class' && !x.system.isMulticlass);
|
|
if (!actorClass) {
|
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClass'));
|
|
return false;
|
|
}
|
|
if (actorClass.system.subclasses.every(x => x.uuid !== dataUuid)) {
|
|
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass'));
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
const allowed = await super._preCreate(data, options, user);
|
|
if (allowed === false) return;
|
|
}
|
|
|
|
_onCreate(data, options, userId) {
|
|
super._onCreate(data, options, userId);
|
|
|
|
if (userId !== game.user.id) return;
|
|
|
|
if (options.parent?.type === 'character') {
|
|
const path = `system.${data.system.isMulticlass ? 'multiclass.subclass' : 'class.subclass'}`;
|
|
options.parent.update({ [path]: `${options.parent.uuid}.Item.${data._id}` });
|
|
}
|
|
}
|
|
|
|
_onDelete(options, userId) {
|
|
super._onDelete(options, userId);
|
|
|
|
if (options.parent?.type === 'character') {
|
|
const path = `system.${this.isMulticlass ? 'multiclass.subclass' : 'class.subclass'}`;
|
|
options.parent.update({ [path]: null });
|
|
}
|
|
}
|
|
}
|