Skip to content
Open
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
1 change: 1 addition & 0 deletions domains/games/libs/cards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This module provides a set of classes and utilities for building card games.

- Top level module contains core components for building card games.
- [golf](./golf) is a mostly complete implementation of the game Golf.
- [castle](./castle) is the rules engine for Castle (Palace).

## Building

Expand Down
53 changes: 53 additions & 0 deletions domains/games/libs/cards/castle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")

# The castle rules engine: immutable GameState/Player value types for
# the games hub.

cc_library(
name = "player",
srcs = ["player.cc"],
hdrs = ["player.h"],
visibility = ["//visibility:public"],
deps = [
"//domains/games/libs/cards",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
)

cc_library(
name = "game_state",
srcs = ["game_state.cc"],
hdrs = ["game_state.h"],
visibility = ["//visibility:public"],
deps = [
":player",
"//domains/games/libs/cards",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
)

cc_test(
name = "player_test",
size = "small",
srcs = ["player_test.cc"],
deps = [
":player",
"//domains/games/libs/cards",
"@googletest//:gtest_main",
],
)

cc_test(
name = "game_state_test",
size = "small",
srcs = ["game_state_test.cc"],
deps = [
":game_state",
":player",
"//domains/games/libs/cards",
"//domains/games/libs/cards:dealer",
"@googletest//:gtest_main",
],
)
17 changes: 17 additions & 0 deletions domains/games/libs/cards/castle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# castle

The rules engine for Castle (the shedding game also played as Palace):
immutable `Player` and `GameState` value types in the style of
[`../golf`](../golf), for the games hub.

The rules the engine plays are the contract, stated on `GameState` in
`game_state.h` and pinned one by one in `game_state_test.cc`: three
face-down, three face-up, three in hand; a setup phase of hand/face-up
swaps; lowest ordinary card opens; equal-or-higher plays, twos reset,
tens and four of a kind burn; must play if able, otherwise pick up the
pile; face-up then face-down rows once the hand is gone; first out wins,
last holder loses.

```bash
bazel test //domains/games/libs/cards/castle/...
```
Loading
Loading