- Create screen: choose キャッシュオンリー (real cards, chips only), 友人戦 (server deals and settles) or CPU戦 (友人戦 plus 1–8 CPU players); replaces the card toggle. The lobby shows each table's type - Poker AI written from scratch (server/ai.js, no libraries): fast 7-card evaluator (checked against bestHand), Monte Carlo equity, and decisions from hand rank, pot odds, raise count, opponents and a per-CPU style (aggression, bluff rate); continuation bets via the last aggressor. It never sees other players' hole cards - CPU seats: think time of 0.7–1.8s (faster when no human is left in the hand), automatic rebuy, never the host, no new hand unless a human is playing, re-think after pause - Play UI: robot avatars and a "考えています…" status for CPU turns - Tests for the evaluator, equity, legality of AI actions and CPU tables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
81 lines
3.0 KiB
JavaScript
81 lines
3.0 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
const { Store, esc, chips } = App;
|
|
const nameInput = document.getElementById('name');
|
|
const nameError = document.getElementById('name-error');
|
|
const listEl = document.getElementById('list');
|
|
const countEl = document.getElementById('count');
|
|
|
|
nameInput.value = Store.name;
|
|
nameInput.addEventListener('input', () => {
|
|
Store.name = nameInput.value.trim();
|
|
nameInput.classList.remove('invalid');
|
|
nameError.textContent = '';
|
|
});
|
|
|
|
function requireName() {
|
|
if (Store.name) return true;
|
|
nameInput.classList.add('invalid');
|
|
nameError.textContent = '先に名前を入力してください。';
|
|
nameInput.focus();
|
|
return false;
|
|
}
|
|
|
|
// 管理者だけにハンドレンジ学習へのリンクを出す(ページ自体もサーバ側で管理者以外は 404)
|
|
App.api('GET', '/api/me')
|
|
.then((me) => { document.getElementById('range-link').hidden = !me.admin; })
|
|
.catch(() => {});
|
|
|
|
document.getElementById('create').addEventListener('click', () => {
|
|
if (requireName()) location.href = '/create';
|
|
});
|
|
|
|
listEl.addEventListener('click', (e) => {
|
|
const btn = e.target.closest('[data-join]');
|
|
if (btn && requireName()) location.href = '/table/' + encodeURIComponent(btn.dataset.join);
|
|
});
|
|
|
|
const MODE_LABEL = { chips: '💰 キャッシュオンリー', friends: '🃏 友人戦', cpu: '🤖 CPU戦' };
|
|
|
|
function phaseBadge(t) {
|
|
if (t.paused) return '<span class="badge paused">PAUSED</span>';
|
|
if (t.phase === 'WAITING') return '<span class="badge">WAITING</span>';
|
|
return '<span class="badge live">PLAYING</span>';
|
|
}
|
|
|
|
function render(tables) {
|
|
countEl.textContent = tables.length ? `${tables.length} テーブル` : '';
|
|
if (!tables.length) {
|
|
listEl.innerHTML = '<div class="empty">開催中のテーブルはありません。<br>テーブルを作成して友達を招待しよう。</div>';
|
|
return;
|
|
}
|
|
listEl.innerHTML = tables
|
|
.map((t) => {
|
|
const full = t.playerCount >= t.maxSeats;
|
|
const timer = t.timerEnabled ? `⏱ ${t.intervalMin}分` : '⏱ なし';
|
|
return `
|
|
<div class="table-item">
|
|
<div class="info">
|
|
<div class="name">${esc(t.name)}${phaseBadge(t)}</div>
|
|
<div class="meta">
|
|
<span>👤 <b>${t.playerCount}/${t.maxSeats}</b></span>
|
|
<span>開始 <b>${chips(t.startingStack)}</b></span>
|
|
<span class="gold">Lv.${t.level} <b class="gold">${chips(t.smallBlind)}/${chips(t.bigBlind)}</b></span>
|
|
<span>${timer}</span>
|
|
<span>${MODE_LABEL[t.mode] || ''}</span>
|
|
</div>
|
|
</div>
|
|
<button class="btn btn-blue btn-sm" data-join="${esc(t.id)}" ${full ? 'title="満席(観戦のみ)"' : ''}>
|
|
${full ? '観戦' : '参加'}
|
|
</button>
|
|
</div>`;
|
|
})
|
|
.join('');
|
|
}
|
|
|
|
const socket = App.connectSocket();
|
|
socket.on('connect', () => socket.emit('lobby:subscribe'));
|
|
socket.on('lobby:tables', render);
|
|
})();
|