diff --git a/inc/functions.php b/inc/functions.php index 72e6afaa..2328c1b7 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2813,10 +2813,12 @@ function handle_dice_roll_markup(array $matches, ?string $img_path): string { $dice_faces = 6; } - $tot = $dice_offset; + $tot = 0; for ($i = 0; $i < $dice_count; $i++) { $tot += mt_rand(1, $dice_faces); } + // Ensure that final result is at least an integer. + $tot = abs((int)($dice_offset + $tot)); if ($img_path !== null) { $img_text = "dice";