Title: | Piecepack Game Rules |
---|---|
Description: | Functions to generate piecepack game rulesets and books. |
Authors: | Trevor L Davis [aut, cre] |
Maintainer: | Trevor L Davis <[email protected]> |
License: | CC BY-SA 4.0 |
Version: | 0.1.0-1 |
Built: | 2024-11-03 05:06:20 UTC |
Source: | https://github.com/piecepackr/pprules |
game_kit
creates a game kit R6 object.
game_kit(cfgs = NULL)
game_kit(cfgs = NULL)
cfgs |
A named list of |
cfg <- piecepackr::game_systems()$dual_piecepacks_expansion gk <- game_kit(list(cfg = cfg)) if (Sys.which("xelatex") != "") { output <- tempfile(fileext = ".pdf") save_pamphlet("tablut", gk = gk, output = output) # xopen::xopen(output) # browseURL(output) }
cfg <- piecepackr::game_systems()$dual_piecepacks_expansion gk <- game_kit(list(cfg = cfg)) if (Sys.which("xelatex") != "") { output <- tempfile(fileext = ".pdf") save_pamphlet("tablut", gk = gk, output = output) # xopen::xopen(output) # browseURL(output) }
names_rulesets()
returns the names of piecepack games we can generate rulesets for.
names_rulesets(book = NULL)
names_rulesets(book = NULL)
book |
Book name or |
save_ruleset()
and save_pamphlet()
.
names_rulesets()
names_rulesets()
save_promo_image()
saves a promo image of a game.
This is usually just a starting diagram for the game but
sometimes we may create a custom image.
save_promo_image(game, gk = game_kit(), file = NULL, ...)
save_promo_image(game, gk = game_kit(), file = NULL, ...)
game |
Game name. Will be normalized by |
gk |
A |
file |
Filename for the image. If |
... |
Passed to |
If we haven't created a custom image for this game then basically
we'll convert the game name to snake case, prepend a "piecepack_"
in front and then dynGet()
a function with that name and use
the resulting data frame with piecepackr::render_piece()
.
See ppdf::games_piecepack()
for list of games directly supported by this package.
A list with the width, height, and filename of the promo image. As a side effect we save an image to disk.
file <- tempfile(fileext = ".pdf") whf <- save_promo_image("Fuji-san", gk = game_kit(), file = file) print(whf) unlink(whf$file)
file <- tempfile(fileext = ".pdf") whf <- save_promo_image("Fuji-san", gk = game_kit(), file = file) print(whf) unlink(whf$file)
save_rulebook
saves a rulebook.
save_rulebook( book = "The Historical Piecepacker", gk = game_kit(), output = NULL, quietly = TRUE, size = "letter", cmd_options = NULL )
save_rulebook( book = "The Historical Piecepacker", gk = game_kit(), output = NULL, quietly = TRUE, size = "letter", cmd_options = NULL )
book |
Book name. Currently only supports "The Historical Piecepacker". |
gk |
A |
output |
Path to the output file.
If |
quietly |
Whether to hide document compilation output. |
size |
Paper size (either "letter", or "A4"). |
cmd_options |
Options passed to |
save_ruleset
save ruleset of a game.
save_pamphlet
is a variant that saves the ruleset as a (tri-fold) pamphlet.
save_ruleset( game, gk = game_kit(), output = NULL, quietly = TRUE, size = "letter", ..., game_info = NULL, game_files = NULL, cmd_options = NULL ) save_pamphlet( game, gk = game_kit(), output = NULL, quietly = TRUE, size = "letter", duplex_edge = "short", ..., game_info = NULL, game_files = NULL, save_promo_fn = save_promo_image )
save_ruleset( game, gk = game_kit(), output = NULL, quietly = TRUE, size = "letter", ..., game_info = NULL, game_files = NULL, cmd_options = NULL ) save_pamphlet( game, gk = game_kit(), output = NULL, quietly = TRUE, size = "letter", duplex_edge = "short", ..., game_info = NULL, game_files = NULL, save_promo_fn = save_promo_image )
game |
Game name to generate ruleset for. See |
gk |
A |
output |
Path to the output file.
If |
quietly |
Whether to hide document compilation output. |
size |
Paper size (either "letter", or "A4"). |
... |
Ignored |
game_info |
List with game info. If |
game_files |
Character vector of (full path to) "Rtex" game rules. If |
cmd_options |
Options passed to |
duplex_edge |
String specifying the desired duplex printing edge. If "short" match the second page along its short edge (second page flipped up, easier to preview on computer) and if "long" match along its long edge (second page flipped upside down, usual printer default). |
save_promo_fn |
A function with arguments |
cfg <- piecepackr::game_systems()$dual_piecepacks_expansion gk <- game_kit(list(cfg = cfg)) if (Sys.which("xelatex") != "") { output <- tempfile(fileext = ".pdf") save_pamphlet("tablut", gk = gk, output = output) # xopen::xopen(output) # browseURL(output) }
cfg <- piecepackr::game_systems()$dual_piecepacks_expansion gk <- game_kit(list(cfg = cfg)) if (Sys.which("xelatex") != "") { output <- tempfile(fileext = ".pdf") save_pamphlet("tablut", gk = gk, output = output) # xopen::xopen(output) # browseURL(output) }