Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify clock advance odds #481

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/clocks/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,34 @@ export async function advanceClock(

const defaultOdds = clockInfo.raw["default-odds"];
let wrapClockUpdates: (nodes: Node[]) => Node[];
let rollOdds = 100
let oddsName = "no roll"

if (defaultOdds !== "no roll") {
const oddsIndex = namedOddsSchema.options.findIndex(
(val) => defaultOdds === val,
);
const roll = await CustomSuggestModal.select(
plugin.app,
namedOddsSchema.options,
(odds) => `${capitalize(odds)} (${STANDARD_ODDS[odds]}%)`,
(odds) => `${capitalize(odds)} (${STANDARD_ODDS[odds]}%)${STANDARD_ODDS[odds] == 100 ? " -> advance without roll" : ""}`,
undefined,
"Choose the odds to advance",
oddsIndex > -1 ? oddsIndex : undefined,
);
const rollOdds = STANDARD_ODDS[roll];
rollOdds = STANDARD_ODDS[roll];
oddsName = roll
}

if (rollOdds < 100) {
const result = await campaignContext
.diceRollerFor("move")
.rollAsync(DiceGroup.of(Dice.fromDiceString("1d100", DieKind.Oracle)));
const shouldAdvance = result[0].value <= rollOdds;

wrapClockUpdates = (nodes) => {
const props: { name: string; roll: number; result: string } = {
name: `Will [[${clockPath}|${stripMarkdown(plugin, clockInfo.name)}]] advance? (${capitalize(roll)})`,
name: `Will [[${clockPath}|${stripMarkdown(plugin, clockInfo.name)}]] advance? (${capitalize(oddsName)})`,
roll: result[0].value,
result: shouldAdvance ? "Yes" : "No",
};
Expand Down