mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Initial
This commit is contained in:
parent
7bbbdce739
commit
798cf8c761
12 changed files with 239 additions and 129 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
50
module/applications/sheets-configs/character-settings.mjs
Normal file
50
module/applications/sheets-configs/character-settings.mjs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
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: {},
|
||||
dragDrop: [
|
||||
{ dragSelector: null, dropSelector: '.tab.features' },
|
||||
{ dragSelector: '.feature-item', dropSelector: null }
|
||||
]
|
||||
};
|
||||
|
||||
/**@override */
|
||||
static PARTS = {
|
||||
header: {
|
||||
id: 'header',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/header.hbs'
|
||||
},
|
||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||
details: {
|
||||
id: 'details',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/details.hbs'
|
||||
},
|
||||
attack: {
|
||||
id: 'attack',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/attack.hbs'
|
||||
},
|
||||
experiences: {
|
||||
id: 'experiences',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/experiences.hbs'
|
||||
},
|
||||
features: {
|
||||
id: 'features',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/features.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [{ id: 'details' }, { id: 'attack' }, { id: 'experiences' }, { id: 'features' }],
|
||||
initial: 'details',
|
||||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
toggleEquipItem: CharacterSheet.#toggleEquipItem,
|
||||
toggleResourceDice: CharacterSheet.#toggleResourceDice,
|
||||
handleResourceDice: CharacterSheet.#handleResourceDice,
|
||||
openConfig: CharacterSheet.#openConfig,
|
||||
useDowntime: this.useDowntime
|
||||
},
|
||||
window: {
|
||||
|
|
@ -716,6 +717,16 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the character config sheet.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #openConfig() {}
|
||||
|
||||
/**
|
||||
* Open the downtime application.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static useDowntime(_, button) {
|
||||
new game.system.api.applications.dialogs.Downtime(this.document, button.dataset.type === 'shortRest').render(
|
||||
true
|
||||
|
|
|
|||
|
|
@ -511,37 +511,39 @@ export default class DhCharacter extends BaseDataActor {
|
|||
: Object.values(game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers).find(
|
||||
tier => currentLevel >= tier.levels.start && currentLevel <= tier.levels.end
|
||||
).tier;
|
||||
for (let levelKey in this.levelData.levelups) {
|
||||
const level = this.levelData.levelups[levelKey];
|
||||
if (game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).levelupAuto) {
|
||||
for (let levelKey in this.levelData.levelups) {
|
||||
const level = this.levelData.levelups[levelKey];
|
||||
|
||||
this.proficiency += level.achievements.proficiency;
|
||||
this.proficiency += level.achievements.proficiency;
|
||||
|
||||
for (let selection of level.selections) {
|
||||
switch (selection.type) {
|
||||
case 'trait':
|
||||
selection.data.forEach(data => {
|
||||
this.traits[data].value += 1;
|
||||
this.traits[data].tierMarked = selection.tier === currentTier;
|
||||
});
|
||||
break;
|
||||
case 'hitPoint':
|
||||
this.resources.hitPoints.max += selection.value;
|
||||
break;
|
||||
case 'stress':
|
||||
this.resources.stress.max += selection.value;
|
||||
break;
|
||||
case 'evasion':
|
||||
this.evasion += selection.value;
|
||||
break;
|
||||
case 'proficiency':
|
||||
this.proficiency += selection.value;
|
||||
break;
|
||||
case 'experience':
|
||||
Object.keys(this.experiences).forEach(key => {
|
||||
const experience = this.experiences[key];
|
||||
experience.value += selection.value;
|
||||
});
|
||||
break;
|
||||
for (let selection of level.selections) {
|
||||
switch (selection.type) {
|
||||
case 'trait':
|
||||
selection.data.forEach(data => {
|
||||
this.traits[data].value += 1;
|
||||
this.traits[data].tierMarked = selection.tier === currentTier;
|
||||
});
|
||||
break;
|
||||
case 'hitPoint':
|
||||
this.resources.hitPoints.max += selection.value;
|
||||
break;
|
||||
case 'stress':
|
||||
this.resources.stress.max += selection.value;
|
||||
break;
|
||||
case 'evasion':
|
||||
this.evasion += selection.value;
|
||||
break;
|
||||
case 'proficiency':
|
||||
this.proficiency += selection.value;
|
||||
break;
|
||||
case 'experience':
|
||||
Object.keys(this.experiences).forEach(key => {
|
||||
const experience = this.experiences[key];
|
||||
experience.value += selection.value;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hopeFear.players.label'
|
||||
})
|
||||
}),
|
||||
levelupAuto: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: true,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.levelupAuto.label'
|
||||
}),
|
||||
actionPoints: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: false,
|
||||
|
|
|
|||
|
|
@ -172,26 +172,30 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
|
||||
async levelUp(levelupData) {
|
||||
const levelupAuto = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).levelupAuto;
|
||||
|
||||
const levelups = {};
|
||||
for (var levelKey of Object.keys(levelupData)) {
|
||||
const level = levelupData[levelKey];
|
||||
|
||||
for (var experienceKey in level.achievements.experiences) {
|
||||
const experience = level.achievements.experiences[experienceKey];
|
||||
await this.update({
|
||||
[`system.experiences.${experienceKey}`]: {
|
||||
name: experience.name,
|
||||
value: experience.modifier
|
||||
}
|
||||
});
|
||||
|
||||
if (this.system.companion) {
|
||||
await this.system.companion.update({
|
||||
if (levelupAuto) {
|
||||
for (var experienceKey in level.achievements.experiences) {
|
||||
const experience = level.achievements.experiences[experienceKey];
|
||||
await this.update({
|
||||
[`system.experiences.${experienceKey}`]: {
|
||||
name: '',
|
||||
name: experience.name,
|
||||
value: experience.modifier
|
||||
}
|
||||
});
|
||||
|
||||
if (this.system.companion) {
|
||||
await this.system.companion.update({
|
||||
[`system.experiences.${experienceKey}`]: {
|
||||
name: '',
|
||||
value: experience.modifier
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -250,74 +254,86 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
|
||||
for (var addition of featureAdditions) {
|
||||
for (var featureData of addition.features) {
|
||||
const feature = new DHFeature({
|
||||
...featureData,
|
||||
description: game.i18n.localize(featureData.description)
|
||||
});
|
||||
|
||||
const document = featureData.toPartner && this.system.partner ? this.system.partner : this;
|
||||
const embeddedItem = await document.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
if (levelupAuto) {
|
||||
for (var featureData of addition.features) {
|
||||
const feature = new DHFeature({
|
||||
...featureData,
|
||||
name: game.i18n.localize(featureData.name),
|
||||
type: 'feature',
|
||||
system: feature
|
||||
}
|
||||
]);
|
||||
const newFeature = {
|
||||
onPartner: Boolean(featureData.toPartner && this.system.partner),
|
||||
id: embeddedItem[0].id
|
||||
};
|
||||
addition.checkbox.features = !addition.checkbox.features
|
||||
? [newFeature]
|
||||
: [...addition.checkbox.features, newFeature];
|
||||
description: game.i18n.localize(featureData.description)
|
||||
});
|
||||
|
||||
const document = featureData.toPartner && this.system.partner ? this.system.partner : this;
|
||||
const embeddedItem = await document.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
...featureData,
|
||||
name: game.i18n.localize(featureData.name),
|
||||
type: 'feature',
|
||||
system: feature
|
||||
}
|
||||
]);
|
||||
const newFeature = {
|
||||
onPartner: Boolean(featureData.toPartner && this.system.partner),
|
||||
id: embeddedItem[0].id
|
||||
};
|
||||
addition.checkbox.features = !addition.checkbox.features
|
||||
? [newFeature]
|
||||
: [...addition.checkbox.features, newFeature];
|
||||
}
|
||||
}
|
||||
|
||||
selections.push(addition.checkbox);
|
||||
}
|
||||
|
||||
if (multiclass) {
|
||||
const subclassItem = await foundry.utils.fromUuid(multiclass.secondaryData.subclass);
|
||||
const subclassData = subclassItem.toObject();
|
||||
const multiclassItem = await foundry.utils.fromUuid(multiclass.data[0]);
|
||||
const multiclassData = multiclassItem.toObject();
|
||||
if (levelupAuto) {
|
||||
const subclassItem = await foundry.utils.fromUuid(multiclass.secondaryData.subclass);
|
||||
const subclassData = subclassItem.toObject();
|
||||
const multiclassItem = await foundry.utils.fromUuid(multiclass.data[0]);
|
||||
const multiclassData = multiclassItem.toObject();
|
||||
|
||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
...multiclassData,
|
||||
system: {
|
||||
...multiclassData.system,
|
||||
domains: [multiclass.secondaryData.domain],
|
||||
isMulticlass: true
|
||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
...multiclassData,
|
||||
system: {
|
||||
...multiclassData.system,
|
||||
domains: [multiclass.secondaryData.domain],
|
||||
isMulticlass: true
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
]);
|
||||
|
||||
await this.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
...subclassData,
|
||||
system: {
|
||||
...subclassData.system,
|
||||
isMulticlass: true
|
||||
await this.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
...subclassData,
|
||||
system: {
|
||||
...subclassData.system,
|
||||
isMulticlass: true
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
selections.push({ ...multiclass, itemUuid: embeddedItem[0].uuid });
|
||||
]);
|
||||
selections.push({ ...multiclass, itemUuid: embeddedItem[0].uuid });
|
||||
} else {
|
||||
selections.push({ ...multiclass });
|
||||
}
|
||||
}
|
||||
|
||||
for (var domainCard of domainCards) {
|
||||
const item = await foundry.utils.fromUuid(domainCard.data[0]);
|
||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]);
|
||||
selections.push({ ...domainCard, itemUuid: embeddedItem[0].uuid });
|
||||
if (levelupAuto) {
|
||||
const item = await foundry.utils.fromUuid(domainCard.data[0]);
|
||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]);
|
||||
selections.push({ ...domainCard, itemUuid: embeddedItem[0].uuid });
|
||||
} else {
|
||||
selections.push({ ...domainCard });
|
||||
}
|
||||
}
|
||||
|
||||
const achievementDomainCards = [];
|
||||
for (var card of Object.values(level.achievements.domainCards)) {
|
||||
const item = await foundry.utils.fromUuid(card.uuid);
|
||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]);
|
||||
card.itemUuid = embeddedItem[0].uuid;
|
||||
achievementDomainCards.push(card);
|
||||
if (levelupAuto) {
|
||||
for (var card of Object.values(level.achievements.domainCards)) {
|
||||
const item = await foundry.utils.fromUuid(card.uuid);
|
||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]);
|
||||
card.itemUuid = embeddedItem[0].uuid;
|
||||
achievementDomainCards.push(card);
|
||||
}
|
||||
}
|
||||
|
||||
if (subclassFeatureState.class) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue