Skip to content

Commit

Permalink
fix: fixes bug preventing adding players via the "Add Creature" button (
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Aug 16, 2023
1 parent 169cc7d commit 3e5cc4d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/encounter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ export class EncounterParser {
)
);
}
console.log(
"🚀 ~ file: index.ts:158 ~ playersToReturn:",
playersToReturn
);
return Array.from(new Set(playersToReturn));
}
async parseRawCreatures(rawMonsters: RawCreatureArray) {
Expand Down
11 changes: 11 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ export default class InitiativeTracker extends Plugin {
let creature = this.getBaseCreatureFromBestiary(name);
if (creature) return Creature.from(creature);
}
getCreatureFromBestiaryByDefinition(
creature: SRDMonster | HomebrewCreature
): Creature {
if (creature.player && this.playerCreatures.has(creature.name)) {
return this.playerCreatures.get(creature.name);
}
return (
this.getCreatureFromBestiary(creature.name) ??
Creature.from(creature)
);
}
get statblock_players() {
return this.statblock_creatures
.filter((p) => p.player)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/suggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ export class SRDMonsterSuggestionModal extends SuggestionModal<
}
onChooseItem(item: HomebrewCreature | SRDMonster) {
this.inputEl.value = item.name;
this.creature = this.plugin.getBaseCreatureFromBestiary(item.name);
this.creature = this.plugin.getCreatureFromBestiaryByDefinition(item);
this.onClose();
this.close();
}
selectSuggestion({ item }: FuzzyMatch<HomebrewCreature | SRDMonster>) {
this.inputEl.value = item.name;
this.creature = this.plugin.getBaseCreatureFromBestiary(item.name);
this.creature = this.plugin.getCreatureFromBestiaryByDefinition(item);
this.onClose();
this.close();
}
Expand Down

0 comments on commit 3e5cc4d

Please sign in to comment.