@@ -16,11 +16,11 @@ import { appendNodesToMoveOrMechanicsBlockWithActor } from "mechanics/editor";
1616import { DieKind } from "utils/dice-roller" ;
1717import { node } from "utils/kdl" ;
1818import { CustomSuggestModal } from "utils/suggest" ;
19- import { PromptModal } from "utils/ui/prompt" ;
2019import { CharacterContext } from "../../character-tracker" ;
2120import { MomentumTracker , momentumTrackerReader } from "../../characters/lens" ;
2221import { ActionMoveDescription } from "../desc" ;
2322import { ActionMoveWrapper , formatRollResult } from "../wrapper" ;
23+ import { numberRange } from "@ironvault/utils/numbers" ;
2424
2525export async function checkForMomentumBurn (
2626 app : App ,
@@ -141,29 +141,40 @@ export async function rerollDie(
141141 undefined ,
142142 "Select the die to reroll" ,
143143 ) ;
144- let newValue : string ;
144+ let newValue : string | undefined = undefined ;
145+ let dieSides : number = 10 ;
146+
147+ if ( dieName === "action" ) {
148+ // Action die is always 6 sides.
149+ dieSides = 6 ;
150+ }
151+ // For challenge dice, we need to check the campaign settings to determine the number of sides.
152+ else if ( dieName === "vs1" || dieName === "vs2" ) {
153+ // Get the number of sides for the challenge dice from the campaign settings.
154+ // This assumes that the campaign settings have been properly initialized and contain the sides for the dice.
155+ // If the campaign settings are not available, default to 10 sides for challenge dice.
156+ const [ challenge1Sides , challenge2Sides ] = actionContext . campaignContext
157+ . localSettings . actionRollChallengeDiceSides ?? [ 10 , 10 ] ;
158+ dieSides = dieName === "vs1" ? challenge1Sides : challenge2Sides ;
159+ }
160+
145161 if ( plugin . settings . promptForRollsInMoves ) {
146- newValue = await PromptModal . prompt (
162+ const choice = await CustomSuggestModal . select (
147163 plugin . app ,
148- "Enter the new die roll value" ,
164+ [ "Roll for me" , ...numberRange ( 1 , dieSides ) ] ,
165+ ( x ) => x . toString ( ) ,
166+ undefined ,
167+ `Roll ${ dieName == "action" ? "your action" : "one challenge" } die (1d${ dieSides } ) and enter the value` ,
149168 ) ;
150- } else {
151- let dieSides : number = 10 ;
152169
153- if ( dieName === "action" ) {
154- // Action die is always 6 sides.
155- dieSides = 6 ;
156- }
157- // For challenge dice, we need to check the campaign settings to determine the number of sides.
158- else if ( dieName === "vs1" || dieName === "vs2" ) {
159- // Get the number of sides for the challenge dice from the campaign settings.
160- // This assumes that the campaign settings have been properly initialized and contain the sides for the dice.
161- // If the campaign settings are not available, default to 10 sides for challenge dice.
162- const [ challenge1Sides , challenge2Sides ] = actionContext . campaignContext
163- . localSettings . actionRollChallengeDiceSides ?? [ 10 , 10 ] ;
164- dieSides = dieName === "vs1" ? challenge1Sides : challenge2Sides ;
170+ if ( typeof choice === "number" ) {
171+ newValue = "" + choice ;
165172 }
173+ }
166174
175+ if ( newValue === undefined ) {
176+ // newValue isn't set yet, meaning either settings.promptForRollsInMoves isn't enabled,
177+ // or user chose "Roll for me" when prompted. Invoke dice roller in either case.
167178 newValue =
168179 "" +
169180 (
0 commit comments