Skip to content

Commit

Permalink
fix: use statblock's bestiary names API vs transforming every time
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Aug 17, 2023
1 parent f625175 commit e7038d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/encounter/editor-suggestor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class EncounterSuggester extends EditorSuggest<string> {
);
break;
case SuggestContext.Creatures:
suggestions = this.plugin.bestiary?.map((b) => b.name);
suggestions = this.plugin.bestiaryNames;
break;
case SuggestContext.Party:
suggestions = this.plugin.data.parties?.map((p) => p.name);
Expand Down
12 changes: 11 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import TrackerView, { CreatureView } from "./tracker/view";
import BuilderView from "./builder/view";
import PlayerView from "./tracker/player-view";
import { tracker } from "./tracker/stores/tracker";
import { EncounterSuggester } from './encounter/editor-suggestor';
import { EncounterSuggester } from "./encounter/editor-suggestor";
declare module "obsidian" {
interface App {
plugins: {
Expand Down Expand Up @@ -153,6 +153,16 @@ export default class InitiativeTracker extends Plugin {
get bestiary() {
return this.statblock_creatures.filter((p) => !p.player);
}

get bestiaryNames(): string[] {
if (!this.app.plugins.getPlugin("obsidian-5e-statblocks")) return [];
return (
(this.app.plugins
.getPlugin("obsidian-5e-statblocks")
//@ts-ignore
?.getBestiaryNames() as string[]) ?? []
);
}
get view() {
const leaves = this.app.workspace.getLeavesOfType(
INITIATIVE_TRACKER_VIEW
Expand Down

0 comments on commit e7038d1

Please sign in to comment.