DndDice/R/disadvantage_advantage.R

45 lines
900 B
R
Raw Normal View History

2019-03-19 03:56:07 +00:00
#'
#' Disadvantage
#'
#' Disadvantage a die roll, which means that when both die are rolled, the result
#' is the lower number.
#'
#' @param x A die to roll.
#' @param y A die to roll. If not specified, then x is disadvantaged against itself.
#' @return A die representing the minimum of both die
#' @examples
#' disadvantage(d20,d20)
#'
#' @export
disadvantage <- function(x, y=NULL){
if(is.null(y)){
y = x
}
return(combineDice(x, y, pmin))
2019-03-19 03:56:07 +00:00
}
#'
#' Advantage
#'
#' Advantage a die roll, which means that when both die are rolled, the result
#' is the higher number.
#'
#' @param x A die to roll.
#' @param y A die to roll. If not specified, then x is advantaged against itself.
#' @return A die representing the maximum of both die
#' @examples
#' advantage(d20,d20)
#'
#' @export
advantage <- function(x, y=NULL){
if(is.null(y)){
y = x
}
return(combineDice(x, y, pmax))
2019-03-19 03:56:07 +00:00
}