From 12b9be090294bfe83adac047577b528172e78e14 Mon Sep 17 00:00:00 2001 From: "Trevor L. Davis" Date: Thu, 27 Mar 2025 16:03:32 -0700 Subject: [PATCH] feat: Support for 'dice_numeral' dice --- DESCRIPTION | 2 +- NEWS.md | 1 + R/str_piece.r | 10 +++++++--- README.Rmd | 1 + README.md | 1 + tests/testthat/_snaps/cat_piece.md | 12 ++++++++++++ tests/testthat/test_cat_piece.r | 6 ++++++ 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1194677..8766b61 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Encoding: UTF-8 Package: ppcli Type: Package Title: Plaintext Board Game Visualizations -Version: 0.2.0-7 +Version: 0.2.0-8 Authors@R: c(person("Trevor L.", "Davis", role=c("aut", "cre"), email="trevor.l.davis@gmail.com", comment = c(ORCID = "0000-0001-6341-4639"))) diff --git a/NEWS.md b/NEWS.md index bba5c53..acc3c35 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ New features * `cat_piece()` and `str_piece()` adds support for the following game pieces (#4): + "alquerque" bit and board pieces. + + "dice_numeral" dice. + "marbles" bit and board pieces. - However we currently do not distinguish between the nine marble bit ranks. diff --git a/R/str_piece.r b/R/str_piece.r index 2983f25..38373bf 100644 --- a/R/str_piece.r +++ b/R/str_piece.r @@ -147,7 +147,8 @@ get_style_combining <- function(style) { dual_piecepacks_expansion = french_suits_white, subpack = piecepack_suits, dice = die_suits, - dice_fudge = die_suits) + dice_fudge = die_suits, + dice_numeral = die_suits) list(coin = coin, die = die, pawn = pawn) } @@ -186,6 +187,7 @@ get_style_rs <- function(style, big = FALSE) { chess2 = c("\u265f", "\u265e", "\u265d", "\u265c", "\u265b", "\u265a"), dice = dominoes_ranks[-1], dice_fudge = dice_fudge, + dice_numeral = as.character(1:6), dominoes = dominoes_ranks, dominoes_black = dominoes_ranks, dominoes_blue = dominoes_ranks, @@ -236,6 +238,7 @@ get_style_ss <- function(style, big = FALSE) { chess2 = "", dice = rep_len(" ", 6L), dice_fudge = rep_len(" ", 6L), + dice_numeral = rep_len(" ", 6L), dominoes = dominoes_ranks, dominoes_black = dominoes_ranks, dominoes_blue = dominoes_ranks, @@ -268,8 +271,9 @@ get_style_fg <- function(style) { chess2 = suit_colors, checkers1 = suit_colors, checkers2 = suit_colors, - dice = suit_colors, - dice_fudge = suit_colors, + dice = dice_colors, + dice_fudge = dice_colors, + dice_numeral = dice_colors, dominoes = rep_len("black", 7L), dominoes_black = rep_len(dice_colors[2L], 7L), dominoes_blue = rep_len(dice_colors[4L], 7L), diff --git a/README.Rmd b/README.Rmd index faf5e52..1119a77 100644 --- a/README.Rmd +++ b/README.Rmd @@ -80,6 +80,7 @@ We don't need to know nearly as much state about how other game pieces were draw * [{piecepackr}](https://github.com/piecepackr/piecepackr) * [{ppdf}](https://github.com/piecepackr/ppdf) +* [{ppn}](https://github.com/piecepackr/ppn) ### Blog/forum posts diff --git a/README.md b/README.md index 7280f91..95ac0a9 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ We don't need to know nearly as much state about how other game pieces were draw * [{piecepackr}](https://github.com/piecepackr/piecepackr) * [{ppdf}](https://github.com/piecepackr/ppdf) +* [{ppn}](https://github.com/piecepackr/ppn) ### Blog/forum posts diff --git a/tests/testthat/_snaps/cat_piece.md b/tests/testthat/_snaps/cat_piece.md index 07683e0..d0e43d7 100644 --- a/tests/testthat/_snaps/cat_piece.md +++ b/tests/testthat/_snaps/cat_piece.md @@ -754,3 +754,15 @@ └─┸─┸─┸─┸─┸─┸─┸─┘ +--- + + Code + df <- tibble(piece_side = "die_face", x = 1:6, y = 1, rank = 1:6, suit = 1:6, + cfg = "dice_numeral") + cat_piece(df) + Output + + 1⃞ 2⃞ 3⃞ 4⃞ 5⃞ 6⃞ + + + diff --git a/tests/testthat/test_cat_piece.r b/tests/testthat/test_cat_piece.r index b9a678d..5ed9413 100644 --- a/tests/testthat/test_cat_piece.r +++ b/tests/testthat/test_cat_piece.r @@ -238,4 +238,10 @@ test_that("text diagrams", { df <- rbind(dfx, dff, dfb) cat_piece(df) }) + + # numeral dice + expect_snapshot({ + df <- tibble(piece_side = "die_face", x=1:6, y=1, rank=1:6, suit=1:6, cfg="dice_numeral") + cat_piece(df) + }) })