Implement Texas Hold'em play: dealing, betting, side pots, showdown
- Hand engine (server/hand.js): crypto-shuffled deck kept server-side, blinds (heads-up button = SB), min-raise rules incl. incomplete all-in, uncalled bet refunds, side pots, split pots, all-in runout - Hand evaluator (server/cards.js) and node:test suite (npm test) - Table flow: hands auto-continue after host START, 30s action clock (timeout = check/fold + sit out), sit out / sit in, rebuy, mid-hand leave folds and keeps the seat reserved until the hand ends, pause freezes all clocks - Only each player's own hole cards are sent until a showdown/runout reveal; all actions validated server-side - Play UI: board, hole cards, bets, action tags, turn timer, raise panel with presets, showdown results with winning cards highlighted, compact 7+ layout - Remove the host crown and the temporary "next phase" control Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b2c91062f1
commit
8de55f7ca5
12 files changed
+1648
-167
No files matched your search
@@ -2,7 +2,19 @@
|
||||
|
||||
友達専用のテキサスホールデム(リングゲーム)サイト。Node.js + Express + Socket.IO。
|
||||
|
||||
現状は「鍵入力 → ロビー → テーブル作成 → プレイ画面(スタブ)」まで。カード配布・ベッティングなどのゲーム処理は未実装で、プレイ画面ではホストが「次へ(仮)」でフェーズを手動で進められる。
|
||||
「鍵入力 → ロビー → テーブル作成 → プレイ」まで動く。
|
||||
|
||||
## ルール・仕様
|
||||
|
||||
- ノーリミット・テキサスホールデムのリングゲーム(最大9人)。ホストが START を押すと、以降は2人以上いる限り自動でハンドが続く。
|
||||
- ブラインドはハンド開始時のレベルで固定。ヘッズアップはボタンが SB。
|
||||
- 最低レイズ額は直前のレイズ幅以上。足りないオールインのレイズは、すでにアクションした人に再レイズ権を与えない。
|
||||
- サイドポット・山分け(端数はボタンの左から)・誰もコールしなかった分の返金に対応。
|
||||
- 全員オールインになったら手札を公開して残りのカードを順にめくる。ショーダウンでは残った全員の手札を公開。
|
||||
- 持ち時間は1手30秒(`server/config.js` の `ACTION_TIME_MS`)。過ぎるとチェック(できなければフォールド)して「離席中」になり、「復帰する」を押すまで配られない。
|
||||
- チップがなくなったら開始スタックでリバイできる。画面下に収支(現在のチップ − バイイン合計)を表示。
|
||||
- ハンド中に退席するとフォールド扱い(出したチップはポットに残る)。
|
||||
- ホストの一時停止中は、持ち時間・ブラインドタイマー・次のハンドの開始がすべて止まる。
|
||||
|
||||
## ローカルで動かす
|
||||
|
||||
@@ -35,6 +47,7 @@ http://localhost:4671 を開く。
|
||||
- **XSS**: 厳格な CSP(インラインスクリプト・インラインスタイル禁止)、表示時のエスケープ、名前から制御文字・不可視文字を除去。
|
||||
- **その他**: クリックジャッキング防止(`frame-ancestors 'none'`)、`nosniff`、`no-referrer`、HTML/API は `no-store`、検索エンジン除外、エラー時に内部情報を返さない、リクエストサイズ・イベント連打・テーブル数の上限。
|
||||
- 他人の席を操作できないよう、席の持ち主を示すプレイヤーIDはブラウザ内だけに保存し、他のプレイヤーには送らない。
|
||||
- **カード**: 山札は暗号論的乱数(`crypto.randomInt`)でシャッフルしてサーバ内だけに保持。各プレイヤーには自分の手札だけを送り、他人の手札は公開時(オールイン・ショーダウン)まで送らない。アクションはサーバ側で手番・額をすべて検証する。
|
||||
|
||||
6桁のキーはそれ自体が強い秘密ではないので、上記の回数制限が守りの要になっている。キーは友達にだけ直接伝えること。
|
||||
|
||||
@@ -44,14 +57,17 @@ http://localhost:4671 を開く。
|
||||
| --- | --- |
|
||||
| `server/index.js` | HTTP ルーティング・セキュリティヘッダ・REST API・Socket.IO |
|
||||
| `server/auth.js` | 参加キー認証(Cookie)・回数制限・Origin チェック |
|
||||
| `server/tables.js` | テーブル状態(席・ボタン・ブラインド・フェーズ・タイマー) |
|
||||
| `server/tables.js` | テーブル状態(席・ボタン・ブラインド・タイマー・ハンドの開始/進行) |
|
||||
| `server/hand.js` | 1ハンドの進行(配札・ベッティング・サイドポット・ショーダウン) |
|
||||
| `server/cards.js` | 山札と役判定 |
|
||||
| `test/` | ゲーム処理のテスト(`npm test`) |
|
||||
| `server/config.js` | `.env` の読み込みと各種上限値 |
|
||||
| `public/assets/blinds.js` | ブラインド計算(サーバ・ブラウザ共用) |
|
||||
| `public/*.html`, `public/assets/*.js` | 各画面 |
|
||||
|
||||
- テーブルはメモリ上にのみ保持(サーバ再起動で消える)。誰も接続していない状態が30分続くと自動削除。
|
||||
- 名前とプレイヤーID はブラウザの localStorage に保存。リロードしても同じ席に戻れる。
|
||||
- 作成者がホスト(👑)。ホストが退席すると次の着席者に移る。
|
||||
- 作成者がホスト(START・一時停止ができる)。ホストが退席すると次の着席者に移る。
|
||||
|
||||
## VPS へのデプロイ例(Ubuntu + nginx + systemd + HTTPS)
|
||||
|
||||
@@ -138,3 +154,14 @@ sudo systemctl daemon-reload && sudo systemctl enable --now holdem
|
||||
# ファイアウォール: 4671 は開けない(nginx だけが 127.0.0.1 経由で使う)
|
||||
sudo ufw allow OpenSSH && sudo ufw allow 'Nginx Full' && sudo ufw enable
|
||||
```
|
||||
|
||||
## 更新(デプロイ済みのサーバに反映)
|
||||
|
||||
テーブルはメモリ上にしかないので、再起動すると進行中のテーブルは消える。誰も遊んでいないときに行う。
|
||||
|
||||
```bash
|
||||
cd /opt/holdem
|
||||
sudo git pull
|
||||
sudo npm ci --omit=dev
|
||||
sudo systemctl restart holdem
|
||||
```
|
||||
Reference in new issue
Block a user