Skip to content

Commit c8713a6

Browse files
committed
fix: broken cs/cf in baseRoll
1 parent ac117c5 commit c8713a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/bot/src/commands/roll/base_roll.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ export async function baseRoll(
8585

8686
let opposition: ComparedValue | undefined;
8787
const evaluated = DICE_COMPILED_PATTERNS.TARGET_VALUE.exec(dice);
88-
logger.trace("Evaluated dice regex result:", evaluated);
88+
logger.trace("Evaluated dice regex result" + ":", evaluated);
8989
if (!evaluated) {
90+
// Preclean to ignore {cs|cf:...} blocs before checking for opposition
91+
const contentForOpposition = dice.replace(REMOVER_PATTERN.CRITICAL_BLOCK, "");
9092
// Remove the second comparator for opposition rolls (e.g., 1d20>15>20 becomes 1d20>15)
91-
const oppositionMatch = DICE_COMPILED_PATTERNS.OPPOSITION.exec(dice);
93+
const oppositionMatch = DICE_COMPILED_PATTERNS.OPPOSITION.exec(contentForOpposition);
9294
opposition = parseComparator(dice, userData?.stats, undefined);
9395
logger.trace("Opposition match regex result:", oppositionMatch, opposition);
9496
if (oppositionMatch?.groups?.second)

0 commit comments

Comments
 (0)