Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Jan 15, 2023
1 parent 0b4b3b7 commit 5601781
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"DND5E.AdvancementItemChoiceHint": "Present the player with a choice of items (such as equipment, features, or spells) that they can choose for their character at one or more levels.",
"DND5E.AdvancementItemChoiceChosen": "Chosen: {current} of {max}",
"DND5E.AdvancementItemChoiceLevelsHint": "Specify how many choices are allowed at each level.",
"DND5E.AdvancementItemChoicePreviouslyChosenWarning": "This item has already been chosen at a previous level.",
"DND5E.AdvancementItemChoiceSpellLevelAvailable": "Any Available Level",
"DND5E.AdvancementItemChoiceSpellLevelAvailableWarning": "Only {level} or lower spells can be chosen for this advancement.",
"DND5E.AdvancementItemChoiceSpellLevelSpecificWarning": "Only {level} spells can be chosen for this advancement.",
Expand Down
6 changes: 4 additions & 2 deletions module/applications/advancement/item-choice-flow.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ export default class ItemChoiceFlow extends ItemGrantFlow {
if ( this.selected.has(item.uuid) ) return false;

// Check to ensure the dropped item hasn't been selected at a lower level
for ( const [level, data] of Object.entries(this.advancement.value) ) {
for ( const [level, data] of Object.entries(this.advancement.value.added ?? {}) ) {
if ( level >= this.level ) continue;
if ( Object.values(data).includes(item.uuid) ) return;
if ( Object.values(data).includes(item.uuid) ) {
return ui.notifications.error(game.i18n.localize("DND5E.AdvancementItemChoicePreviouslyChosenWarning"));
}
}

// If spell level is restricted to available level, ensure the spell is of the appropriate level
Expand Down

0 comments on commit 5601781

Please sign in to comment.