mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-10 19:17:09 +01:00
Added a check for card duplicates on character
This commit is contained in:
parent
9d038d283a
commit
6a9ccc8c3f
1 changed files with 13 additions and 13 deletions
|
|
@ -429,20 +429,20 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const cardExistsInCharacter = this.actor.items.find(x => x.name === item.name); // Any other way to check? The item is a copy so different ids
|
||||||
Object.values(this.levelup.levels).some(level => {
|
const cardExistsInLevelup = Object.values(this.levelup.levels).some(level => {
|
||||||
const achievementExists = Object.values(level.achievements.domainCards).some(
|
const achievementExists = Object.values(level.achievements.domainCards).some(
|
||||||
card => card.uuid === item.uuid
|
card => card.uuid === item.uuid
|
||||||
);
|
);
|
||||||
const advancementExists = Object.keys(level.choices).some(choiceKey => {
|
const advancementExists = Object.keys(level.choices).some(choiceKey => {
|
||||||
if (choiceKey !== 'domainCard') return false;
|
if (choiceKey !== 'domainCard') return false;
|
||||||
const choice = level.choices[choiceKey];
|
const choice = level.choices[choiceKey];
|
||||||
return Object.values(choice).some(checkbox => checkbox.data.includes(item.uuid));
|
return Object.values(choice).some(checkbox => checkbox.data.includes(item.uuid));
|
||||||
});
|
});
|
||||||
|
|
||||||
return achievementExists || advancementExists;
|
return achievementExists || advancementExists;
|
||||||
})
|
});
|
||||||
) {
|
if (cardExistsInCharacter || cardExistsInLevelup) {
|
||||||
ui.notifications.error(
|
ui.notifications.error(
|
||||||
game.i18n.localize('DAGGERHEART.Application.LevelUp.notifications.error.domainCardDuplicate')
|
game.i18n.localize('DAGGERHEART.Application.LevelUp.notifications.error.domainCardDuplicate')
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue