Skip to content

Commit

Permalink
feat(game_systems()): 'dice_numeral' configuration
Browse files Browse the repository at this point in the history
* The following enhancements to the configurations returned by `game_systems()`:

  - New configuration ``dice_numeral`` which provide six-sided dice with numerals instead of pips in six color schemes.

closes #311
  • Loading branch information
trevorld committed Feb 25, 2023
1 parent 529a18c commit f3d2705
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 98 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Encoding: UTF-8
Package: piecepackr
Type: Package
Title: Board Game Graphics
Version: 1.13.0-7
Version: 1.13.0-8
Description: Functions to make board game graphics with the 'ggplot2', 'grid', 'rayrender', 'rayvertex', and 'rgl' packages. Specializes in game diagrams, animations, and "Print & Play" layouts for the 'piecepack' <https://www.ludism.org/ppwiki> but can make graphics for other board game systems. Includes configurations for several public domain game systems such as checkers, (double-18) dominoes, go, 'piecepack', playing cards, etc.
Authors@R: c(person("Trevor L", "Davis", role=c("aut", "cre"),
email="trevor.l.davis@gmail.com",
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ New features

- New configuration ``dice_d4`` which provide four-sided dice in six color schemes (color controlled by their suit).
Tetrahedrons with the rank as a numeral at the top point (#286).
- New configuration ``dice_numeral`` which provide six-sided dice with numerals instead of pips in six color schemes (#311).
- New configurations ``dominoes_chinese`` and ``dominoes_chinese_black`` which provide [Chinese dominoes](https://en.wikipedia.org/wiki/Chinese_dominoes) and [Asian-style dice](https://en.wikipedia.org/wiki/Dice#Arrangement).
``dominoes_chinese`` has a white background with black and red pips while ``dominoes_chinese_black`` has a black background with white and red pips (#308).

Expand Down
19 changes: 19 additions & 0 deletions R/game_systems.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#' Tetrahedrons with the rank as a numeral at the top point.}
#' \item{dice_fudge}{\dQuote{Fudge} dice in six color schemes (color controlled by their suit).
#' \dQuote{Fudge} dice have three ranks "+", " ", and "-" repeated twice.}
#' \item{dice_numeral}{Six-sided dice with numerals instead of pips in six color schemes (color controlled by their suit).}
#' \item{dominoes, dominoes_black, dominoes_blue, dominoes_green, dominoes_red, dominoes_white, dominoes_yellow}{
#' Traditional pipped dominoes in six color schemes (\code{dominoes} and \code{dominoes_white} are the same).
#' In each color scheme the number of pips on the \dQuote{top} of the domino is
Expand Down Expand Up @@ -159,6 +160,7 @@ game_systems <- function(style = NULL, round = FALSE, pawn = "token") {
dice = dice(color_list, rect_shape),
dice_d4 = dice_d4(style, color_list),
dice_fudge = dice_fudge(color_list, rect_shape),
dice_numeral = dice_numeral(style, color_list, rect_shape),
dominoes = dominoes(color_list$suit_color[6], "black", color_list$border_color, rect_shape),
dominoes_black = dominoes(color_list$suit_color[2], "white", color_list$border_color, rect_shape),
dominoes_blue = dominoes(color_list$suit_color[4], "white", color_list$border_color, rect_shape),
Expand Down Expand Up @@ -281,6 +283,23 @@ dice_d4 <- function(style, color_list) {
dice
}

dice_numeral <- function(style, color_list, rect_shape) {
dice_list <- list(n_suits = 6, n_ranks = 6,
fontfamily = ifelse(grepl("^dejavu", style), "DejaVu Sans", "sans"),
rank_text = "1,2,3,4,5,6\u0331",
suit_text.die = "",
ps_cex.die = 1.8,
width.die = 16 / 25.4, # 16 mm dice most common
background_color = "white,white,white,white,black,black",
invert_colors = TRUE,
die_arrangement = "1<,2>,3>,6v,5,4",
shape.card = rect_shape)
dice <- pp_cfg(c(dice_list, color_list))
dice$has_piecepack <- FALSE
dice$has_dice <- TRUE
dice
}

meeples <- function(color_list) {
meeples_list <- list(shape.bit = "meeple", n_suits = 6,
width.bit = 16 / 25.4, height.bit = 16 / 25.4, depth.bit = 10 / 25.4,
Expand Down
2 changes: 1 addition & 1 deletion R/save_print_and_play.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ save_print_and_play <- function(cfg = getOption("piecepackr.cfg", pp_cfg()),
add_pdf_metadata(output_filename, cfg, pl)
} else if (!isFALSE(getOption("piecepackr.metadata.inform"))) {
msg <- c(x = "Need the {xmpdf} package to embed pdf metadata",
i = '`remotes::install_github("trevorld/r-xmpdf")`',
i = '`install.packages("xmpdf")`',
i = "These messages can be disabled via `options(piecepackr.metadata.inform = FALSE)`.")
inform(msg, class = "piecepackr_embed_metadata")

Expand Down
1 change: 1 addition & 0 deletions man/game_systems.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f3d2705

Please sign in to comment.