Skip to content

Commit

Permalink
fix: Fixes issue with Dice Roller integration (close #232)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Oct 12, 2023
1 parent 396238c commit 3888416
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class API {
creatures: HomebrewCreature[],
rollHP: boolean = this.plugin.data.rollHP
) {
console.log("🚀 ~ file: api.ts:18 ~ creatures:", creatures);
if (!creatures || !Array.isArray(creatures) || !creatures.length) {
throw new Error("Creatures must be an array.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/encounter/ui/Encounter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
creatureMap = creatureMap;
});
rollerMap.set(creature, roller);
roller.roll();
roller.rollSync();
} else {
creatureMap.set(creature, number);
}
Expand Down
4 changes: 2 additions & 2 deletions src/encounter/ui/EncounterLine.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
creatureMap.set(creature, roller.result);
});
rollerMap.set(creature, roller);
roller.roll();
roller.rollSync();
} else {
creatureMap.set(creature, number);
}
Expand Down Expand Up @@ -156,7 +156,7 @@

<style>
.creature-name {
cursor: pointer;
cursor: pointer;
}
.encounter-line {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/encounter/ui/EncounterRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
creatureMap = creatureMap;
});
rollerMap.set(creature, roller);
roller.roll();
roller.rollSync();
} else {
creatureMap.set(creature, number);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import BuilderView from "./builder/view";
import PlayerView from "./tracker/player-view";
import { tracker } from "./tracker/stores/tracker";
import { EncounterSuggester } from "./encounter/editor-suggestor";
import { API } from "./api/api"
import { API } from "./api/api";
declare module "obsidian" {
interface App {
plugins: {
Expand Down Expand Up @@ -99,8 +99,10 @@ export default class InitiativeTracker extends Plugin {
dice = dice.replace(`%mod${i + 1}%`, `${modifier[i]}`);
}
}
console.log("🚀 ~ file: main.ts:103 ~ dice:", dice);
const roller = this.getRoller(dice);
const initiative = roller.rollSync();
console.log("🚀 ~ file: main.ts:104 ~ initiative:", initiative);
if (isNaN(initiative)) return defaultIfNoResult;
return initiative;
}
Expand Down

0 comments on commit 3888416

Please sign in to comment.