R/build_games.R

Defines functions games_row build_games

Documented in build_games

#' Build candidate replacement for Games wiki page
#'
#' `build_games()` builds a candidate replacement for Games piecepack wiki page
#'
#' @inheritParams download_game_metadata
#' @return A character vector with the text for the candidate replacement for Games wiki page.
#'         As a side effect also saves to
#'         `file.path(tools::R_user_dir("ppwicker", "cache"), "games.creole")`.
#'
#' @export
build_games <- function(update = FALSE) {
    df <- download_game_metadata(update = update)

    creole_file <- file.path(tools::R_user_dir("ppwicker", "cache"),
                             "games.creole")

    header <- "|=Games|=Designer / Adapter|=Equipment Required|"
    rows <- purrr::pmap(df, games_row)

    text <- c(games_preamble, header, unlist(rows))

    writeLines(text, creole_file)

    invisible(text)
}

games_row <- function(name, designer, bits, ...) {
    str_glue('| ["{name}"] | {designer} | {bits} |')
}

games_preamble <- '
**Note:** This page is [[https://github.com/piecepackr/ppwicker | computer-generated from individual game metadata]]  and manually uploaded to the wiki.
Please let me know of any errors or if outdated and I\'ll take a look.  --TrevorLDavis

For a complete list of games on the wiki, check the CategoryGame page.
The GamesStatistics spreadsheet with all the games makes it easy to get various statistics on the games.

----

The below are the games that have a description page on this Wiki.
To keep up with the latest games, see NewGames.
For curated lists of good games to play, see [[Competitions]], RecommendedGames, GamersDozen, FreeCulcha, and ["The_Infinite_Board_Game"].
You can also view lists of games sorted by

* NumberOfPlayers required for play
* TimeToPlay each game
* RequiredEquipment
* GameThemes
* GameMechanics

Also see games sorted by ["License"].

For a categorised list of piecepack games see TaxonomyOfPiecepackGames.

For a list of abstract games that you can play with a piecepack see GenericAbstracts.

----

'
piecepackr/ppwicker documentation built on July 16, 2022, 3:25 a.m.