Fixed subclass effects

This commit is contained in:
WBHarry 2025-06-21 22:39:53 +02:00
parent c15d55a505
commit 51f9b5d5c1
4 changed files with 26 additions and 18 deletions

View file

@ -300,9 +300,9 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
return { return {
armor: characterGuide.suggestedArmor ?? null, armor: characterGuide.suggestedArmor ?? null,
primaryWeapon: characterGuide.suggestedPrimaryWeapon ?? null, primaryWeapon: characterGuide.suggestedPrimaryWeapon ?? null,
secondaryWeapon: secondaryWeapon: characterGuide.suggestedSecondaryWeapon
{ ...characterGuide.suggestedSecondaryWeapon, uuid: characterGuide.suggestedSecondaryWeapon.uuid } ?? ? { ...characterGuide.suggestedSecondaryWeapon, uuid: characterGuide.suggestedSecondaryWeapon.uuid }
null, : null,
inventory: { inventory: {
take: inventory.take ?? [], take: inventory.take ?? [],
choiceA: choiceA:
@ -399,11 +399,19 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
const data = TextEditor.getDragEventData(event); const data = TextEditor.getDragEventData(event);
const item = await foundry.utils.fromUuid(data.uuid); const item = await foundry.utils.fromUuid(data.uuid);
if (item.type === 'ancestry' && event.target.closest('.ancestry-card')) { if (item.type === 'ancestry' && event.target.closest('.ancestry-card')) {
this.setup.ancestry = { ...item, uuid: item.uuid }; this.setup.ancestry = {
...item,
effects: Array.from(item.effects).map(x => x.toObject()),
uuid: item.uuid
};
} else if (item.type === 'community' && event.target.closest('.community-card')) { } else if (item.type === 'community' && event.target.closest('.community-card')) {
this.setup.community = { ...item, uuid: item.uuid }; this.setup.community = {
...item,
effects: Array.from(item.effects).map(x => x.toObject()),
uuid: item.uuid
};
} else if (item.type === 'class' && event.target.closest('.class-card')) { } else if (item.type === 'class' && event.target.closest('.class-card')) {
this.setup.class = { ...item, uuid: item.uuid }; this.setup.class = { ...item, effects: Array.from(item.effects).map(x => x.toObject()), uuid: item.uuid };
this.setup.subclass = {}; this.setup.subclass = {};
this.setup.domainCards = { this.setup.domainCards = {
[foundry.utils.randomID()]: {}, [foundry.utils.randomID()]: {},
@ -417,7 +425,11 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
return; return;
} }
this.setup.subclass = { ...item, uuid: item.uuid }; this.setup.subclass = {
...item,
effects: Array.from(item.effects).map(x => x.toObject()),
uuid: item.uuid
};
} else if (item.type === 'domainCard' && event.target.closest('.domain-card')) { } else if (item.type === 'domainCard' && event.target.closest('.domain-card')) {
if (!this.setup.class.uuid) { if (!this.setup.class.uuid) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.CharacterCreation.Notifications.MissingClass')); ui.notifications.error(game.i18n.localize('DAGGERHEART.CharacterCreation.Notifications.MissingClass'));

View file

@ -302,7 +302,7 @@ export class EncounterCountdowns extends Countdowns {
} }
export const registerCountdownApplicationHooks = () => { export const registerCountdownApplicationHooks = () => {
const updateCountdowns = async shouldIncrease => { const updateCountdowns = async shouldProgress => {
if (game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation).countdowns) { if (game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation).countdowns) {
const countdownSetting = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Countdowns); const countdownSetting = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Countdowns);
for (let countdownCategoryKey in countdownSetting) { for (let countdownCategoryKey in countdownSetting) {
@ -310,10 +310,10 @@ export const registerCountdownApplicationHooks = () => {
for (let countdownKey in countdownCategory.countdowns) { for (let countdownKey in countdownCategory.countdowns) {
const countdown = countdownCategory.countdowns[countdownKey]; const countdown = countdownCategory.countdowns[countdownKey];
if (shouldIncrease(countdown)) { if (shouldProgress(countdown)) {
await countdownSetting.updateSource({ await countdownSetting.updateSource({
[`${countdownCategoryKey}.countdowns.${countdownKey}.progress.current`]: [`${countdownCategoryKey}.countdowns.${countdownKey}.progress.current`]:
countdown.progress.current + 1 countdown.progress.current - 1
}); });
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Countdowns, countdownSetting); await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Countdowns, countdownSetting);
foundry.applications.instances.get(`${countdownCategoryKey}-countdowns`)?.render(); foundry.applications.instances.get(`${countdownCategoryKey}-countdowns`)?.render();
@ -326,18 +326,14 @@ export const registerCountdownApplicationHooks = () => {
Hooks.on(SYSTEM.HOOKS.characterAttack, async () => { Hooks.on(SYSTEM.HOOKS.characterAttack, async () => {
updateCountdowns(countdown => { updateCountdowns(countdown => {
return ( return (
countdown.progress.type.value === countdownTypes.characterAttack.id && countdown.progress.type.value === countdownTypes.characterAttack.id && countdown.progress.current > 0
countdown.progress.current < countdown.progress.max
); );
}); });
}); });
Hooks.on(SYSTEM.HOOKS.spotlight, async () => { Hooks.on(SYSTEM.HOOKS.spotlight, async () => {
updateCountdowns(countdown => { updateCountdowns(countdown => {
return ( return countdown.progress.type.value === countdownTypes.spotlight.id && countdown.progress.current > 0;
countdown.progress.type.value === countdownTypes.spotlight.id &&
countdown.progress.current < countdown.progress.max
);
}); });
}); });
}; };

View file

@ -89,7 +89,7 @@ class DhCountdown extends foundry.abstract.DataModel {
current: new fields.NumberField({ current: new fields.NumberField({
required: true, required: true,
integer: true, integer: true,
initial: 0, initial: 1,
label: 'DAGGERHEART.Countdown.FIELDS.countdowns.element.progress.current.label' label: 'DAGGERHEART.Countdown.FIELDS.countdowns.element.progress.current.label'
}), }),
max: new fields.NumberField({ max: new fields.NumberField({

View file

@ -64,7 +64,7 @@ export default class DHSubclass extends BaseDataItem {
} else if (subclassData) { } else if (subclassData) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.SubclassAlreadySelected')); ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.SubclassAlreadySelected'));
return false; return false;
} else if (classData.system.subclasses.every(x => x.uuid !== data.uuid ?? `Item.${data._id}`)) { } else if (classData.system.subclasses.every(x => x.uuid !== (data.uuid ?? `Item.${data._id}`))) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.SubclassNotInClass')); ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.SubclassNotInClass'));
return false; return false;
} }