diff options
Diffstat (limited to '')
| -rw-r--r-- | docs/GAMES.md | 74 | ||||
| -rw-r--r-- | docs/SERVER_SETUP.md | 16 | ||||
| -rw-r--r-- | docs/TESTING.md | 13 |
3 files changed, 103 insertions, 0 deletions
diff --git a/docs/GAMES.md b/docs/GAMES.md new file mode 100644 index 0000000..cbe355e --- /dev/null +++ b/docs/GAMES.md | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | # Games and the play audit | ||
| 2 | |||
| 3 | ## Implemented | ||
| 4 | |||
| 5 | | Game | Status | Notes | | ||
| 6 | | --- | --- | --- | | ||
| 7 | | Slots | Done | 5 reels x 3 rows, 5 paylines, 98.6% RTP | | ||
| 8 | |||
| 9 | ## Planned | ||
| 10 | |||
| 11 | | Game | Shape | Main open decisions | | ||
| 12 | | --- | --- | --- | | ||
| 13 | | Roulette | One spin, many bets | European/French/American wheel; which bet types; 35:1 straight and other payouts | | ||
| 14 | | Blackjack | Multi-step hand | Dealer hits/stands soft 17; double/split/insurance; blackjack payout; shoe persistence | | ||
| 15 | | Crash | Real-time round | Crash-point distribution; cashout latency; provable fairness | | ||
| 16 | |||
| 17 | Roulette fits the current one-request-settle model most easily. Blackjack needs | ||
| 18 | server-side hand state and player actions. Crash needs a timed round loop and a | ||
| 19 | cashout action, so it should come last unless we redesign the loop first. | ||
| 20 | |||
| 21 | ## Audit schema | ||
| 22 | |||
| 23 | Every settled play is one row in `plays`: | ||
| 24 | |||
| 25 | ``` | ||
| 26 | plays ( | ||
| 27 | session_id TEXT PRIMARY KEY, | ||
| 28 | username TEXT NOT NULL, | ||
| 29 | game_type TEXT NOT NULL, | ||
| 30 | bet_amount INTEGER NOT NULL, | ||
| 31 | winnings INTEGER NOT NULL, | ||
| 32 | balance_after INTEGER NOT NULL, | ||
| 33 | details TEXT NOT NULL DEFAULT '{}', | ||
| 34 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP | ||
| 35 | ) | ||
| 36 | ``` | ||
| 37 | |||
| 38 | `game_type` is the game that was played. `details` is a JSON object whose shape | ||
| 39 | depends on the game: | ||
| 40 | |||
| 41 | ```json | ||
| 42 | // slots | ||
| 43 | {"reels":"CCCCLLCLODGSDGS","win_type":"win","win_lines":"1","win_cells":"0,3,6"} | ||
| 44 | |||
| 45 | // rumoured future examples | ||
| 46 | {"player":["AS","10H"],"dealer":["9D","7C"],"outcome":"blackjack"} | ||
| 47 | {"bets":[{"kind":"straight","number":17,"amount":10}],"winning":17} | ||
| 48 | {"crash_point":2.41,"cashout":1.80} | ||
| 49 | ``` | ||
| 50 | |||
| 51 | The balance updates and the `plays` insert happen in one transaction | ||
| 52 | (`database::apply_play`). The slots-specific wire fields (`reels`, `win_lines`, | ||
| 53 | `win_cells`) are still in `GAME_RESULT`, but the database no longer assumes | ||
| 54 | them. | ||
| 55 | |||
| 56 | ## Protocol gap | ||
| 57 | |||
| 58 | The current exchange is slots-shaped: | ||
| 59 | |||
| 60 | ``` | ||
| 61 | PLAY_START <game> <bet> | ||
| 62 | GAME_RESULT <session> <winnings> <bet> <balance> <reels> <win_type> <win_lines> <win_cells> | ||
| 63 | ``` | ||
| 64 | |||
| 65 | Before blackjack, roulette, or crash can be added, the game session needs a | ||
| 66 | generic state/action protocol. A possible shape: | ||
| 67 | |||
| 68 | ``` | ||
| 69 | GAME_START <game> <bet> | ||
| 70 | GAME_ACTION <action> [json] | ||
| 71 | GAME_STATE <json> # cards, bets, multiplier, legal actions, result | ||
| 72 | ``` | ||
| 73 | |||
| 74 | That is a wire-protocol change and will be its own major version. | ||
diff --git a/docs/SERVER_SETUP.md b/docs/SERVER_SETUP.md index e2f3177..62d1a9c 100644 --- a/docs/SERVER_SETUP.md +++ b/docs/SERVER_SETUP.md | |||
| @@ -69,6 +69,22 @@ On first contact the client prints the SPKI fingerprint and pins it. If you | |||
| 69 | regenerate the server identity, the client will reject the new key; run | 69 | regenerate the server identity, the client will reject the new key; run |
| 70 | `forget-host` in the client if the change is intentional. | 70 | `forget-host` in the client if the change is intentional. |
| 71 | 71 | ||
| 72 | ## Database | ||
| 73 | |||
| 74 | The server creates `server.db` in the current directory on first use. It holds | ||
| 75 | users, balances, and the per-game `plays` audit. The client keeps its own | ||
| 76 | `client.db` for host fingerprints and stored credentials. | ||
| 77 | |||
| 78 | During development, delete both files to reset users, balances, history, and | ||
| 79 | trust: | ||
| 80 | |||
| 81 | ```sh | ||
| 82 | rm -f server.db client.db | ||
| 83 | ``` | ||
| 84 | |||
| 85 | The `plays` schema is not auto-migrated from the old slots-only shape; a stale | ||
| 86 | database must be removed. | ||
| 87 | |||
| 72 | ## Windows | 88 | ## Windows |
| 73 | 89 | ||
| 74 | `--init` shells out to `openssl`, so OpenSSL must be installed and on `PATH` | 90 | `--init` shells out to `openssl`, so OpenSSL must be installed and on `PATH` |
diff --git a/docs/TESTING.md b/docs/TESTING.md index 2a3572d..4d46855 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md | |||
| @@ -23,6 +23,19 @@ shared global database. Each test owns its state. | |||
| 23 | `tests/tofu.rs` and `tests/server_setup.rs` shell out to `openssl`, so run them | 23 | `tests/tofu.rs` and `tests/server_setup.rs` shell out to `openssl`, so run them |
| 24 | on a machine where the `openssl` CLI is available. | 24 | on a machine where the `openssl` CLI is available. |
| 25 | 25 | ||
| 26 | ## Development resets | ||
| 27 | |||
| 28 | The server creates `server.db` in its working directory; the client creates | ||
| 29 | `client.db` for host trust and stored credentials. While the software is in | ||
| 30 | testing, delete both after a schema or trust change: | ||
| 31 | |||
| 32 | ```sh | ||
| 33 | rm -f server.db client.db | ||
| 34 | ``` | ||
| 35 | |||
| 36 | The audit schema is not auto-migrated from the pre-2.0 slots-only `plays` | ||
| 37 | table. Starting against an old database will fail until it is removed. | ||
| 38 | |||
| 26 | ## Manual TUI checklist | 39 | ## Manual TUI checklist |
| 27 | 40 | ||
| 28 | There is no CI. Run this on Linux and on a Windows VM before a release. | 41 | There is no CI. Run this on Linux and on a Windows VM before a release. |
