- tests/mock_spec.py: Kettentest cdp.mjs -> fenster.py -> click.py -> runner.py --live --act, belegt ueber nachsehen (ab fenster.py nur macOS); Pruefung, dass jedes Bedienelement per Text einen Knopf trifft - Seiten: + ohne Huelle, Buy-In-Ueberschrift als h2, Knoepfe als <button>, Buy-In an fester Rahmenstelle, Spielerzahl mit player-count/table-seat-progress - Logschreiber schreibt beim Klick die echte game.user_action-Zeile - start.py beendet alle Prozesse mit dem Klonprofil - runner.py: COINPOKER_LOG ueberschreibt den Logpfad Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
262 lines
12 KiB
HTML
262 lines
12 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. -->
|
||
<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-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; }
|
||
.sfs-buy-in-modal { position: absolute; width: 380px; box-sizing: border-box;
|
||
background: #1b1e29; border-radius: 12px; padding: 18px; display: none; }
|
||
.sfs-buy-in-header { display: flex; justify-content: space-between; align-items: center; }
|
||
.sfs-buy-in-heading { font-size: 20px; font-weight: 700; margin: 0; }
|
||
.sfs-buy-in-header-game-info { color: #99a; margin: 6px 0 14px; }
|
||
.sfs-buy-in-balance-container { display: flex; justify-content: space-between; margin-bottom: 12px; }
|
||
.sfs-buy-in-user-balance { color: #f5c542; font-weight: 700; }
|
||
.sfs-slider-range-value { width: 100%; 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-range-buttons { display: flex; justify-content: space-between; margin: 10px 0 16px; }
|
||
.sfs-buy-in-body-range-buttons button, .sfs-buy-in-modal-button {
|
||
background: #2b3045; color: #fff; border: 0; border-radius: 6px; padding: 6px 16px; cursor: pointer;
|
||
font: inherit; }
|
||
.sfs-buy-in-modal-button-container { padding: 6px 40px; }
|
||
.sfs-buy-in-modal-button { background: #1fae64; font-weight: 700; padding: 10px; width: 100%; }
|
||
.sfs-buy-in-body-error { color: #ff6b6b; min-height: 1em; font-size: 12px; }
|
||
.common-dialog-cross-icon { cursor: pointer; font-size: 22px; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="filz"></div>
|
||
<div id="plaetze"></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>
|
||
|
||
<div class="dialog-backdrop"></div>
|
||
<div class="sfs-buy-in-modal">
|
||
<div class="sfs-buy-in-header">
|
||
<h2 class="sfs-buy-in-heading">Buy-In</h2>
|
||
<div class="common-dialog-cross-icon" role="button" aria-label="close">×</div>
|
||
</div>
|
||
<div class="sfs-buy-in-header-game-info">{{TITEL}}</div>
|
||
<div class="sfs-buy-in-balance-container">
|
||
<div class="sfs-buy-in-balance-label">Balance</div>
|
||
<div class="sfs-buy-in-user-balance"></div>
|
||
</div>
|
||
<div class="sfs-buy-in-body">
|
||
<input class="sfs-slider-range-value" inputmode="numeric">
|
||
<div class="sfs-buy-in-body-range-buttons">
|
||
<button class="sfs-buy-in-body-min-range">Min</button>
|
||
<button class="sfs-buy-in-body-max-range">Max</button>
|
||
</div>
|
||
<div class="sfs-buy-in-body-error"></div>
|
||
</div>
|
||
<div class="sfs-buy-in-modal-button-container">
|
||
<button class="sfs-buy-in-modal-button">Buy-In</button>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
const RAUM = "{{RAUM}}";
|
||
// Platz -> Anteil des Fensterrahmens. Platz 1 ist das + aus der README (0.14 / 0.24).
|
||
const BUYIN = [0.50, 0.62]; // Stelle des Buy-In-Knopfs - das Bild des Dialogs fehlt in der Vorlage
|
||
const PLATZ = {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]};
|
||
// 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.66, 0.94, "gross", "findseat"],
|
||
["Join Wait List", 0.80, 0.94, "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();
|
||
|
||
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";
|
||
el.style.top = (fy * r.h - r.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");
|
||
box.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" : "");
|
||
el.innerHTML = '<div class="name"></div>';
|
||
el.firstChild.textContent = s.name;
|
||
} 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", () => buyinOeffnen(s.nr));
|
||
} else continue;
|
||
el.dataset.fx = PLATZ[s.nr][0]; el.dataset.fy = PLATZ[s.nr][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 (["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");
|
||
}
|
||
}
|
||
|
||
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));
|
||
document.querySelector(".pot").hidden = zustand.pot === null;
|
||
document.getElementById("pot").textContent = zustand.pot ?? "";
|
||
anordnen();
|
||
}
|
||
|
||
async function laden() {
|
||
try {
|
||
const neu = await (await fetch("/api/zustand?room=" + encodeURIComponent(RAUM))).json();
|
||
if (JSON.stringify(neu) !== JSON.stringify(zustand)) { zustand = neu; zeichnen(); }
|
||
} 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;
|
||
const zahl = n => Number(n).toLocaleString("en-US");
|
||
|
||
function buyinOeffnen(nr) {
|
||
gewaehlt = nr;
|
||
const b = zustand.buyin;
|
||
document.querySelector(".sfs-buy-in-user-balance").textContent = zahl(b.konto);
|
||
feld.value = zahl(b.min);
|
||
fehler.textContent = "";
|
||
modal.style.display = "block";
|
||
document.querySelector(".dialog-backdrop").style.display = "block";
|
||
buyinAusrichten();
|
||
}
|
||
function buyinAusrichten() {
|
||
if (modal.style.display !== "block") return;
|
||
const r = rahmen(), knopf = document.querySelector(".sfs-buy-in-modal-button");
|
||
modal.style.left = "0px"; modal.style.top = "0px";
|
||
const k = knopf.getBoundingClientRect();
|
||
modal.style.left = (BUYIN[0] * r.w - r.rand - (k.left + k.width / 2)) + "px";
|
||
modal.style.top = (BUYIN[1] * r.h - r.oben - (k.top + k.height / 2)) + "px";
|
||
}
|
||
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(zustand.buyin.min));
|
||
document.querySelector(".sfs-buy-in-body-max-range").addEventListener("click", () => feld.value = zahl(zustand.buyin.max));
|
||
document.querySelector(".common-dialog-cross-icon").addEventListener("click", buyinSchliessen);
|
||
document.querySelector(".sfs-buy-in-modal-button").addEventListener("click", async () => {
|
||
const betrag = Number(feld.value.replace(/[^0-9.]/g, ""));
|
||
const r = await senden("/api/sitzen", {sitz: gewaehlt, betrag});
|
||
if (r.ok) { buyinSchliessen(); laden(); } else fehler.textContent = r.fehler || "Platz nicht frei";
|
||
});
|
||
|
||
addEventListener("resize", () => { anordnen(); buyinAusrichten(); });
|
||
laden();
|
||
setInterval(laden, 250);
|
||
</script>
|
||
</body>
|
||
</html>
|