Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ppcli
Type: Package
Title: Plaintext Board Game Visualizations
Version: 0.3.0-1
Version: 0.3.0-2
Authors@R: c(person("Trevor L.", "Davis", role=c("aut", "cre"),
email="trevor.l.davis@gmail.com",
comment = c(ORCID = "0000-0001-6341-4639")))
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ppcli 0.3.0 (development)
=========================

* `cat_piece()` and `str_piece()` add support for "cubes" bit pieces (#4).
* `cat_piece()` and `str_piece()` adds support for the following game pieces (#4):

+ "cubes" bit pieces
+ (piecepack) saucers

ppcli 0.2.1
===========
Expand Down
34 changes: 31 additions & 3 deletions R/str_piece.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ get_style_combining <- function(style) {
dice_numeral = die_suits
)

list(coin = coin, die = die, pawn = pawn)
saucer <- if (style == "unicode") NULL else "\U000FCE51"
list(coin = coin, die = die, pawn = pawn, saucer = saucer)
}

get_style_rs <- function(style, big = FALSE) {
Expand Down Expand Up @@ -572,7 +573,10 @@ add_piece <- function(
reorient = "none",
style = get_style()
) {
if (piece_side %in% c("tile_back", "coin_face", "card_back", "board_face", "board_back")) {
if (
piece_side %in%
c("tile_back", "coin_face", "card_back", "board_face", "board_back", "saucer_back")
) {
fg <- "black"
} else {
if (grepl("pyramid", piece_side)) {
Expand Down Expand Up @@ -600,7 +604,9 @@ add_piece <- function(
"pawn_face",
"pawn_back",
"board_face",
"board_back"
"board_back",
"saucer_face",
"saucer_back"
))
) {
if (piece_side == "tile_face") {
Expand Down Expand Up @@ -636,6 +642,8 @@ add_piece <- function(
piece_side,
coin_back = add_coin_back(cm, ss, x, y, angle, fg, style),
coin_face = add_coin_face(cm, rs, x, y, angle, fg, style),
saucer_back = add_saucer_back(cm, x, y, angle, fg, style),
saucer_face = add_saucer_face(cm, ss, x, y, angle, fg, style),
die_face = add_die_face(cm, rs, x, y, angle, fg, cfg, style, suit),
pawn_face = add_pawn_face(cm, ss, x, y, angle, fg, style),
pawn_back = add_pawn_back(cm, ss, x, y, angle, fg, style),
Expand Down Expand Up @@ -784,6 +792,26 @@ add_coin_face <- function(cm, rs, x, y, angle, fg, style) {
cm$fg[y, x] <- fg
cm
}
add_saucer_back <- function(cm, x, y, angle, fg, style) {
if (is.null(style$combining$saucer)) {
cm$char[y, x] <- "\u25ce"
} else {
enclosing_saucer <- style$rotate(style$combining$saucer, angle)
cm$char[y, x] <- paste0(style$space, enclosing_saucer)
}
cm$fg[y, x] <- fg
cm
}
add_saucer_face <- function(cm, ss, x, y, angle, fg, style) {
if (is.null(style$combining$saucer)) {
cm$char[y, x] <- "\u25c9"
} else {
enclosing_saucer <- style$rotate(style$combining$saucer, angle)
cm$char[y, x] <- paste0(ss, enclosing_saucer)
}
cm$fg[y, x] <- fg
cm
}
add_die_face <- function(cm, rs, x, y, angle, fg, cfg, style, suit) {
enclosing_die <- style$rotate(style$combining$die[[cfg]][suit], angle)
# nolint start
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
7 changes: 6 additions & 1 deletion data-raw/sysdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ r225[["\u25b3"]] <- "\u25ff"
r270[["\u25b3"]] <- "\u25b7"
r315[["\u25b3"]] <- "\u25f9"
# Various Symmetric Circles
for (circle in c("\u25cb", "\u25cc", "\u25ce", "\u25cf", "\u20dd")) {
for (circle in c("\u25c9", "\u25cb", "\u25cc", "\u25ce", "\u25cf", "\u20dd")) {
r45[[circle]] <- circle
r90[[circle]] <- circle
r135[[circle]] <- circle
Expand All @@ -755,6 +755,11 @@ r90[["\U000FCE50"]] <- "\U000FCE5C" # Game Bit PUA
r180[["\U000FCE50"]] <- "\U000FCE58"
r270[["\U000FCE50"]] <- "\U000FCE54"

# Enclosing Pawn Saucer (with directional mark)
r90[["\U000FCE51"]] <- "\U000FCE5D" # Game Bit PUA
r180[["\U000FCE51"]] <- "\U000FCE59"
r270[["\U000FCE51"]] <- "\U000FCE55"

# Enclosing Pawn
r45[["\u20df"]] <- "\u20de"
r90[["\u20df"]] <- "\u20df"
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/_snaps/cat_piece.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@
└─┴┸┴─┴┸┘


---

Code
dfs <- tibble(piece_side = rep(c("saucer_face", "saucer_back"), 2), x = 1:4, y = 1,
suit = 1:4)
cat_piece(dfs)
Output

◉ ◎ ◉ ◎



---

Code
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/_snaps/game_bit_mono.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
│󼨀│ │󼨄│
└─┘ └─┘

# saucers

Code
cat_piece(dfs)
Output

󼹑 󼹝 󼹙 󼹕

󼰀󼹑 󼰍󼹝 󼰊󼹙 󼰇󼹕



# Can't rotate boards

Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ test_that("text diagrams", {
skip_if_not_installed("withr")
library("tibble")

expect_warning(capture.output(cat_piece(tibble(piece_side = "token_face", x = 2, y = 2))))

style <- get_style("unicode")
expect_warning(style$rotate("$", 90))
expect_warning(style$rotate("&", 180))
Expand All @@ -15,7 +17,6 @@ test_that("text diagrams", {
f <- tempfile()
expect_equal(cat_piece(tibble(), file = f), character())
unlink(f)
expect_warning(capture.output(cat_piece(tibble(piece_side = "saucer_face", x = 2, y = 2))))
expect_error(cat_piece(tibble(
piece_side = "pyramid_top",
x = 2,
Expand Down Expand Up @@ -161,6 +162,17 @@ test_that("text diagrams", {
cat_piece(df)
})

# saucers
expect_snapshot({
dfs <- tibble(
piece_side = rep(c("saucer_face", "saucer_back"), 2),
x = 1:4,
y = 1,
suit = 1:4
)
cat_piece(dfs)
})

# misc
expect_snapshot({
dft <- tibble(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ test_that("Dominoes", {
expect_snapshot(cat_piece(df))
})

test_that("saucers", {
skip_if_not_installed("tibble")
library("tibble")
dfs <- tibble(
piece_side = rep(c("saucer_face", "saucer_back"), each = 4),
x = rep(1:4, 2),
y = rep(1:2, each = 4),
angle = rep(c(0, 90, 180, 270), 2),
suit = rep(1:4, 2)
)
expect_snapshot(cat_piece(dfs))
})

# https://github.com/piecepackr/ppcli/issues/3
test_that("Can't rotate boards", {
skip_if_not_installed("ppdf", "0.2.0-13")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading