Skip to content

Commit 638d07b

Browse files
add basic comments to document each function
1 parent 7d548ac commit 638d07b

File tree

14 files changed

+200
-11
lines changed

14 files changed

+200
-11
lines changed

.gitignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,26 @@
44

55
# Session Data files
66
.RData
7-
87
# Example code in package build process
98
*-Ex.R
10-
119
# Output files from R CMD build
1210
/*.tar.gz
13-
1411
# Output files from R CMD check
1512
/*.Rcheck/
16-
1713
# RStudio files
1814
.Rproj.user/
19-
2015
# produced vignettes
2116
vignettes/*.html
2217
vignettes/*.pdf
23-
2418
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
2519
.httr-oauth
26-
2720
# knitr and R markdown default cache directories
2821
/*_cache/
2922
/cache/
30-
3123
# Temporary files created by R markdown
3224
*.utf8.md
3325
*.knit.md
34-
3526
# Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html
3627
rsconnect/
3728
.Rproj.user
29+
inst/doc

DESCRIPTION

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ Description: More about what it does (maybe more than one line)
88
Use four spaces when indenting paragraphs within the Description.
99
License: What license is it under?
1010
Encoding: UTF-8
11-
LazyData: true
11+
LazyData: true
12+
RoxygenNote: 6.0.1
13+
Suggests: knitr,
14+
rmarkdown
15+
VignetteBuilder: knitr

NAMESPACE

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
exportPattern("^[[:alpha:]]+")
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(cast_dice)
4+
export(d10)
5+
export(d100)
6+
export(d20)
7+
export(d4)
8+
export(d6)
9+
export(d8)
10+
export(sicherman)

R/dice.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
#' Cast a dice
2+
#'
3+
#' @param sides can either be an integer value (maximum value on a standard dice) or a vector of sides.
4+
#' @param n_tries how often the dice should be cast.
5+
#' @param sum whether the result of casting the dice should be summed.
6+
#' @examples
7+
#' cast_dice()
8+
#' cast_dice(5)
9+
#' cast_dice(1:5) # same as example above
10+
#' cast_dice(20, 3)
11+
#' cast_dice(20, 3, TRUE)
12+
#' @export
113
cast_dice <- function(sides = 1:6, n_tries = 1, sum = FALSE) {
214
result <- sample(sides, n_tries, TRUE)
315
if (sum) {

R/dnd_dice.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,53 @@
1+
#' Cast a D4
2+
#'
3+
#' @param n_tries how often the dice should be cast.
4+
#' @param sum whether the result of casting the dice should be summed.
5+
#' @export
16
d4 <- function(n_tries = 1, sum = FALSE) {
27
return(cast_dice(4, n_tries, sum))
38
}
49

10+
#' Cast a D6
11+
#'
12+
#' @param n_tries how often the dice should be cast.
13+
#' @param sum whether the result of casting the dice should be summed.
14+
#' @export
515
d6 <- function(n_tries = 1, sum = FALSE) {
616
return(cast_dice(6, n_tries, sum))
717
}
818

19+
#' Cast a D8
20+
#'
21+
#' @param n_tries how often the dice should be cast.
22+
#' @param sum whether the result of casting the dice should be summed.
23+
#' @export
924
d8 <- function(n_tries = 1, sum = FALSE) {
1025
return(cast_dice(8, n_tries, sum))
1126
}
1227

28+
#' Cast a D10
29+
#'
30+
#' @param n_tries how often the dice should be cast.
31+
#' @param sum whether the result of casting the dice should be summed.
32+
#' @export
1333
d10 <- function(n_tries = 1, sum = FALSE) {
1434
return(cast_dice(10, n_tries, sum))
1535
}
1636

37+
#' Cast a D20
38+
#'
39+
#' @param n_tries how often the dice should be cast.
40+
#' @param sum whether the result of casting the dice should be summed.
41+
#' @export
1742
d20 <- function(n_tries = 1, sum = FALSE) {
1843
return(cast_dice(20, n_tries, sum))
1944
}
2045

46+
#' Cast a D100
47+
#'
48+
#' @param n_tries how often the dice should be cast.
49+
#' @param sum whether the result of casting the dice should be summed.
50+
#' @export
2151
d100 <- function(n_tries = 1, sum = FALSE) {
2252
return(cast_dice(100, n_tries, sum))
2353
}

R/special_dice.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#' Cast a Sicherman dice
2+
#'
3+
#' @param n_tries how often the dice should be cast.
4+
#' @param sum whether the result of casting the dice should be summed.
5+
#' @export
16
sicherman <- function(n_tries=1, sum = FALSE) {
27
s1 <- .sicherman1(n_tries)
38
s2 <- .sicherman2(n_tries)

man/cast_dice.Rd

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/d10.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/d100.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/d20.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)