DndDice/R/reroll.R
Joel Therrien 566b48ff62 Bug fixes for when die roll is non-integer
Also added a reroll function and simplified code greatly
2019-05-29 10:35:13 -07:00

20 lines
480 B
R

#' Reroll
#'
#' If the die lands on the provided \code{numbers}, then the die is re-rolled
#' once with the output being final.
#'
#' @param x The die to possibly reroll
#' @param numbers The numbers to reroll on
#'
#' @return A new die with updated probabilties
#' @export
#'
#' @examples
#' paladin.greataxe <- reroll(d12, 1:2)
reroll <- function(x, numbers){
which.die.fun <- function(a, b){
ifelse(a %in% numbers, b, a)
}
return(combineDice(x, x, which.die.fun))
}