Skip to content

Commit

Permalink
Ensure dropped choice hasn't been selected at a previous level
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Jul 5, 2022
1 parent bd67124 commit a0d569e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions module/advancement/item-choice.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ export class ItemChoiceFlow extends AdvancementFlow {
// If the item is already been marked as selected, no need to go further
if ( this.selected.has(item.uuid) ) return false;

// TODO: Check to ensure the dropped item hasn't been selected at a lower level
// Check to ensure the dropped item hasn't been selected at a lower level
for ( const [level, data] of Object.entries(this.advancement.data.value) ) {
if ( level >= this.level ) continue;
if ( Object.values(data).includes(item.uuid) ) return;
}

// If spell level is restricted, ensure the spell is of the appropriate level
const spellLevel = this.advancement.data.configuration.spell?.level;
Expand All @@ -357,7 +361,6 @@ export class ItemChoiceFlow extends AdvancementFlow {
if ( item.data.data.level > maxSlot ) return ui.notifications.warn(game.i18n.format(
"DND5E.AdvancementItemChoiceSpellLevelAvailableWarning", { level: CONFIG.DND5E.spellLevels[maxSlot] }
));
// TODO: Ensure the spell level is less than or equal to maximum available spell slot
} else if ( item.data.data.level !== parseInt(spellLevel) ) {
return ui.notifications.warn(game.i18n.format(
"DND5E.AdvancementItemChoiceSpellLevelSpecificWarning", { level: CONFIG.DND5E.spellLevels[spellLevel] }
Expand Down

0 comments on commit a0d569e

Please sign in to comment.