- hand/zeiger.py: ein Zeiger, der lebt (Drift, Spielen, ungleiche Kreise, Zittern nur in Phasen), deutet (zeig_auf/wackle/zeig_weg über den Briefkasten), beim Klick ruht und bei menschlichem Eingriff Ruhe gibt; Lauf im eigenen Faden, blockiert das Spiel nie - hand/klonmaus.py: Bildschirm - ein Zeiger über allen Tischfenstern, Weg quer durch die Fenster, nur das Fenster darunter zeichnet ihn; geschlossene Fenster werfen nicht mehr - hand/maus.py: ab und zu ein nervöser zweiter Klick (4 %, nur im Klon) - betrieb/strom.py, buehne.py, regie.py: Ereignisstrom, Bühnenserver, Regie deutet Karten/Board/Knopf vor dem Klick; MCP zeig_auf/zeig_weg - betrieb/runner.py: Beenden in zwei Phasen (Sitout, laufende Hand zu Ende, dann aufstehen, Frist 120 s); im Klon Setzen Tisch für Tisch statt überall Buy-in-Dialoge zu öffnen - lesen/spot_from_log.py: kein KeyError beim Knopf, solange der eigene Platz unbekannt ist - lesen/turnier.py, mock/turnier.py: Turnier-Wache und Klon-Turnier mit Prüfstücken Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
486 lines
27 KiB
HTML
486 lines
27 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>{{TITEL}}</title>
|
||
<!-- Nachbildung des gemalten Unity-Tisches. Alle Stellen sind Anteile des FENSTERRAHMENS
|
||
(mock/vorlage/README.md), nicht der Seite - so rechnet auch hand/click.py.
|
||
|
||
Am echten Tisch gemessen (mock/vorlage/tisch-geometrie.md, Fenster 820x628):
|
||
+ freier Platz 1: 0.140/0.240 3: 0.868/0.239 4: 0.868/0.622 5: 0.495/0.787
|
||
2 (Mitte oben) und 6 (links unten): NICHT gemessen, Schätzung (PLUS unten)
|
||
voller Tisch Join Wait List 0.720/0.951 Find Seat 0.902/0.951
|
||
Buy-in-Dialog Min 0.377/0.611 Mitte 0.500/0.611 Max 0.624/0.611 Buy-In 0.500/0.847
|
||
Schliessen 0.674/0.151 "Claim Chips" 0.613/0.261 (nur bei offenen Chips)
|
||
Der rote Knopf heisst "Buy-In" (freier Platz, Nachkauf) oder "Join Wait List"
|
||
(Find Seat am vollen Tisch). Betrag beim Öffnen: freier Platz Max, Wartelisten-
|
||
Dialog Min, Nachkauf Min - gekauft wird, was im Feld steht.
|
||
Fensterkreuz des Spiels 0.972/0.024 (schliesst das Tischfenster). Im Chrome des Klons liegt
|
||
die Titelleiste des Betriebssystems über der Seite: bei 0.024 (rund 15 px) trifft
|
||
ein Mausklick sie, nicht die Seite. Das Kreuz sitzt deshalb bei x 0.972 und so
|
||
hoch, wie die Seite reicht (14 px unter ihrem Rand, data-min-top) - ohne
|
||
Titelleiste ist es genau 0.024. Abweichung nur in y, nur im Klon.
|
||
Sit Out / I'm Back (SITOUT 0.060/0.951): geschätzt, am echten Tisch nicht gemessen - dieselbe
|
||
Stelle in beiden Zuständen, nur wenn wir sitzen (hand/sitzen.py hat denselben Wert).
|
||
Wer am eigenen Platz das Fensterkreuz drückt, steht auf: game.leave_Seat, Stack zurück ins Guthaben.
|
||
Nachkauf: kein eigener Knopf. Auf dem eigenen Platz sitzt ein kleines "+" an der Stelle des
|
||
freien-Platz-+ (PLUS), solange der Stack unter dem Max-Buy-in liegt; Klick öffnet den Dialog.
|
||
Find Seat am vollen Tisch bleibt am Tisch und öffnet den Wartelisten-Dialog. -->
|
||
<style>
|
||
html, body { margin: 0; height: 100%; overflow: hidden; }
|
||
body { background: #11131b; color: #eee; font: 15px/1.2 Roboto, Arial, sans-serif; position: relative; }
|
||
.filz { position: absolute; left: 7%; right: 7%; top: 21%; bottom: 20%; border-radius: 50%;
|
||
background: radial-gradient(#1d7a55, #0f4d37); border: 14px solid #232634; }
|
||
.stelle { position: absolute; transform: translate(-50%, -50%); }
|
||
.platz { text-align: center; }
|
||
.platz .name { background: #1b1e29; border-radius: 8px; padding: 6px 14px; min-width: 110px; }
|
||
.platz .chips { color: #f5c542; font-weight: 700; }
|
||
.platz.held .name { outline: 2px solid #4fc3f7; }
|
||
.platz.dran .name { outline: 2px solid #f5c542; }
|
||
.platz .aktion { color: #9ab; font-size: 12px; min-height: 14px; }
|
||
.platz.gefoldet { opacity: .45; }
|
||
.einsatz { background: #0d0f15; color: #f5c542; border-radius: 10px; padding: 2px 10px; font-size: 13px; }
|
||
.uhr { background: #f5c542; color: #111; font-weight: 700; border-radius: 10px; padding: 2px 8px; font-size: 13px; }
|
||
.uhr.knapp { background: #d4202c; color: #fff; }
|
||
.uhr[hidden] { display: none; }
|
||
.handnr { position: absolute; left: 12px; top: 10px; color: #778; font-size: 12px; }
|
||
.platz-frei { width: 80px; height: 80px; border-radius: 50%; border: 3px solid #2a2d3a;
|
||
background: #1a1c25; color: #ccc; font-size: 44px; line-height: 1; cursor: pointer; padding: 0; }
|
||
.mitte { text-align: center; }
|
||
.pot { background: #1b1e29; color: #fff; border-radius: 12px; padding: 4px 14px; display: inline-block; }
|
||
.pot[hidden] { display: none; }
|
||
.pot b { color: #4fc3f7; }
|
||
.karten { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
|
||
.karte { background: #fff; color: #111; border-radius: 6px; width: 42px; height: 58px; font-size: 20px;
|
||
font-weight: 700; display: flex; align-items: center; justify-content: center; }
|
||
.karte.rot { color: #d4202c; }
|
||
.aktionsleiste button { position: absolute; transform: translate(-50%, -50%); border: 0; border-radius: 8px;
|
||
background: #262a36; color: #fff; font: 600 16px Roboto, Arial, sans-serif; cursor: pointer;
|
||
white-space: nowrap; }
|
||
.aktionsleiste .gross { width: 12.5vw; height: 7vh; min-width: 90px; }
|
||
.aktionsleiste .klein { width: 5.2vw; height: 4.6vh; min-width: 40px; font-size: 13px; background: #1e2130; }
|
||
.aktionsleiste .fold { background: #8c2b2b; }
|
||
.aktionsleiste .call { background: #2b6b3f; }
|
||
.aktionsleiste .raise { background: #a5791d; }
|
||
.aktionsleiste .an { outline: 2px solid #4caf50; }
|
||
.betrag { position: absolute; transform: translate(-50%, -50%); width: 9vw; height: 4.4vh; text-align: center;
|
||
background: #0d0f15; color: #fff; border: 1px solid #333; border-radius: 6px; }
|
||
.dialog-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: none; }
|
||
/* Der Dialog ist eine durchsichtige Fläche über dem ganzen Fenster; jedes Element mit data-fx
|
||
sitzt an seiner gemessenen Stelle (anordnen()). Keine Klassen ausser denen der echten Seite. */
|
||
.sfs-buy-in-modal { position: absolute; inset: 0; display: none; }
|
||
.sfs-buy-in-modal [data-fx] { position: absolute; transform: translate(-50%, -50%); margin: 0; }
|
||
.sfs-buy-in-header, .sfs-buy-in-body, .sfs-buy-in-body-range-buttons,
|
||
.sfs-buy-in-modal-button-container { display: contents; } /* nur Gruppen, ohne eigene Fläche */
|
||
.sfs-buy-in-modal-container { width: 40vw; height: 82vh; background: #1b1e29; border-radius: 12px; }
|
||
.sfs-buy-in-heading { font-size: 20px; font-weight: 700; }
|
||
.sfs-buy-in-header-game-info { color: #99a; white-space: nowrap; }
|
||
.sfs-buy-in-balance-container { display: flex; gap: 8px; white-space: nowrap; }
|
||
.sfs-buy-in-user-balance { color: #f5c542; font-weight: 700; }
|
||
.sfs-slider-range-value { width: 30vw; box-sizing: border-box; padding: 8px; font-size: 18px; text-align: center;
|
||
background: #0d0f15; color: #fff; border: 1px solid #333; border-radius: 6px; }
|
||
.sfs-buy-in-body-min-range, .sfs-buy-in-body-mid-range, .sfs-buy-in-body-max-range,
|
||
.sfs-buy-in-modal-button, .sfs-buy-in-modal-header-button {
|
||
background: #2b3045; color: #fff; border: 0; border-radius: 6px; padding: 6px 16px; cursor: pointer;
|
||
font: inherit; white-space: nowrap; min-width: 9vw; }
|
||
.sfs-buy-in-modal-header-button { background: #a5791d; font-size: 13px; min-width: 0; }
|
||
.sfs-buy-in-modal-button { background: #d4202c; font-weight: 700; padding: 10px; min-width: 18vw; }
|
||
.sfs-buy-in-body-error { color: #ff6b6b; min-height: 1em; font-size: 12px; white-space: nowrap; }
|
||
.common-dialog-cross-icon { cursor: pointer; font-size: 22px; line-height: 1; padding: 4px 8px; }
|
||
.sfs-buy-in-body-container-text { color: #99a; font-size: 13px; white-space: nowrap; }
|
||
.nachkauf { border: 2px solid #2a2d3a; border-radius: 50%; width: 30px; height: 30px; padding: 0; z-index: 5;
|
||
background: #1f6fae; color: #fff; font: 700 20px/1 Roboto, Arial; cursor: pointer; }
|
||
.spielkreuz { background: #232634; color: #ccc; border-radius: 6px; width: 26px; height: 22px; line-height: 22px;
|
||
text-align: center; cursor: pointer; font-size: 18px; }
|
||
.sitoutknopf { background: #262a36; color: #fff; border: 0; border-radius: 8px; padding: 6px 14px;
|
||
font: 600 14px Roboto, Arial, sans-serif; cursor: pointer; white-space: nowrap; }
|
||
.turnierleiste { position: absolute; left: 12px; top: 28px; color: #9ab; font-size: 12px; }
|
||
.guthaben { position: absolute; right: 8%; top: 10px; color: #99a; font-size: 13px; }
|
||
.guthaben b { color: #f5c542; }
|
||
/* Bühnenmodus (start.py --buehne): sichtbarer Zeiger, folgt den Mausereignissen; fängt selbst keine */
|
||
#zeiger { position: fixed; left: 0; top: 0; width: 28px; height: 28px; z-index: 99999; pointer-events: none;
|
||
display: none; filter: drop-shadow(0 0 3px #000); }
|
||
#zeiger path { fill: #fff; stroke: #111; stroke-width: 1.5; }
|
||
#zeiger.mensch path { fill: #ff9d2e; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="filz"></div>
|
||
<div class="handnr" id="handnr"></div>
|
||
<div class="turnierleiste" id="turnier" hidden></div>
|
||
<div class="guthaben">Balance <b id="guthaben"></b></div>
|
||
<div id="plaetze"></div>
|
||
<div id="einsaetze"></div>
|
||
<div class="stelle uhr" id="uhr" hidden></div>
|
||
<div class="stelle mitte" data-fx="0.5" data-fy="0.5">
|
||
<div class="pot" hidden><b>Pot</b> <span id="pot"></span></div>
|
||
<div class="karten" id="board"></div>
|
||
</div>
|
||
<div class="stelle" id="eigene" data-fx="0.5" data-fy="0.73"><div class="karten"></div></div>
|
||
<div class="aktionsleiste" id="leiste"></div>
|
||
<button class="stelle sitoutknopf" id="sitout" hidden>Sit Out</button>
|
||
<div class="stelle spielkreuz" id="spielkreuz" role="button" data-fx="0.972" data-fy="0.024" data-min-top="14">×</div>
|
||
|
||
<div id="zeiger" hidden><svg viewBox="0 0 28 28" width="28" height="28"><path d="M2 2 L2 22 L7.5 17 L11 25 L14.5 23.5 L11 15.5 L18.5 15.5 Z"/></svg></div>
|
||
|
||
<div class="dialog-backdrop"></div>
|
||
<div class="sfs-buy-in-modal">
|
||
<div class="sfs-buy-in-modal-container" data-fx="0.5" data-fy="0.51"></div>
|
||
<div class="sfs-buy-in-header">
|
||
<h2 class="sfs-buy-in-heading" data-fx="0.5" data-fy="0.17">Buy-In</h2>
|
||
<div class="common-dialog-cross-icon" role="button" aria-label="close" data-fx="0.674" data-fy="0.151">×</div>
|
||
</div>
|
||
<div class="sfs-buy-in-header-game-info" data-fx="0.5" data-fy="0.215">{{TITEL}}</div>
|
||
<div class="sfs-buy-in-balance-container" data-fx="0.43" data-fy="0.261">
|
||
<div class="sfs-buy-in-balance-label">Balance</div>
|
||
<div class="sfs-buy-in-user-balance"></div>
|
||
</div>
|
||
<button class="sfs-buy-in-modal-header-button" data-fx="0.613" data-fy="0.261" hidden>Claim Chips</button>
|
||
<div class="sfs-buy-in-body">
|
||
<div class="sfs-buy-in-body-container-text" data-fx="0.5" data-fy="0.34" hidden></div>
|
||
<input class="sfs-slider-range-value" data-fx="0.5" data-fy="0.45" inputmode="numeric">
|
||
<div class="sfs-buy-in-body-range-buttons">
|
||
<button class="sfs-buy-in-body-min-range" data-fx="0.377" data-fy="0.611">Min</button>
|
||
<button class="sfs-buy-in-body-mid-range" data-fx="0.500" data-fy="0.611">Mid</button>
|
||
<button class="sfs-buy-in-body-max-range" data-fx="0.624" data-fy="0.611">Max</button>
|
||
</div>
|
||
<div class="sfs-buy-in-body-error" data-fx="0.5" data-fy="0.70"></div>
|
||
</div>
|
||
<div class="sfs-buy-in-modal-button-container">
|
||
<button class="sfs-buy-in-modal-button" data-fx="0.500" data-fy="0.847">Buy-In</button>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
const RAUM = "{{RAUM}}";
|
||
// Stelle des + je freiem Platz (Anteil des Fensterrahmens). Platz 1, 3, 4, 5: am echten Tisch gemessen.
|
||
// Platz 2 (Mitte oben) und 6 (links unten): GESCHÄTZT - am echten Tisch noch nicht vermessen.
|
||
const PLUS = {1: [0.140, 0.240], 2: [0.50, 0.20], 3: [0.868, 0.239],
|
||
4: [0.868, 0.622], 5: [0.495, 0.787], 6: [0.12, 0.64]};
|
||
// Sitzschilder (Name, Chips, Einsatz, Uhr): nicht neu vermessen, die Schätzungen von früher.
|
||
const SCHILD = {1: [0.14, 0.24], 2: [0.50, 0.20], 3: [0.86, 0.27],
|
||
4: [0.88, 0.66], 5: [0.50, 0.84], 6: [0.12, 0.64]};
|
||
// Sit Out / I'm Back (Anteil des Fensterrahmens): geschätzt, am echten Tisch nicht gemessen
|
||
const SITOUT = [0.060, 0.951];
|
||
const START = new URLSearchParams(location.search);
|
||
const BUEHNE = "{{BUEHNE}}" === "1";
|
||
window.name = "tisch-" + RAUM.split(" ").pop(); // das Fenster heisst nach seinem Tisch
|
||
// Die drei Zustände der Aktionsleiste (README; "vorab" wie in bild-tisch-im-spiel.png)
|
||
const LEISTE = {
|
||
zug: z => [["Fold", 0.66, 0.94, "gross fold", "fold"],
|
||
[z.call ? "Call " + z.call : "Check", 0.80, 0.94, "gross call", "call"],
|
||
["Raise" + (z.raise ? " " + z.raise : ""), 0.93, 0.94, "gross raise", "raise"],
|
||
["33%", 0.616, 0.86, "klein", "v33"], ["50%", 0.677, 0.86, "klein", "v50"],
|
||
["75%", 0.735, 0.86, "klein", "v75"], ["Max", 0.784, 0.86, "klein", "vmax"]],
|
||
vorab: () => [["✓ Call Any", 0.79, 0.876, "gross", "callany"],
|
||
["✓ X/F", 0.66, 0.95, "gross", "xf"],
|
||
["✓ Call", 0.80, 0.95, "gross", "vcall"]],
|
||
voll: () => [["Find Seat", 0.902, 0.951, "gross", "findseat"],
|
||
["Join Wait List", 0.720, 0.951, "gross", "waitlist"]],
|
||
keine: () => [],
|
||
};
|
||
const FARBE = {HEARTS: "♥", DIAMONDS: "♦", CLUBS: "♣", SPADES: "♠"};
|
||
const WERT = {TWO: "2", THREE: "3", FOUR: "4", FIVE: "5", SIX: "6", SEVEN: "7", EIGHT: "8",
|
||
NINE: "9", TEN: "10", JACK: "J", QUEEN: "Q", KING: "K", ACE: "A"};
|
||
|
||
let zustand = null, leisteSchluessel = "", vorab = new Set();
|
||
|
||
// --- Mauszeiger -------------------------------------------------------------
|
||
// Die Seite merkt sich, wo sie den Zeiger zuletzt sah (window.__zeiger, Pixel des Viewports; hand/klonmaus.py
|
||
// liest das) und meldet es gedrosselt an den Server (Anteil des Viewports -> /api/zustand). Echte Mausereignisse
|
||
// sind von CDP-Ereignissen nicht zu trennen; `mensch` setzt nur der Prüfhebel POST /api/mensch.
|
||
const zeiger = window.__zeiger = {x: null, y: null, n: 0, mensch: false, menschen: 0, mx: null, my: null};
|
||
const zeigerEl = document.getElementById("zeiger");
|
||
let zeigerMeldung = 0, zeigerTimer = null, menschNr = null;
|
||
function zeigerSehen(x, y, mensch) {
|
||
zeiger.x = x; zeiger.y = y; zeiger.n++; zeiger.mensch = mensch;
|
||
if (BUEHNE) {
|
||
zeigerEl.hidden = false; zeigerEl.style.display = "block";
|
||
zeigerEl.classList.toggle("mensch", mensch);
|
||
zeigerEl.style.transform = "translate(" + x + "px," + y + "px)";
|
||
}
|
||
const warte = zeigerMeldung + 50 - Date.now();
|
||
if (warte <= 0) zeigerMelden(); else if (!zeigerTimer) zeigerTimer = setTimeout(zeigerMelden, warte);
|
||
}
|
||
function zeigerMelden() {
|
||
zeigerTimer = null; zeigerMeldung = Date.now();
|
||
if (zeiger.x === null) return;
|
||
fetch("/api/zeiger", {method: "POST", keepalive: true, body: JSON.stringify({
|
||
room: RAUM, x: zeiger.x / innerWidth, y: zeiger.y / innerHeight, n: zeiger.n, mensch: zeiger.mensch})});
|
||
}
|
||
addEventListener("mousemove", e => zeigerSehen(e.clientX, e.clientY, false), true);
|
||
// der Zeiger hat das Fenster verlassen (hand/klonmaus.Bildschirm): nicht mehr zeichnen
|
||
window.zeigerWeg = () => { zeigerEl.hidden = true; zeigerEl.style.display = "none"; };
|
||
// Prüfhebel: als hätte ein Mensch die Maus bewegt (zustand.mensch zählt die Aufrufe)
|
||
function menschPruefen(m) {
|
||
if (!m) return;
|
||
if (menschNr === null) { menschNr = m.nr; return; } // frisch geöffnet: alte Aufrufe zählen nicht
|
||
if (m.nr === menschNr || m.x === null) return;
|
||
menschNr = m.nr;
|
||
// bleibt stehen, auch wenn gleich das nächste CDP-Ereignis kommt: menschen zählt, mx/my ist die Stelle
|
||
zeiger.menschen++; zeiger.mx = m.x * innerWidth; zeiger.my = m.y * innerHeight;
|
||
zeigerSehen(zeiger.mx, zeiger.my, true);
|
||
}
|
||
|
||
function rahmen() {
|
||
const w = outerWidth || innerWidth, h = outerHeight || innerHeight;
|
||
const rand = Math.max(0, (w - innerWidth) / 2); // links, rechts und unten gleich
|
||
return {w, h, rand, oben: Math.max(0, h - innerHeight - rand)};
|
||
}
|
||
function setzeStelle(el, fx, fy) {
|
||
const r = rahmen();
|
||
el.style.left = (fx * r.w - r.rand) + "px";
|
||
let oben = fy * r.h - r.oben;
|
||
if (el.dataset.minTop) oben = Math.max(oben, +el.dataset.minTop); // nie über den Seitenrand hinaus
|
||
el.style.top = oben + "px";
|
||
}
|
||
function anordnen() {
|
||
for (const el of document.querySelectorAll("[data-fx]")) setzeStelle(el, +el.dataset.fx, +el.dataset.fy);
|
||
}
|
||
function karte(k) {
|
||
const d = document.createElement("div");
|
||
d.className = "karte" + (k.suit === "HEARTS" || k.suit === "DIAMONDS" ? " rot" : "");
|
||
d.textContent = (WERT[k.value] || "?") + (FARBE[k.suit] || "?");
|
||
return d;
|
||
}
|
||
async function senden(pfad, daten) {
|
||
const r = await fetch(pfad, {method: "POST", body: JSON.stringify(Object.assign({room: RAUM}, daten))});
|
||
return r.json();
|
||
}
|
||
|
||
function plaetzeZeichnen() {
|
||
const box = document.getElementById("plaetze"), einsaetze = document.getElementById("einsaetze");
|
||
box.textContent = ""; einsaetze.textContent = "";
|
||
for (const s of zustand.sitze) {
|
||
let el;
|
||
if (s.name) {
|
||
el = document.createElement("div");
|
||
el.className = "stelle platz" + (s.nr === zustand.held_sitz ? " held" : "")
|
||
+ (zustand.uhr && zustand.uhr.sitz === s.nr ? " dran" : "")
|
||
+ (s.aktion === "Fold" ? " gefoldet" : "");
|
||
el.innerHTML = '<div class="name"><div></div><div class="chips"></div></div><div class="aktion"></div>';
|
||
el.querySelector(".name div").textContent = s.name;
|
||
el.querySelector(".chips").textContent = s.chips ?? "";
|
||
el.querySelector(".aktion").textContent = s.aktion || "";
|
||
if (s.einsatz) { // Einsatz liegt zwischen Platz und Mitte
|
||
const e = document.createElement("div");
|
||
e.className = "stelle einsatz"; e.textContent = s.einsatz;
|
||
e.dataset.fx = SCHILD[s.nr][0] + (0.5 - SCHILD[s.nr][0]) * 0.4;
|
||
e.dataset.fy = SCHILD[s.nr][1] + (0.5 - SCHILD[s.nr][1]) * 0.4;
|
||
einsaetze.appendChild(e);
|
||
}
|
||
if (s.nr === zustand.held_sitz && zustand.buyin.nachkauf_max > 0) { // Nachkauf: + an der Stelle des freien +
|
||
const n = document.createElement("button");
|
||
n.className = "stelle nachkauf"; n.textContent = "+";
|
||
n.dataset.fx = PLUS[s.nr][0]; n.dataset.fy = PLUS[s.nr][1];
|
||
n.addEventListener("click", nachkaufOeffnen);
|
||
box.appendChild(n);
|
||
}
|
||
} else if (zustand.held_sitz === null) {
|
||
el = document.createElement("button"); // ohne Hülle: der Text gehört dem Knopf
|
||
el.className = "stelle platz-frei"; el.textContent = "+";
|
||
el.addEventListener("click", () => platzWaehlen(s.nr));
|
||
} else continue;
|
||
const stelle = s.name ? SCHILD[s.nr] : PLUS[s.nr];
|
||
el.dataset.fx = stelle[0]; el.dataset.fy = stelle[1];
|
||
box.appendChild(el);
|
||
}
|
||
}
|
||
|
||
function leisteZeichnen() {
|
||
const box = document.getElementById("leiste");
|
||
const knoepfe = LEISTE[zustand.leiste](zustand);
|
||
const schluessel = zustand.leiste + JSON.stringify(knoepfe.map(k => k[0]));
|
||
if (schluessel === leisteSchluessel) return;
|
||
leisteSchluessel = schluessel;
|
||
box.textContent = "";
|
||
for (const [text, fx, fy, art, name] of knoepfe) {
|
||
const b = document.createElement("button");
|
||
b.textContent = text; b.className = art; b.dataset.fx = fx; b.dataset.fy = fy;
|
||
if (vorab.has(name)) b.classList.add("an");
|
||
b.addEventListener("click", () => klick(name, b));
|
||
box.appendChild(b);
|
||
}
|
||
if (zustand.leiste === "zug") {
|
||
const f = document.createElement("input");
|
||
f.className = "betrag"; f.dataset.fx = 0.873; f.dataset.fy = 0.855; f.value = zustand.raise || "";
|
||
box.appendChild(f);
|
||
}
|
||
}
|
||
|
||
function klick(name, knopf) {
|
||
if (name === "findseat") { findSeat(); return; }
|
||
if (name === "waitlist") return; // der untere Knopf "Join Wait List" tut nichts; erst Find Seat öffnet den Dialog
|
||
if (["fold", "call", "raise"].includes(name)) { senden("/api/aktion", {aktion: name}); return; }
|
||
if (name.startsWith("v") && zustand.leiste === "zug") {
|
||
const f = document.querySelector(".betrag");
|
||
if (f) f.value = name === "vmax" ? "Max" : name.slice(1) + "%";
|
||
return;
|
||
}
|
||
if (zustand.leiste === "vorab") { // Vorauswahl: nur Haken umschalten, wie im Client
|
||
vorab.has(name) ? vorab.delete(name) : vorab.add(name);
|
||
knopf.classList.toggle("an");
|
||
}
|
||
}
|
||
|
||
// Find Seat am vollen Tisch: bleibt am Tisch und öffnet den Wartelisten-Dialog (Betrag Min).
|
||
async function findSeat() {
|
||
const r = await senden("/api/findseat", {});
|
||
if (r.ok) { modus = "warteliste"; dialogOeffnen("Buy-In"); }
|
||
}
|
||
|
||
function zeichnen() {
|
||
plaetzeZeichnen();
|
||
leisteZeichnen();
|
||
const board = document.getElementById("board");
|
||
board.textContent = "";
|
||
for (const k of zustand.board) board.appendChild(karte(k));
|
||
const eigene = document.querySelector("#eigene .karten");
|
||
eigene.textContent = "";
|
||
for (const k of zustand.karten) eigene.appendChild(karte(k));
|
||
const so = document.getElementById("sitout");
|
||
so.hidden = zustand.held_sitz === null;
|
||
so.textContent = zustand.sitout ? "I'm Back" : "Sit Out";
|
||
so.dataset.fx = SITOUT[0]; so.dataset.fy = SITOUT[1];
|
||
document.querySelector(".pot").hidden = zustand.pot === null;
|
||
document.getElementById("pot").textContent = zustand.pot ?? "";
|
||
const tl = document.getElementById("turnier"), tu = zustand.turnier;
|
||
tl.hidden = !tu; // Turnier-Modus: Level, Blinds, Ante, Feld
|
||
if (tu) tl.textContent = (zustand.aus ? "Busted, Platz " + tu.platz + " - " : "") + "Level " + tu.level + " "
|
||
+ tu.sb + "/" + tu.bb + " ante " + tu.ante + " - " + tu.feld + "/" + tu.gesamt + " (bezahlt " + tu.bezahlt + ")";
|
||
document.getElementById("handnr").textContent = zustand.hand ? "Hand #" + zustand.hand : "";
|
||
document.getElementById("guthaben").textContent = zahl(zustand.buyin.konto);
|
||
const uhr = document.getElementById("uhr");
|
||
uhr.hidden = !(zustand.uhr && zustand.uhr.sitz);
|
||
if (!uhr.hidden) { // über dem Namen dessen, der dran ist
|
||
uhr.dataset.fx = SCHILD[zustand.uhr.sitz][0]; uhr.dataset.fy = SCHILD[zustand.uhr.sitz][1] - 0.075;
|
||
}
|
||
uhrTicken();
|
||
anordnen();
|
||
}
|
||
|
||
function uhrTicken() { // die Uhr läuft zwischen zwei Abfragen weiter
|
||
const u = zustand && zustand.uhr, el = document.getElementById("uhr");
|
||
if (!u || el.hidden) return;
|
||
const rest = Math.max(0, Math.ceil(u.frist - (Date.now() / 1000 - u.start) * u.faktor));
|
||
el.textContent = "⏱ " + rest;
|
||
el.classList.toggle("knapp", rest <= 5);
|
||
}
|
||
|
||
async function laden() {
|
||
try {
|
||
const neu = await (await fetch("/api/zustand?room=" + encodeURIComponent(RAUM))).json();
|
||
menschPruefen(neu.mensch);
|
||
// Zeigerstand ändert sich ständig und darf die Seite nicht neu zeichnen (ein Knopf unter der Maus ginge verloren)
|
||
const ohneZeiger = z => JSON.stringify(Object.assign({}, z, {zeiger: null, mensch: null}));
|
||
if (ohneZeiger(neu) !== ohneZeiger(zustand)) { zustand = neu; zeichnen(); }
|
||
if (zustand.wechsel) { location.href = "/table.html?room=" + encodeURIComponent(zustand.wechsel); return; } // Tischwechsel
|
||
const an = zustand.angebot; // Warteliste: Platz frei geworden und für uns reserviert
|
||
if (an && an.nr !== angebotNr) { angebotNr = an.nr; buyinOeffnen(an.sitz); }
|
||
if (START.get("sitz")) { const nr = +START.get("sitz"); START.delete("sitz"); platzWaehlen(nr); }
|
||
} catch (e) { /* Server weg */ }
|
||
}
|
||
|
||
// --- Buy-in ---------------------------------------------------------------
|
||
const modal = document.querySelector(".sfs-buy-in-modal");
|
||
const feld = document.querySelector(".sfs-slider-range-value");
|
||
const fehler = document.querySelector(".sfs-buy-in-body-error");
|
||
let gewaehlt = null, modus = "sitzen", angebotNr = null; // modus: sitzen | warteliste | nachkauf
|
||
const zahl = n => Number(n).toLocaleString("en-US");
|
||
const stackInfo = document.querySelector(".sfs-buy-in-body-container-text");
|
||
const claim = document.querySelector(".sfs-buy-in-modal-header-button");
|
||
const bestaetigen = document.querySelector(".sfs-buy-in-modal-button");
|
||
// Grenzen des Dialogs: beim Hinsetzen und auf der Warteliste Min/Max des Tischs, beim Nachkauf bis zur Obergrenze
|
||
function grenzen() {
|
||
const b = zustand.buyin;
|
||
if (modus !== "nachkauf") return {min: b.min, max: Math.min(b.max, b.konto)};
|
||
const max = Math.min(b.nachkauf_max, b.konto);
|
||
return {min: Math.min(b.bb, max), max};
|
||
}
|
||
// Vorbelegung beim Öffnen (am echten Tisch beobachtet): freier Platz Max, Warteliste Min; Nachkauf Min (Klon-Annahme)
|
||
function voreinstellung() {
|
||
return modus === "sitzen" ? grenzen().max : grenzen().min;
|
||
}
|
||
// Für Werkzeuge, die per Bildschirm klicken: Mitte eines Elements als Anteil des Fensterrahmens
|
||
window.stelleVon = sel => {
|
||
const el = document.querySelector(sel), r = rahmen();
|
||
if (!el || !el.offsetParent) return null;
|
||
const k = el.getBoundingClientRect();
|
||
return [(k.left + k.width / 2 + r.rand) / r.w, (k.top + k.height / 2 + r.oben) / r.h];
|
||
};
|
||
|
||
function buyinOeffnen(nr) {
|
||
gewaehlt = nr; modus = "sitzen";
|
||
dialogOeffnen("Buy-In");
|
||
}
|
||
// Klick auf ein freies +: der Platz wird reserviert (game.reserve_Seat), dann öffnet der Dialog
|
||
async function platzWaehlen(nr) {
|
||
await senden("/api/reservieren", {sitz: nr});
|
||
buyinOeffnen(nr);
|
||
}
|
||
function nachkaufOeffnen() {
|
||
modus = "nachkauf";
|
||
dialogOeffnen("Add Chips");
|
||
}
|
||
function dialogOeffnen(titel) {
|
||
const b = zustand.buyin;
|
||
document.querySelector(".sfs-buy-in-heading").textContent = titel;
|
||
document.querySelector(".sfs-buy-in-user-balance").textContent = zahl(b.konto);
|
||
stackInfo.hidden = modus !== "nachkauf";
|
||
stackInfo.textContent = "Stack " + zahl(b.stack ?? 0) + " · bis " + zahl(b.max);
|
||
claim.hidden = !b.claim_offen; // "Claim Chips" nur, solange die Chips offen sind (jeder Dialog)
|
||
bestaetigen.textContent = modus === "warteliste" ? "Join Wait List" : "Buy-In";
|
||
feld.value = zahl(voreinstellung());
|
||
fehler.textContent = "";
|
||
modal.style.display = "block";
|
||
document.querySelector(".dialog-backdrop").style.display = "block";
|
||
anordnen();
|
||
}
|
||
function buyinSchliessen() {
|
||
modal.style.display = "none";
|
||
document.querySelector(".dialog-backdrop").style.display = "none";
|
||
}
|
||
document.querySelector(".sfs-buy-in-body-min-range").addEventListener("click", () => feld.value = zahl(grenzen().min));
|
||
document.querySelector(".sfs-buy-in-body-max-range").addEventListener("click", () => feld.value = zahl(grenzen().max));
|
||
document.querySelector(".sfs-buy-in-body-mid-range").addEventListener("click", () => {
|
||
const g = grenzen();
|
||
feld.value = zahl(Math.round((g.min + g.max) / 2));
|
||
});
|
||
claim.addEventListener("click", async () => {
|
||
const r = await senden("/api/claim", {});
|
||
if (!r.ok) return;
|
||
await laden();
|
||
document.querySelector(".sfs-buy-in-user-balance").textContent = zahl(zustand.buyin.konto);
|
||
claim.hidden = true;
|
||
feld.value = zahl(voreinstellung());
|
||
});
|
||
document.querySelector(".common-dialog-cross-icon").addEventListener("click", buyinSchliessen);
|
||
bestaetigen.addEventListener("click", async () => {
|
||
let betrag = Number(feld.value.replace(/[^0-9.]/g, "")); // gekauft wird, was im Feld steht
|
||
if (modus === "nachkauf") betrag = Math.min(betrag, zustand.buyin.nachkauf_max); // höchstens bis Max
|
||
const r = modus === "sitzen" ? await senden("/api/sitzen", {sitz: gewaehlt, betrag})
|
||
: modus === "warteliste" ? await senden("/api/warteliste", {betrag})
|
||
: await senden("/api/nachkauf", {betrag});
|
||
if (r.ok) { buyinSchliessen(); laden(); } else fehler.textContent = r.fehler || "Platz nicht frei";
|
||
});
|
||
// Fensterkreuz des Spiels: das Tischfenster schliesst. Greift window.close() nicht (nicht per Skript
|
||
// geöffnet), schliesst der Server das Ziel per CDP.
|
||
document.getElementById("sitout").addEventListener("click", () => {
|
||
senden("/api/sitout", {an: !zustand.sitout}).then(laden);
|
||
});
|
||
// Am eigenen Platz steht das Kreuz erst vom Platz auf (leave_Seat, Guthaben zurück), dann schliesst es.
|
||
document.getElementById("spielkreuz").addEventListener("click", async () => {
|
||
if (zustand && zustand.held_sitz !== null) await senden("/api/verlassen", {});
|
||
window.close();
|
||
setTimeout(() => senden("/api/schliessen", {}), 300);
|
||
});
|
||
|
||
window.menschZeigt = laden; // vom Server angestossen, wenn POST /api/mensch kommt
|
||
addEventListener("resize", () => anordnen());
|
||
laden();
|
||
setInterval(laden, 250);
|
||
setInterval(uhrTicken, 100);
|
||
</script>
|
||
</body>
|
||
</html>
|