mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Manual Character Editing (#490)
* Initial * Added Character-Settings * Finalized Character-Settings * Hide CharacterSetup if any part is done manually * Fixed class/subclass drag-drop * Fixed relinking of Features from items created on Character * Adding features on CharacterItems now adds them on the Character and relinks * Made suggested items inactive in the Class sheet if rendered from inside a Character * Added hope to CharacterSetting * add style to textarea element, add spellcasting and domain class into char sheet and move rest buttons to another place * Fixed characterCreation experience description --------- Co-authored-by: moliloo <dev.murilobrito@gmail.com>
This commit is contained in:
parent
263dfa69ae
commit
e1d8f8784a
49 changed files with 1205 additions and 386 deletions
|
|
@ -5,6 +5,7 @@ export { default as DamageReductionDialog } from './damageReductionDialog.mjs';
|
|||
export { default as DamageSelectionDialog } from './damageSelectionDialog.mjs';
|
||||
export { default as DeathMove } from './deathMove.mjs';
|
||||
export { default as Downtime } from './downtime.mjs';
|
||||
export { default as MulticlassChoiceDialog } from './multiclassChoiceDialog.mjs';
|
||||
export { default as OwnershipSelection } from './ownershipSelection.mjs';
|
||||
export { default as ResourceDiceDialog } from './resourceDiceDialog.mjs';
|
||||
export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs';
|
||||
|
|
|
|||
73
module/applications/dialogs/multiclassChoiceDialog.mjs
Normal file
73
module/applications/dialogs/multiclassChoiceDialog.mjs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class MulticlassChoiceDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(actor, multiclass, options) {
|
||||
super(options);
|
||||
|
||||
this.actor = actor;
|
||||
this.multiclass = multiclass;
|
||||
this.selectedDomain = null;
|
||||
}
|
||||
|
||||
get title() {
|
||||
return game.i18n.format('DAGGERHEART.APPLICATIONS.MulticlassChoice.title', { actor: this.actor.name });
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['daggerheart', 'dh-style', 'dialog', 'views', 'multiclass-choice'],
|
||||
position: { width: 'auto', height: 'auto' },
|
||||
window: { icon: 'fa-solid fa-person-rays' },
|
||||
actions: {
|
||||
save: MulticlassChoiceDialog.#save,
|
||||
selectDomain: MulticlassChoiceDialog.#selectDomain
|
||||
}
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
application: {
|
||||
id: 'multiclass-choice',
|
||||
template: 'systems/daggerheart/templates/dialogs/multiclassChoice.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.multiclass = this.multiclass;
|
||||
context.domainChoices = this.multiclass.domains.map(value => {
|
||||
const domain = CONFIG.DH.DOMAIN.domains[value];
|
||||
return {
|
||||
value: value,
|
||||
label: game.i18n.localize(domain.label),
|
||||
description: game.i18n.localize(domain.description),
|
||||
src: domain.src,
|
||||
selected: value === this.selectedDomain,
|
||||
disabled: this.actor.system.domains.includes(value)
|
||||
};
|
||||
});
|
||||
context.multiclassDisabled = !this.selectedDomain;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/** @override */
|
||||
_onClose(options = {}) {
|
||||
if (!options.submitted) this.move = null;
|
||||
}
|
||||
|
||||
static async configure(actor, multiclass, options = {}) {
|
||||
return new Promise(resolve => {
|
||||
const app = new this(actor, multiclass, options);
|
||||
app.addEventListener('close', () => resolve(app.selectedDomain), { once: true });
|
||||
app.render({ force: true });
|
||||
});
|
||||
}
|
||||
|
||||
static #save() {
|
||||
this.close({ submitted: true });
|
||||
}
|
||||
|
||||
static #selectDomain(_event, button) {
|
||||
this.selectedDomain = this.selectedDomain === button.dataset.domain ? null : button.dataset.domain;
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +46,8 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
tabs: { template: 'systems/daggerheart/templates/levelup/tabs/tab-navigation.hbs' },
|
||||
advancements: { template: 'systems/daggerheart/templates/levelup/tabs/advancements.hbs' },
|
||||
selections: { template: 'systems/daggerheart/templates/levelup/tabs/selections.hbs' },
|
||||
summary: { template: 'systems/daggerheart/templates/levelup/tabs/summary.hbs' }
|
||||
summary: { template: 'systems/daggerheart/templates/levelup/tabs/summary.hbs' },
|
||||
footer: { template: 'systems/daggerheart/templates/levelup/tabs/footer.hbs' }
|
||||
};
|
||||
|
||||
static TABS = {
|
||||
|
|
@ -95,6 +96,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
const context = await super._prepareContext(_options);
|
||||
context.levelup = this.levelup;
|
||||
context.tabs = this._getTabs(this.constructor.TABS);
|
||||
context.levelupAuto = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).levelupAuto;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
export { default as ActionConfig } from './action-config.mjs';
|
||||
export { default as CharacterSettings } from './character-settings.mjs';
|
||||
export { default as AdversarySettings } from './adversary-settings.mjs';
|
||||
export { default as CompanionSettings } from './companion-settings.mjs';
|
||||
export { default as DowntimeConfig } from './downtimeConfig.mjs';
|
||||
|
|
|
|||
143
module/applications/sheets-configs/character-settings.mjs
Normal file
143
module/applications/sheets-configs/character-settings.mjs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
import DHBaseActorSettings from '../sheets/api/actor-setting.mjs';
|
||||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
|
||||
export default class DHCharacterSettings extends DHBaseActorSettings {
|
||||
/**@inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['character-settings'],
|
||||
position: { width: 455, height: 'auto' },
|
||||
actions: {
|
||||
addExperience: DHCharacterSettings.#addExperience,
|
||||
removeExperience: DHCharacterSettings.#removeExperience
|
||||
},
|
||||
dragDrop: [
|
||||
{ dragSelector: null, dropSelector: '.tab.features' },
|
||||
{ dragSelector: '.feature-item', dropSelector: null }
|
||||
]
|
||||
};
|
||||
|
||||
/**@override */
|
||||
static PARTS = {
|
||||
header: {
|
||||
id: 'header',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/character-settings/header.hbs'
|
||||
},
|
||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||
details: {
|
||||
id: 'details',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/character-settings/details.hbs'
|
||||
},
|
||||
experiences: {
|
||||
id: 'experiences',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/character-settings/experiences.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [{ id: 'details' }, { id: 'experiences' }],
|
||||
initial: 'details',
|
||||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
context.levelupAuto = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).levelupAuto;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Adds a new experience entry to the actor.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #addExperience() {
|
||||
const newExperience = {
|
||||
name: 'Experience',
|
||||
modifier: 0
|
||||
};
|
||||
await this.actor.update({ [`system.experiences.${foundry.utils.randomID()}`]: newExperience });
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an experience entry from the actor.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #removeExperience(_, target) {
|
||||
const experience = this.actor.system.experiences[target.dataset.experience];
|
||||
const updates = {};
|
||||
|
||||
const relinkAchievementData = [];
|
||||
const relinkSelectionData = [];
|
||||
Object.keys(this.actor.system.levelData.levelups).forEach(key => {
|
||||
const level = this.actor.system.levelData.levelups[key];
|
||||
|
||||
const achievementIncludesExp = level.achievements.experiences[target.dataset.experience];
|
||||
if (achievementIncludesExp)
|
||||
relinkAchievementData.push({ levelKey: key, experience: target.dataset.experience });
|
||||
|
||||
const selectionIndex = level.selections.findIndex(
|
||||
x => x.optionKey === 'experience' && x.data[0] === target.dataset.experience
|
||||
);
|
||||
if (selectionIndex !== -1)
|
||||
relinkSelectionData.push({ levelKey: key, selectionIndex, experience: target.dataset.experience });
|
||||
});
|
||||
|
||||
if (relinkAchievementData.length > 0 || relinkSelectionData.length > 0) {
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: game.i18n.localize('DAGGERHEART.ACTORS.Character.experienceDataRemoveConfirmation.title')
|
||||
},
|
||||
content: game.i18n.localize('DAGGERHEART.ACTORS.Character.experienceDataRemoveConfirmation.text')
|
||||
});
|
||||
if (!confirmed) return;
|
||||
}
|
||||
|
||||
if (relinkAchievementData.length > 0) {
|
||||
relinkAchievementData.forEach(data => {
|
||||
updates[`system.levelData.levelups.${data.levelKey}.achievements.experiences.-=${data.experience}`] =
|
||||
null;
|
||||
});
|
||||
} else if (relinkSelectionData.length > 0) {
|
||||
relinkSelectionData.forEach(data => {
|
||||
updates[`system.levelData.levelups.${data.levelKey}.selections`] = this.actor.system.levelData.levelups[
|
||||
data.levelKey
|
||||
].selections.reduce((acc, selection, index) => {
|
||||
if (
|
||||
index === data.selectionIndex &&
|
||||
selection.optionKey === 'experience' &&
|
||||
selection.data.includes(data.experience)
|
||||
) {
|
||||
acc.push({ ...selection, data: selection.data.filter(x => x !== data.experience) });
|
||||
} else {
|
||||
acc.push(selection);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
});
|
||||
} else {
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.title', {
|
||||
type: game.i18n.localize(`DAGGERHEART.GENERAL.Experience.single`),
|
||||
name: experience.name
|
||||
})
|
||||
},
|
||||
content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { name: experience.name })
|
||||
});
|
||||
if (!confirmed) return;
|
||||
}
|
||||
|
||||
await this.actor.update({
|
||||
...updates,
|
||||
[`system.experiences.-=${target.dataset.experience}`]: null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
|
|||
classes: ['companion-settings'],
|
||||
position: { width: 455, height: 'auto' },
|
||||
actions: {
|
||||
addExperience: DHCompanionSettings.#addExperience,
|
||||
removeExperience: DHCompanionSettings.#removeExperience,
|
||||
levelUp: DHCompanionSettings.#levelUp
|
||||
}
|
||||
};
|
||||
|
|
@ -88,6 +90,38 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
|
|||
if (!value) await this.actor.updateLevel(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new experience entry to the actor.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #addExperience() {
|
||||
const newExperience = {
|
||||
name: 'Experience',
|
||||
modifier: 0
|
||||
};
|
||||
await this.actor.update({ [`system.experiences.${foundry.utils.randomID()}`]: newExperience });
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an experience entry from the actor.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #removeExperience(_, target) {
|
||||
const experience = this.actor.system.experiences[target.dataset.experience];
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.title', {
|
||||
type: game.i18n.localize(`DAGGERHEART.GENERAL.Experience.single`),
|
||||
name: experience.name
|
||||
})
|
||||
},
|
||||
content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { name: experience.name })
|
||||
});
|
||||
if (!confirmed) return;
|
||||
|
||||
await this.actor.update({ [`system.experiences.-=${target.dataset.experience}`]: null });
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the companion level-up dialog for the associated actor.
|
||||
* @type {ApplicationClickAction}
|
||||
|
|
|
|||
|
|
@ -716,10 +716,14 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the downtime application.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static useDowntime(_, button) {
|
||||
new game.system.api.applications.dialogs.Downtime(this.document, button.dataset.type === 'shortRest').render(
|
||||
true
|
||||
);
|
||||
new game.system.api.applications.dialogs.Downtime(this.document, button.dataset.type === 'shortRest').render({
|
||||
force: true
|
||||
});
|
||||
}
|
||||
|
||||
async _onDragStart(event) {
|
||||
|
|
|
|||
|
|
@ -417,17 +417,29 @@ export default function DHApplicationMixin(Base) {
|
|||
const { documentClass, type, inVault, disabled } = target.dataset;
|
||||
const parentIsItem = this.document.documentName === 'Item';
|
||||
const parent =
|
||||
parentIsItem && documentClass === 'Item'
|
||||
? type === 'action'
|
||||
? this.document.system
|
||||
: null
|
||||
: this.document;
|
||||
this.document.parent?.type === 'character'
|
||||
? this.document.parent
|
||||
: parentIsItem && documentClass === 'Item'
|
||||
? type === 'action'
|
||||
? this.document.system
|
||||
: null
|
||||
: this.document;
|
||||
|
||||
let systemData = {};
|
||||
if (parent?.type === 'character' && type === 'feature') {
|
||||
systemData = {
|
||||
originItemType: this.document.type,
|
||||
originId: this.document.id,
|
||||
identifier: this.document.system.isMulticlass ? 'multiclass' : null
|
||||
};
|
||||
}
|
||||
|
||||
const cls =
|
||||
type === 'action' ? game.system.api.models.actions.actionsTypes.base : getDocumentClass(documentClass);
|
||||
const data = {
|
||||
name: cls.defaultName({ type, parent }),
|
||||
type
|
||||
type,
|
||||
system: systemData
|
||||
};
|
||||
if (inVault) data['system.inVault'] = true;
|
||||
if (disabled) data.disabled = true;
|
||||
|
|
|
|||
|
|
@ -150,10 +150,24 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
static async #addFeature(_, target) {
|
||||
const { type } = target.dataset;
|
||||
const cls = foundry.documents.Item.implementation;
|
||||
const item = await cls.create({
|
||||
type: 'feature',
|
||||
name: cls.defaultName({ type: 'feature' })
|
||||
});
|
||||
|
||||
let systemData = {};
|
||||
if (this.document.parent?.type === 'character') {
|
||||
systemData = {
|
||||
originItemType: this.document.type,
|
||||
originId: this.document.id,
|
||||
identifier: this.document.system.isMulticlass ? 'multiclass' : null
|
||||
};
|
||||
}
|
||||
|
||||
const item = await cls.create(
|
||||
{
|
||||
type: 'feature',
|
||||
name: cls.defaultName({ type: 'feature' }),
|
||||
system: systemData
|
||||
},
|
||||
{ parent: this.document.parent?.type === 'character' ? this.document.parent : undefined }
|
||||
);
|
||||
await this.document.update({
|
||||
'system.features': [...this.document.system.features, { type, item }].map(x => ({
|
||||
...x,
|
||||
|
|
|
|||
|
|
@ -113,45 +113,47 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
});
|
||||
} else if (item.type === 'feature') {
|
||||
super._onDrop(event);
|
||||
} else if (item.type === 'weapon') {
|
||||
if (target.classList.contains('primary-weapon-section')) {
|
||||
if (!item.system.secondary)
|
||||
} else if (this.document.parent?.type !== 'character') {
|
||||
if (item.type === 'weapon') {
|
||||
if (target.classList.contains('primary-weapon-section')) {
|
||||
if (!item.system.secondary)
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedPrimaryWeapon': item.uuid
|
||||
});
|
||||
} else if (target.classList.contains('secondary-weapon-section')) {
|
||||
if (item.system.secondary)
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedSecondaryWeapon': item.uuid
|
||||
});
|
||||
}
|
||||
} else if (item.type === 'armor') {
|
||||
if (target.classList.contains('armor-section')) {
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedPrimaryWeapon': item.uuid
|
||||
});
|
||||
} else if (target.classList.contains('secondary-weapon-section')) {
|
||||
if (item.system.secondary)
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedSecondaryWeapon': item.uuid
|
||||
});
|
||||
}
|
||||
} else if (item.type === 'armor') {
|
||||
if (target.classList.contains('armor-section')) {
|
||||
await this.document.update({
|
||||
'system.characterGuide.suggestedArmor': item.uuid
|
||||
});
|
||||
}
|
||||
} else if (target.classList.contains('choice-a-section')) {
|
||||
if (item.type === 'loot' || item.type === 'consumable') {
|
||||
const filteredChoiceA = this.document.system.inventory.choiceA;
|
||||
if (filteredChoiceA.length < 2)
|
||||
await this.document.update({
|
||||
'system.inventory.choiceA': [...filteredChoiceA.map(x => x.uuid), item.uuid]
|
||||
});
|
||||
}
|
||||
} else if (item.type === 'loot') {
|
||||
if (target.classList.contains('take-section')) {
|
||||
const filteredTake = this.document.system.inventory.take.filter(x => x);
|
||||
if (filteredTake.length < 3)
|
||||
await this.document.update({
|
||||
'system.inventory.take': [...filteredTake.map(x => x.uuid), item.uuid]
|
||||
});
|
||||
} else if (target.classList.contains('choice-b-section')) {
|
||||
const filteredChoiceB = this.document.system.inventory.choiceB.filter(x => x);
|
||||
if (filteredChoiceB.length < 2)
|
||||
await this.document.update({
|
||||
'system.inventory.choiceB': [...filteredChoiceB.map(x => x.uuid), item.uuid]
|
||||
'system.characterGuide.suggestedArmor': item.uuid
|
||||
});
|
||||
}
|
||||
} else if (target.classList.contains('choice-a-section')) {
|
||||
if (item.type === 'loot' || item.type === 'consumable') {
|
||||
const filteredChoiceA = this.document.system.inventory.choiceA;
|
||||
if (filteredChoiceA.length < 2)
|
||||
await this.document.update({
|
||||
'system.inventory.choiceA': [...filteredChoiceA.map(x => x.uuid), item.uuid]
|
||||
});
|
||||
}
|
||||
} else if (item.type === 'loot') {
|
||||
if (target.classList.contains('take-section')) {
|
||||
const filteredTake = this.document.system.inventory.take.filter(x => x);
|
||||
if (filteredTake.length < 3)
|
||||
await this.document.update({
|
||||
'system.inventory.take': [...filteredTake.map(x => x.uuid), item.uuid]
|
||||
});
|
||||
} else if (target.classList.contains('choice-b-section')) {
|
||||
const filteredChoiceB = this.document.system.inventory.choiceB.filter(x => x);
|
||||
if (filteredChoiceB.length < 2)
|
||||
await this.document.update({
|
||||
'system.inventory.choiceB': [...filteredChoiceB.map(x => x.uuid), item.uuid]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue