mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Improved multiclass/subclass recognition
This commit is contained in:
parent
8db8619bf5
commit
448abb5f50
2 changed files with 51 additions and 15 deletions
|
|
@ -484,7 +484,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
if (item.type === 'domainCard') {
|
||||
if (
|
||||
!this.actor.system.class.system.domains.includes(item.system.domain) &&
|
||||
this.levelup.multiclass?.domain !== item.system.domain
|
||||
this.levelup.classUpgradeChoices?.multiclass?.domain !== item.system.domain
|
||||
) {
|
||||
ui.notifications.error(
|
||||
game.i18n.localize('DAGGERHEART.Application.LevelUp.notifications.error.domainCardWrongDomain')
|
||||
|
|
@ -559,10 +559,13 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
|
||||
const update = {};
|
||||
if (!button.checked) {
|
||||
update[`levels.${button.dataset.level}.choices.${button.dataset.option}.-=${button.dataset.checkboxNr}`] =
|
||||
null;
|
||||
if (button.dataset.type === 'multiclass') {
|
||||
update['-=multiclass'] = null;
|
||||
if (button.dataset.cost > 1) {
|
||||
// Simple handling that doesn't cover potential Custom LevelTiers.
|
||||
update[`levels.${this.levelup.currentLevel}.choices.-=${button.dataset.option}`] = null;
|
||||
} else {
|
||||
update[
|
||||
`levels.${this.levelup.currentLevel}.choices.${button.dataset.option}.-=${button.dataset.checkboxNr}`
|
||||
] = null;
|
||||
}
|
||||
} else {
|
||||
if (!this.levelup.levels[this.levelup.currentLevel].nrSelections.available) {
|
||||
|
|
@ -582,7 +585,6 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
value: button.dataset.value,
|
||||
type: button.dataset.type
|
||||
};
|
||||
update['multiclass'] = { tier: Number(button.dataset.tier), level: this.levelup.currentLevel };
|
||||
}
|
||||
|
||||
await this.levelup.updateSource(update);
|
||||
|
|
@ -642,8 +644,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
};
|
||||
}
|
||||
return acc;
|
||||
}, {}),
|
||||
...(this.levelup.multiclass?.level === this.levelup.currentLevel ? { '-=multiclass': null } : {})
|
||||
}, {})
|
||||
});
|
||||
} else {
|
||||
await this.levelup.updateSource({
|
||||
|
|
|
|||
|
|
@ -83,13 +83,7 @@ export class DhLevelup extends foundry.abstract.DataModel {
|
|||
levels: new fields.TypedObjectField(new fields.EmbeddedDataField(DhLevelupLevel)),
|
||||
startLevel: new fields.NumberField({ required: true, integer: true }),
|
||||
currentLevel: new fields.NumberField({ required: true, integer: true }),
|
||||
endLevel: new fields.NumberField({ required: true, integer: true }),
|
||||
multiclass: new fields.SchemaField({
|
||||
class: new fields.StringField({ required: true }),
|
||||
domain: new fields.StringField(),
|
||||
tier: new fields.NumberField({ required: true, integer: true }),
|
||||
level: new fields.NumberField({ required: true, integer: true })
|
||||
})
|
||||
endLevel: new fields.NumberField({ required: true, integer: true })
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +128,33 @@ export class DhLevelup extends foundry.abstract.DataModel {
|
|||
.every(this.#levelFinished.bind(this));
|
||||
}
|
||||
|
||||
get classUpgradeChoices() {
|
||||
let subclass = null;
|
||||
let multiclass = null;
|
||||
Object.keys(this.levels).forEach(levelKey => {
|
||||
const level = this.levels[levelKey];
|
||||
Object.values(level.choices).forEach(choice => {
|
||||
Object.values(choice).forEach(checkbox => {
|
||||
if (checkbox.type === 'multiclass') {
|
||||
multiclass = {
|
||||
class: checkbox.data.length > 0 ? checkbox.data[0] : null,
|
||||
domain: checkbox.secondaryData ?? null,
|
||||
tier: checkbox.tier,
|
||||
level: levelKey
|
||||
};
|
||||
}
|
||||
if (checkbox.type === 'subclass') {
|
||||
subclass = {
|
||||
tier: checkbox.tier,
|
||||
level: levelKey
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return { subclass, multiclass };
|
||||
}
|
||||
|
||||
get tiersForRendering() {
|
||||
const tierKeys = Object.keys(this.tiers);
|
||||
const selections = Object.keys(this.levels).reduce(
|
||||
|
|
@ -158,8 +179,12 @@ export class DhLevelup extends foundry.abstract.DataModel {
|
|||
}, {})
|
||||
);
|
||||
|
||||
const { multiclass, subclass } = this.classUpgradeChoices;
|
||||
return tierKeys.map(tierKey => {
|
||||
const tier = this.tiers[tierKey];
|
||||
const multiclassInTier = multiclass?.tier === Number(tierKey);
|
||||
const subclassInTier = subclass?.tier === Number(tierKey);
|
||||
|
||||
return {
|
||||
name: tier.name,
|
||||
active: this.currentLevel >= Math.min(...tier.belongingLevels),
|
||||
|
|
@ -177,6 +202,16 @@ export class DhLevelup extends foundry.abstract.DataModel {
|
|||
checkbox.disabled = checkbox.level !== this.currentLevel;
|
||||
}
|
||||
|
||||
if (optionKey === 'multiclass') {
|
||||
if ((multiclass && !multiclassInTier) || subclassInTier) {
|
||||
checkbox.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (optionKey === 'subclass' && multiclassInTier) {
|
||||
checkbox.disabled = true;
|
||||
}
|
||||
|
||||
return checkbox;
|
||||
});
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue