2026-11-14 04:25:51 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# games/blackjack/views/blackjack_table_view.py
|
2026-11-15 23:22:24 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
import json
|
|
|
|
|
import time
|
2026-11-15 23:22:24 +00:00
|
|
|
from pathlib import Path
|
2026-11-14 04:25:51 +00:00
|
|
|
import tkinter as tk
|
2026-11-15 23:22:24 +00:00
|
|
|
from PIL import Image, ImageTk
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
from games.blackjack.models.blackjack_engine import BlackjackEngine
|
|
|
|
|
from games.blackjack.models.bot_ai import BlackjackBotAI
|
|
|
|
|
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
|
|
|
|
from games.blackjack.models.hand_evaluator import HandEvaluator
|
|
|
|
|
from games.blackjack.models.player_hand import PlayerHand
|
|
|
|
|
from games.blackjack.views.round_result_dialog import BlackjackResultDialog
|
2026-11-21 01:20:50 +00:00
|
|
|
from games.solitaire.base.solitaire_bottom_bar import SolitaireBottomBar
|
|
|
|
|
from games.solitaire.base.solitaire_theme import SolitaireTableBgRenderer
|
2026-11-14 04:25:51 +00:00
|
|
|
from models.database import Database
|
|
|
|
|
from models.progression import Progression
|
|
|
|
|
from resources.code_res.game_constants import (
|
2026-11-21 01:20:50 +00:00
|
|
|
ACCENT_GOLD,
|
|
|
|
|
ACCENT_GOTH,
|
|
|
|
|
BJ_BOT_CARD_SIZE,
|
|
|
|
|
BJ_BOT_TURN_DELAY_MS,
|
|
|
|
|
BJ_DEALER_DELAY_MS,
|
|
|
|
|
BJ_INITIAL_ANTE,
|
|
|
|
|
BJ_SPLIT_CARD_SIZE,
|
|
|
|
|
BJ_STARTING_GOLD,
|
|
|
|
|
BJ_VARIANTS,
|
|
|
|
|
BORDER_COLOR,
|
|
|
|
|
ERROR_FG,
|
|
|
|
|
FG_COLOR,
|
|
|
|
|
FONT_COLOR_TITLE_MAIN,
|
|
|
|
|
FONT_SIZE_BODY,
|
|
|
|
|
GOLD_MIN_TABLE_ENTRY,
|
|
|
|
|
PK_TABLE_IMAGE,
|
|
|
|
|
PLAYING_CARD_SIZE,
|
|
|
|
|
TABLE_BG,
|
|
|
|
|
XP_TO_GOLD_AMOUNT,
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
from resources.code_res.i18n import t
|
|
|
|
|
from view.widgets.image_button import ImageButton
|
|
|
|
|
|
|
|
|
|
GAME_FOLDER_ID = "blackjack"
|
2026-11-15 23:22:24 +00:00
|
|
|
IMAGES_DIR = Path(__file__).resolve().parents[3] / "resources" / "images"
|
|
|
|
|
|
2026-11-16 20:07:01 +00:00
|
|
|
BJ_DEALER_CARD_SIZE = (86, 125)
|
|
|
|
|
|
2026-11-15 23:22:24 +00:00
|
|
|
BJ_SEAT_LAYOUT_BY_COUNT = {
|
|
|
|
|
1: (2,),
|
|
|
|
|
2: (1, 2),
|
|
|
|
|
3: (1, 2, 3),
|
|
|
|
|
4: (0, 1, 2, 3),
|
|
|
|
|
}
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
STEP_MITGEHEN = "MITGEHEN"
|
|
|
|
|
STEP_ZIEHEN = "ZIEHEN"
|
|
|
|
|
STEP_ERHOEHEN = "ERHOEHEN"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BlackjackTableView:
|
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
context,
|
|
|
|
|
variant_key: str,
|
|
|
|
|
bj_account_id: int,
|
|
|
|
|
bot_configs: list[tuple[int, str]],
|
|
|
|
|
on_back_to_menu,
|
|
|
|
|
resume_state_json: str | None = None,
|
|
|
|
|
):
|
|
|
|
|
self.ctx = context
|
|
|
|
|
self.variant_key = variant_key
|
|
|
|
|
self.cfg = BJ_VARIANTS[variant_key]
|
|
|
|
|
self.on_back_to_menu = on_back_to_menu
|
|
|
|
|
self.engine = BlackjackEngine(num_decks=self.cfg["decks"])
|
|
|
|
|
self.bot_ai = BlackjackBotAI()
|
|
|
|
|
|
|
|
|
|
self.active_hand_idx: int = 0
|
2026-11-14 05:46:46 +00:00
|
|
|
self.turn_step: str = STEP_ZIEHEN
|
|
|
|
|
self.settle_only_mode: bool = False
|
2026-11-14 04:25:51 +00:00
|
|
|
self.active_bot_idx: int = -1
|
|
|
|
|
self.round_start_time: float = time.time()
|
|
|
|
|
self._last_popup_payload: dict | None = None
|
|
|
|
|
self._result_dialog: BlackjackResultDialog | None = None
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
self._photo_refs: list = []
|
|
|
|
|
self._turn_job: str | None = None
|
|
|
|
|
self._resize_job: str | None = None
|
|
|
|
|
self._last_reveal_state: tuple[bool, bool] = (False, False)
|
|
|
|
|
|
|
|
|
|
self._bg_renderer = SolitaireTableBgRenderer(self.ctx.assets.res)
|
2026-11-15 23:22:24 +00:00
|
|
|
self._raw_table_pil: Image.Image | None = self._load_raw_table_image()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._raw_box_bg_pil: Image.Image | None = self._load_raw_box_bg_image()
|
2026-11-15 23:22:24 +00:00
|
|
|
self._scaled_table_photo: ImageTk.PhotoImage | None = None
|
2026-11-21 01:20:50 +00:00
|
|
|
self._cached_table_dims: tuple[int, int] = (0, 0)
|
|
|
|
|
self._box_bg_cache: dict[tuple[int, int], ImageTk.PhotoImage] = {}
|
2026-11-15 23:22:24 +00:00
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
self.ctx.sounds.play_ingame_music()
|
|
|
|
|
|
|
|
|
|
if resume_state_json is not None:
|
|
|
|
|
self._restore_from_json(resume_state_json)
|
|
|
|
|
else:
|
|
|
|
|
self.bj_account = Database.get_blackjack_account(bj_account_id)
|
|
|
|
|
self.devils_locked = bool(self.bj_account.get("devils_deal_active", 0))
|
|
|
|
|
|
|
|
|
|
level_chips = self._get_current_level_chips()
|
|
|
|
|
bot_bankroll = max(BJ_STARTING_GOLD, level_chips[-1] * 4)
|
|
|
|
|
self.bots: list[BlackjackBotSeat] = [
|
|
|
|
|
BlackjackBotSeat(name=b_name, ai_level=lvl, gold=bot_bankroll)
|
|
|
|
|
for lvl, b_name in bot_configs
|
|
|
|
|
]
|
|
|
|
|
self._build_ui()
|
|
|
|
|
self._start_new_round()
|
|
|
|
|
|
2026-11-15 23:22:24 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def _load_raw_table_image() -> Image.Image | None:
|
|
|
|
|
img_path = IMAGES_DIR / PK_TABLE_IMAGE
|
|
|
|
|
if img_path.is_file():
|
|
|
|
|
try:
|
2026-11-21 01:20:50 +00:00
|
|
|
return Image.open(img_path).convert("RGBA")
|
2026-11-15 23:22:24 +00:00
|
|
|
except Exception:
|
|
|
|
|
return None
|
|
|
|
|
return None
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def _load_raw_box_bg_image() -> Image.Image | None:
|
|
|
|
|
for fname in ("box_background.png", "box_background.jpg"):
|
|
|
|
|
p = IMAGES_DIR / fname
|
|
|
|
|
if p.is_file():
|
|
|
|
|
try:
|
|
|
|
|
return Image.open(p).convert("RGBA")
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def _canvas_alive(self) -> bool:
|
|
|
|
|
try:
|
|
|
|
|
return hasattr(self, "arena_canvas") and bool(self.arena_canvas.winfo_exists())
|
|
|
|
|
except Exception:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def _cancel_jobs(self):
|
|
|
|
|
for job in (self._turn_job, self._resize_job):
|
|
|
|
|
if job is not None:
|
|
|
|
|
try:
|
|
|
|
|
self.ctx.root.after_cancel(job)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
self._turn_job = None
|
|
|
|
|
self._resize_job = None
|
|
|
|
|
|
|
|
|
|
def _get_box_bg_photo(self, w: int, h: int) -> ImageTk.PhotoImage | None:
|
|
|
|
|
if self._raw_box_bg_pil is None or w < 16 or h < 16:
|
|
|
|
|
return None
|
|
|
|
|
key = (w, h)
|
|
|
|
|
cached = self._box_bg_cache.get(key)
|
|
|
|
|
if cached is not None:
|
|
|
|
|
return cached
|
|
|
|
|
if len(self._box_bg_cache) > 24:
|
|
|
|
|
self._box_bg_cache.clear()
|
|
|
|
|
scaled = self._raw_box_bg_pil.resize((w, h), Image.Resampling.LANCZOS)
|
|
|
|
|
ph = ImageTk.PhotoImage(scaled)
|
|
|
|
|
self._box_bg_cache[key] = ph
|
|
|
|
|
return ph
|
|
|
|
|
|
|
|
|
|
def _draw_framed_panel(
|
2026-11-16 20:07:01 +00:00
|
|
|
self,
|
2026-11-21 01:20:50 +00:00
|
|
|
cx: int,
|
|
|
|
|
cy: int,
|
|
|
|
|
w: int,
|
|
|
|
|
h: int,
|
|
|
|
|
frame_style: str = "purple",
|
|
|
|
|
status_border: str | None = None,
|
|
|
|
|
):
|
|
|
|
|
"""Zeichnet `box_background.png` mit gotischem Zierrahmen (`box_purple` / `box_gold_double`)."""
|
|
|
|
|
x1, y1 = cx - w // 2, cy - h // 2
|
|
|
|
|
x2, y2 = x1 + w, y1 + h
|
|
|
|
|
|
|
|
|
|
inset = 5
|
|
|
|
|
inner_w, inner_h = max(16, w - 2 * inset), max(16, h - 2 * inset)
|
|
|
|
|
if hasattr(self.ctx.assets, "get_box_bg_photo"):
|
|
|
|
|
bg_ph = self.ctx.assets.get_box_bg_photo((inner_w, inner_h))
|
|
|
|
|
else:
|
|
|
|
|
bg_ph = self._get_box_bg_photo(inner_w, inner_h)
|
|
|
|
|
|
|
|
|
|
if bg_ph is not None:
|
|
|
|
|
self._photo_refs.append(bg_ph)
|
|
|
|
|
self.arena_canvas.create_image(cx, cy, image=bg_ph, anchor="center", tags="fg")
|
|
|
|
|
else:
|
|
|
|
|
self.arena_canvas.create_rectangle(
|
|
|
|
|
x1 + inset, y1 + inset, x2 - inset, y2 - inset,
|
|
|
|
|
fill="#110e18", outline="", tags="fg",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
box_key = "box_gold_double" if frame_style == "gold" else "box_purple"
|
|
|
|
|
frame_ph = self.ctx.assets.get_box_photo(box_key, (w, h))
|
|
|
|
|
if frame_ph is not None:
|
|
|
|
|
self._photo_refs.append(frame_ph)
|
|
|
|
|
self.arena_canvas.create_image(cx, cy, image=frame_ph, anchor="center", tags="fg")
|
|
|
|
|
else:
|
|
|
|
|
fallback_col = ACCENT_GOLD if frame_style == "gold" else BORDER_COLOR
|
|
|
|
|
self.arena_canvas.create_rectangle(
|
|
|
|
|
x1, y1, x2, y2, fill="", outline=fallback_col, width=2, tags="fg"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if status_border:
|
|
|
|
|
self.arena_canvas.create_rectangle(
|
|
|
|
|
x1 + 3, y1 + 3, x2 - 3, y2 - 3,
|
|
|
|
|
fill="", outline=status_border, width=2, tags="fg",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def _make_goth_photo(
|
|
|
|
|
self,
|
|
|
|
|
text: str,
|
|
|
|
|
size_px: int,
|
|
|
|
|
color: str,
|
|
|
|
|
max_width: int | None = None,
|
|
|
|
|
) -> ImageTk.PhotoImage | None:
|
|
|
|
|
if not text:
|
|
|
|
|
return None
|
|
|
|
|
try:
|
|
|
|
|
kwargs = {"size_px": size_px, "color": color}
|
|
|
|
|
if max_width is not None:
|
|
|
|
|
kwargs["max_width"] = max_width
|
|
|
|
|
ph = self.ctx.assets.get_goth_text_photo(text, **kwargs)
|
|
|
|
|
if ph is not None:
|
|
|
|
|
self._photo_refs.append(ph)
|
|
|
|
|
return ph
|
|
|
|
|
except TypeError:
|
|
|
|
|
try:
|
|
|
|
|
ph = self.ctx.assets.get_goth_text_photo(text, size_px=size_px, color=color)
|
|
|
|
|
if ph is not None:
|
|
|
|
|
self._photo_refs.append(ph)
|
|
|
|
|
return ph
|
|
|
|
|
except Exception:
|
|
|
|
|
return None
|
|
|
|
|
except Exception:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def _place_goth_photo_or_fallback(
|
|
|
|
|
self,
|
|
|
|
|
cx: int,
|
|
|
|
|
cy: int,
|
|
|
|
|
ph: ImageTk.PhotoImage | None,
|
|
|
|
|
fallback_text: str,
|
|
|
|
|
size_px: int,
|
|
|
|
|
color: str,
|
|
|
|
|
anchor: str = "center",
|
|
|
|
|
):
|
|
|
|
|
if ph is not None:
|
|
|
|
|
self.arena_canvas.create_image(cx, cy, image=ph, anchor=anchor, tags="fg")
|
|
|
|
|
elif fallback_text:
|
|
|
|
|
self.arena_canvas.create_text(
|
|
|
|
|
cx,
|
|
|
|
|
cy,
|
|
|
|
|
text=fallback_text,
|
|
|
|
|
font=("Georgia", max(9, size_px - 3), "bold"),
|
|
|
|
|
fill=color,
|
|
|
|
|
anchor=anchor,
|
|
|
|
|
tags="fg",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def _draw_fanned_cards_on_canvas(
|
|
|
|
|
self,
|
|
|
|
|
cx: int,
|
|
|
|
|
cy: int,
|
2026-11-16 20:07:01 +00:00
|
|
|
photos: list,
|
|
|
|
|
card_size: tuple[int, int],
|
|
|
|
|
visible_step: int,
|
2026-11-21 01:20:50 +00:00
|
|
|
max_width: int = 340,
|
|
|
|
|
highlight_color: str | None = None,
|
|
|
|
|
) -> tuple[int, int, int, int]:
|
2026-11-16 20:07:01 +00:00
|
|
|
cw, ch = card_size
|
|
|
|
|
n = len(photos)
|
|
|
|
|
if n <= 0:
|
2026-11-21 01:20:50 +00:00
|
|
|
return (cx, cy, cx, cy)
|
2026-11-16 20:07:01 +00:00
|
|
|
|
|
|
|
|
step = visible_step
|
|
|
|
|
if n > 1 and (cw + (n - 1) * step) > max_width:
|
2026-11-21 01:20:50 +00:00
|
|
|
step = max(16, (max_width - cw) // (n - 1))
|
2026-11-16 20:07:01 +00:00
|
|
|
|
|
|
|
|
total_w = cw + (n - 1) * step if n > 1 else cw
|
2026-11-21 01:20:50 +00:00
|
|
|
start_x = cx - total_w // 2
|
|
|
|
|
start_y = cy - ch // 2
|
|
|
|
|
|
|
|
|
|
if highlight_color:
|
|
|
|
|
self.arena_canvas.create_rectangle(
|
|
|
|
|
start_x - 4,
|
|
|
|
|
start_y - 4,
|
|
|
|
|
start_x + total_w + 4,
|
|
|
|
|
start_y + ch + 4,
|
|
|
|
|
outline=highlight_color,
|
|
|
|
|
width=2,
|
|
|
|
|
tags="fg",
|
|
|
|
|
)
|
|
|
|
|
|
2026-11-16 20:07:01 +00:00
|
|
|
for i, ph in enumerate(photos):
|
2026-11-21 01:20:50 +00:00
|
|
|
self.arena_canvas.create_image(
|
|
|
|
|
start_x + i * step, start_y, image=ph, anchor="nw", tags="fg"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return (start_x, start_y, start_x + total_w, start_y + ch)
|
2026-11-16 20:07:01 +00:00
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
# ---------------------------------------------------------
|
2026-11-21 01:20:50 +00:00
|
|
|
# AUTO-SAVE & RESUME / STATE SNAPSHOT
|
2026-11-14 04:25:51 +00:00
|
|
|
# ---------------------------------------------------------
|
2026-11-21 01:20:50 +00:00
|
|
|
def _build_state_dict(self) -> dict:
|
|
|
|
|
return {
|
2026-11-14 04:25:51 +00:00
|
|
|
"bj_account_id": self.bj_account["id"],
|
|
|
|
|
"devils_locked": self.devils_locked,
|
|
|
|
|
"active_hand_idx": self.active_hand_idx,
|
|
|
|
|
"turn_step": self.turn_step,
|
2026-11-14 05:46:46 +00:00
|
|
|
"settle_only_mode": self.settle_only_mode,
|
2026-11-14 04:25:51 +00:00
|
|
|
"active_bot_idx": self.active_bot_idx,
|
|
|
|
|
"elapsed_sec": max(0.0, time.time() - self.round_start_time),
|
|
|
|
|
"running_count": self.bot_ai.running_count,
|
|
|
|
|
"last_popup_payload": self._last_popup_payload,
|
|
|
|
|
"engine": self.engine.to_dict(self.bots),
|
|
|
|
|
}
|
2026-11-21 01:20:50 +00:00
|
|
|
|
|
|
|
|
def _persist_state(self):
|
|
|
|
|
if not self.devils_locked:
|
|
|
|
|
return
|
2026-11-14 04:25:51 +00:00
|
|
|
Database.save_game_state(
|
|
|
|
|
self.ctx.profile["id"],
|
|
|
|
|
GAME_FOLDER_ID,
|
|
|
|
|
self.variant_key,
|
2026-11-21 01:20:50 +00:00
|
|
|
json.dumps(self._build_state_dict()),
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def _clear_persisted_state(self):
|
|
|
|
|
Database.delete_game_state(self.ctx.profile["id"], GAME_FOLDER_ID)
|
|
|
|
|
|
|
|
|
|
def _restore_from_json(self, raw_json: str):
|
|
|
|
|
try:
|
|
|
|
|
data = json.loads(raw_json)
|
|
|
|
|
self.bj_account = Database.get_blackjack_account(data["bj_account_id"])
|
2026-11-21 01:20:50 +00:00
|
|
|
self.devils_locked = bool(
|
|
|
|
|
data.get("devils_locked", False) or self.bj_account.get("devils_deal_active", 0)
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
self.active_hand_idx = int(data.get("active_hand_idx", 0))
|
2026-11-14 05:46:46 +00:00
|
|
|
self.turn_step = data.get("turn_step", STEP_ZIEHEN)
|
|
|
|
|
self.settle_only_mode = bool(data.get("settle_only_mode", False))
|
2026-11-14 04:25:51 +00:00
|
|
|
self.active_bot_idx = int(data.get("active_bot_idx", -1))
|
|
|
|
|
self.round_start_time = time.time() - float(data.get("elapsed_sec", 0.0))
|
|
|
|
|
self.bot_ai.running_count = int(data.get("running_count", 0))
|
|
|
|
|
self._last_popup_payload = data.get("last_popup_payload")
|
|
|
|
|
self.bots = self.engine.load_from_dict(data["engine"])
|
|
|
|
|
except Exception:
|
|
|
|
|
self._clear_persisted_state()
|
|
|
|
|
dev_acc = Database.get_active_devils_bj_account(self.ctx.profile["id"])
|
|
|
|
|
accounts = Database.get_blackjack_accounts(self.ctx.profile["id"])
|
|
|
|
|
self.bj_account = dev_acc or accounts[0]
|
|
|
|
|
self.devils_locked = bool(self.bj_account.get("devils_deal_active", 0))
|
|
|
|
|
self.bots = []
|
|
|
|
|
self._build_ui()
|
|
|
|
|
self._start_new_round()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._build_ui()
|
|
|
|
|
|
|
|
|
|
if self.engine.state == "ACTION_LOOP":
|
2026-11-14 05:46:46 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 04:25:51 +00:00
|
|
|
if self.active_bot_idx >= 0:
|
|
|
|
|
self._step_next_bot()
|
2026-11-14 05:46:46 +00:00
|
|
|
elif 0 <= self.active_hand_idx < len(self.engine.player_hands):
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-14 04:25:51 +00:00
|
|
|
else:
|
2026-11-14 05:46:46 +00:00
|
|
|
self._begin_new_table_cycle()
|
2026-11-14 04:25:51 +00:00
|
|
|
elif self.engine.state == "DEALER_TURN":
|
|
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
self._turn_job = self.ctx.root.after(BJ_DEALER_DELAY_MS, self._dealer_draw_step)
|
|
|
|
|
elif self.engine.state == "SHOWDOWN" and self._last_popup_payload:
|
|
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
self._open_result_popup(self._build_localized_popup_data(self._last_popup_payload))
|
|
|
|
|
else:
|
|
|
|
|
self._start_new_round()
|
|
|
|
|
|
|
|
|
|
def _get_current_level_chips(self) -> tuple[int, int, int, int]:
|
|
|
|
|
bj_lvl = self.ctx.game_progress["level"]
|
|
|
|
|
return Progression.get_level_bet_chips(bj_lvl, bet_scale=self.cfg.get("bet_scale", 1))
|
|
|
|
|
|
|
|
|
|
def _cleanup_and_go(self, nav_callable):
|
|
|
|
|
if self.devils_locked:
|
|
|
|
|
return
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
|
|
|
|
self._cancel_jobs()
|
2026-11-14 04:25:51 +00:00
|
|
|
if self._result_dialog:
|
|
|
|
|
self._result_dialog.close_dialog()
|
|
|
|
|
self._result_dialog = None
|
|
|
|
|
self._clear_persisted_state()
|
|
|
|
|
nav_callable()
|
|
|
|
|
|
|
|
|
|
def _on_language_switched(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
self._persist_state()
|
|
|
|
|
self._build_ui()
|
|
|
|
|
if self.engine.state == "ACTION_LOOP":
|
2026-11-21 01:20:50 +00:00
|
|
|
if self.active_bot_idx == -1 and 0 <= self.active_hand_idx < len(self.engine.player_hands):
|
2026-11-14 04:25:51 +00:00
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 04:25:51 +00:00
|
|
|
elif self.engine.state == "DEALER_TURN":
|
|
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
elif self.engine.state == "SHOWDOWN" and self._last_popup_payload:
|
|
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
self._open_result_popup(self._build_localized_popup_data(self._last_popup_payload))
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
# UI AUFBAU (Vollbild-Canvas + Universal-Topbar + Bottom-Bar)
|
|
|
|
|
# ---------------------------------------------------------
|
2026-11-14 04:25:51 +00:00
|
|
|
def _build_ui(self):
|
|
|
|
|
if self._result_dialog:
|
|
|
|
|
self._result_dialog.close_dialog()
|
|
|
|
|
self._result_dialog = None
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
|
|
|
|
self._cached_table_dims = (0, 0)
|
|
|
|
|
self._scaled_table_photo = None
|
2026-11-14 04:25:51 +00:00
|
|
|
self.ctx.root.clear_window(apply_global_bg=True)
|
2026-11-21 01:20:50 +00:00
|
|
|
self.ctx.refresh_game_progress()
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
self.topbar = self.ctx.build_game_topbar(
|
|
|
|
|
self.ctx.root,
|
2026-11-21 01:20:50 +00:00
|
|
|
stats_endpoint="blackjack",
|
|
|
|
|
stats_enabled=not self.devils_locked,
|
2026-11-14 04:25:51 +00:00
|
|
|
on_lang_refresh=self._on_language_switched,
|
|
|
|
|
locked_exit=self.devils_locked,
|
|
|
|
|
)
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
self.hud_var = tk.StringVar(value="")
|
|
|
|
|
self.status_var = tk.StringVar(value="")
|
|
|
|
|
|
|
|
|
|
self.bottom_bar = SolitaireBottomBar(
|
|
|
|
|
self.ctx.root, self.ctx, self.hud_var, self.status_var
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
2026-11-21 01:20:50 +00:00
|
|
|
self.bottom_bar.pack(fill="x", side="bottom", padx=14, pady=(4, 8))
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-15 23:22:24 +00:00
|
|
|
self.arena_canvas = tk.Canvas(
|
2026-11-21 01:20:50 +00:00
|
|
|
self.ctx.root, bg=TABLE_BG, bd=0, highlightthickness=0
|
2026-11-15 23:22:24 +00:00
|
|
|
)
|
2026-11-21 01:20:50 +00:00
|
|
|
self.arena_canvas.pack(fill="both", expand=True, padx=14, pady=(4, 2))
|
|
|
|
|
self.arena_canvas.bind("<Configure>", self._on_arena_configure)
|
2026-11-15 23:22:24 +00:00
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
self._refresh_header()
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
def _set_bottom_buttons(
|
|
|
|
|
self,
|
|
|
|
|
primary_buttons: list[ImageButton],
|
|
|
|
|
overflow_buttons: list[ImageButton] | None = None,
|
|
|
|
|
):
|
|
|
|
|
ImageButton.close_active_hover_tip()
|
|
|
|
|
if hasattr(self, "bottom_bar") and self.bottom_bar.winfo_exists():
|
|
|
|
|
self.bottom_bar.set_buttons(primary_buttons, overflow_buttons=overflow_buttons)
|
2026-11-15 23:22:24 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
def _on_arena_configure(self, _event=None):
|
|
|
|
|
if not self._canvas_alive():
|
|
|
|
|
return
|
|
|
|
|
if self._resize_job is not None:
|
|
|
|
|
try:
|
|
|
|
|
self.ctx.root.after_cancel(self._resize_job)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
try:
|
|
|
|
|
self._resize_job = self.ctx.root.after(
|
|
|
|
|
35, lambda: self._render_table(*self._last_reveal_state)
|
2026-11-15 23:22:24 +00:00
|
|
|
)
|
2026-11-21 01:20:50 +00:00
|
|
|
except Exception:
|
|
|
|
|
self._resize_job = None
|
|
|
|
|
|
|
|
|
|
def _get_stretched_table_photo(self, exact_w: int, exact_h: int) -> ImageTk.PhotoImage | None:
|
|
|
|
|
if self._raw_table_pil is None or exact_w < 160 or exact_h < 120:
|
|
|
|
|
return None
|
|
|
|
|
if self._scaled_table_photo is None or self._cached_table_dims != (exact_w, exact_h):
|
|
|
|
|
stretched = self._raw_table_pil.resize((exact_w, exact_h), Image.Resampling.LANCZOS)
|
|
|
|
|
self._scaled_table_photo = ImageTk.PhotoImage(stretched)
|
|
|
|
|
self._cached_table_dims = (exact_w, exact_h)
|
|
|
|
|
return self._scaled_table_photo
|
2026-11-15 23:22:24 +00:00
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
def _refresh_header(self):
|
|
|
|
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
2026-11-21 01:20:50 +00:00
|
|
|
self.topbar.update_level_xp_text()
|
|
|
|
|
|
|
|
|
|
gold_str = t("bj_header_gold", self.bj_account["account_name"], self.bj_account["gold"])
|
|
|
|
|
hud_segments = [gold_str, f"~Pot: {self.engine.pot}g"]
|
|
|
|
|
if self.devils_locked:
|
|
|
|
|
hud_segments.append("~Devil's Gambit")
|
|
|
|
|
hud_txt = "|".join(hud_segments)
|
|
|
|
|
if hasattr(self, "hud_var") and self.hud_var.get() != hud_txt:
|
|
|
|
|
self.hud_var.set(hud_txt)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
# ---------------------------------------------------------
|
2026-11-14 05:46:46 +00:00
|
|
|
# ROUND START
|
2026-11-14 04:25:51 +00:00
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
def _start_new_round(self):
|
|
|
|
|
if self._result_dialog:
|
|
|
|
|
self._result_dialog.close_dialog()
|
|
|
|
|
self._result_dialog = None
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
|
|
|
|
self.devils_locked = bool(self.bj_account.get("devils_deal_active", 0))
|
|
|
|
|
gold = self.bj_account["gold"]
|
|
|
|
|
|
|
|
|
|
if gold < GOLD_MIN_TABLE_ENTRY:
|
|
|
|
|
Database.set_bj_devils_deal_active(self.bj_account["id"], False)
|
|
|
|
|
self.devils_locked = False
|
|
|
|
|
self._clear_persisted_state()
|
|
|
|
|
cur_cost = self.ctx.refresh_game_progress()["xp_exchange_cost"]
|
|
|
|
|
msg = t(
|
|
|
|
|
"bj_err_not_enough_gold_entry",
|
2026-11-21 01:20:50 +00:00
|
|
|
self.bj_account["account_name"],
|
|
|
|
|
GOLD_MIN_TABLE_ENTRY,
|
|
|
|
|
gold,
|
|
|
|
|
cur_cost,
|
|
|
|
|
XP_TO_GOLD_AMOUNT,
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
self._cleanup_and_go(lambda: self.on_back_to_menu(self.bj_account["id"], msg))
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._last_popup_payload = None
|
|
|
|
|
self.active_hand_idx = 0
|
2026-11-14 05:46:46 +00:00
|
|
|
self.settle_only_mode = False
|
2026-11-14 04:25:51 +00:00
|
|
|
self.active_bot_idx = -1
|
|
|
|
|
self.round_start_time = time.time()
|
|
|
|
|
self.ctx.sounds.play("deal")
|
|
|
|
|
|
|
|
|
|
min_cards = (len(self.bots) + 3) * 6
|
|
|
|
|
if self.engine.check_reshuffle(min_needed=min_cards):
|
|
|
|
|
self.bot_ai.reset_count()
|
|
|
|
|
|
|
|
|
|
level_chips = self._get_current_level_chips()
|
|
|
|
|
min_bot_stack = max(BJ_STARTING_GOLD, level_chips[-1] * 3)
|
|
|
|
|
for b in self.bots:
|
|
|
|
|
self.bot_ai.ensure_ante_gold(b, BJ_INITIAL_ANTE, fallback_stack=min_bot_stack)
|
|
|
|
|
|
|
|
|
|
paid_ante = self.engine.deal_initial_round(BJ_INITIAL_ANTE, gold, self.bots)
|
|
|
|
|
self.bj_account = Database.update_blackjack_gold(self.bj_account["id"], -paid_ante)
|
|
|
|
|
|
|
|
|
|
self.bot_ai.observe_public_card(self.engine.dealer_hand[0])
|
|
|
|
|
self._persist_state()
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
if not self._canvas_alive():
|
|
|
|
|
self._build_ui()
|
|
|
|
|
else:
|
|
|
|
|
self.topbar.set_locked_exit(self.devils_locked)
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 05:46:46 +00:00
|
|
|
self._begin_new_table_cycle()
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
# ---------------------------------------------------------
|
2026-11-21 01:20:50 +00:00
|
|
|
# CANVAS-LAYOUT: NUR DEALER-KARTEN & POT INNEN, BOTS ECKEN, SPIELER UNTEN
|
2026-11-14 04:25:51 +00:00
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _hand_state_suffix(hand: PlayerHand) -> str:
|
|
|
|
|
if hand.busted:
|
|
|
|
|
return t("bj_state_busted")
|
|
|
|
|
if hand.folded:
|
|
|
|
|
return t("bj_state_folded")
|
2026-11-14 05:46:46 +00:00
|
|
|
if hand.doubled or hand.cards_locked:
|
2026-11-14 04:25:51 +00:00
|
|
|
return t("bj_state_locked")
|
|
|
|
|
return ""
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
def _draw_dealer_and_pot_inside_table(
|
|
|
|
|
self,
|
|
|
|
|
table_rect: tuple[int, int, int, int],
|
|
|
|
|
player_top_y: int,
|
|
|
|
|
reveal_dealer: bool,
|
|
|
|
|
):
|
|
|
|
|
"""Zeichnet im Tisch-Innenfeld ausschließlich die Dealer-Karten und das kompakte Pot-Banner."""
|
|
|
|
|
tx1, ty1, tx2, ty2 = table_rect
|
|
|
|
|
t_cx = (tx1 + tx2) // 2
|
|
|
|
|
t_h = max(260, ty2 - ty1)
|
|
|
|
|
|
|
|
|
|
felt_top = ty1 + max(36, int(t_h * 0.15))
|
|
|
|
|
felt_bot = min(ty2 - max(28, int(t_h * 0.12)), player_top_y - 12)
|
|
|
|
|
|
|
|
|
|
_dc_w, dc_h = BJ_DEALER_CARD_SIZE
|
|
|
|
|
avail_felt_h = max(170, felt_bot - felt_top)
|
|
|
|
|
d_cards_cy = felt_top + min(dc_h // 2 + 12, int(avail_felt_h * 0.34))
|
|
|
|
|
|
|
|
|
|
d_photos = []
|
|
|
|
|
for c_idx, card in enumerate(self.engine.dealer_hand):
|
|
|
|
|
photo = (
|
|
|
|
|
self.ctx.assets.get_card_back_photo(
|
|
|
|
|
color=self.cfg["back_color"], size=BJ_DEALER_CARD_SIZE
|
|
|
|
|
)
|
|
|
|
|
if c_idx == 1 and not reveal_dealer
|
|
|
|
|
else self.ctx.assets.get_card_photo(
|
|
|
|
|
card.image_filename, size=BJ_DEALER_CARD_SIZE
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
if photo:
|
|
|
|
|
self._photo_refs.append(photo)
|
|
|
|
|
d_photos.append(photo)
|
|
|
|
|
|
|
|
|
|
if d_photos:
|
|
|
|
|
self._draw_fanned_cards_on_canvas(
|
|
|
|
|
t_cx, d_cards_cy, d_photos, BJ_DEALER_CARD_SIZE, visible_step=38, max_width=340
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
pot_raw = t("bj_pot_banner", self.engine.pot)
|
|
|
|
|
pot_txt = pot_raw.split("|")[0].strip()
|
|
|
|
|
|
|
|
|
|
pot_cy = min(
|
|
|
|
|
felt_bot - 22,
|
|
|
|
|
max(d_cards_cy + dc_h // 2 + 34, (d_cards_cy + dc_h // 2 + felt_bot) // 2),
|
|
|
|
|
)
|
|
|
|
|
pot_size = max(16, FONT_SIZE_BODY + 1)
|
|
|
|
|
pot_ph = self._make_goth_photo(pot_txt, size_px=pot_size, color=FONT_COLOR_TITLE_MAIN)
|
|
|
|
|
if pot_ph is not None:
|
|
|
|
|
bw = max(230, pot_ph.width() + 64)
|
|
|
|
|
bh = max(40, pot_ph.height() + 18)
|
|
|
|
|
self._draw_framed_panel(t_cx, pot_cy, bw, bh, frame_style="gold")
|
|
|
|
|
self.arena_canvas.create_image(t_cx, pot_cy, image=pot_ph, anchor="center", tags="fg")
|
|
|
|
|
else:
|
|
|
|
|
self._draw_framed_panel(t_cx, pot_cy, 240, 40, frame_style="gold")
|
|
|
|
|
self._place_goth_photo_or_fallback(
|
|
|
|
|
t_cx, pot_cy, None, pot_txt, size_px=pot_size, color=ACCENT_GOLD
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def _draw_bots_at_table_corners(
|
|
|
|
|
self,
|
|
|
|
|
cw: int,
|
|
|
|
|
ch: int,
|
|
|
|
|
pad_x: int,
|
|
|
|
|
pad_top: int,
|
|
|
|
|
pad_bot: int,
|
|
|
|
|
table_rect: tuple[int, int, int, int],
|
|
|
|
|
reveal_opponents: bool,
|
|
|
|
|
):
|
|
|
|
|
"""Zeichnet die 4 Kultisten-Boxen an den Tischecken mit garantiertem Rahmenabstand."""
|
|
|
|
|
if not self.bots:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
tx1, ty1, tx2, ty2 = table_rect
|
|
|
|
|
bc_w, bc_h = BJ_BOT_CARD_SIZE
|
|
|
|
|
|
|
|
|
|
card_scale = 0.90 if ch < 560 else 1.0
|
|
|
|
|
cur_card_sz = (max(52, int(bc_w * card_scale)), max(76, int(bc_h * card_scale)))
|
|
|
|
|
base_box_w = max(198, cur_card_sz[0] + 114)
|
|
|
|
|
box_h = cur_card_sz[1] + 90
|
|
|
|
|
|
|
|
|
|
top_cy = max(pad_top + box_h // 2, ty1 + box_h // 2 - 4)
|
|
|
|
|
bot_cy = min(ch - pad_bot - box_h // 2, ty2 - box_h // 2 + 22)
|
|
|
|
|
if bot_cy - top_cy < box_h + 14:
|
|
|
|
|
mid_y = (top_cy + bot_cy) // 2
|
|
|
|
|
top_cy = mid_y - (box_h + 14) // 2
|
|
|
|
|
bot_cy = mid_y + (box_h + 14) // 2
|
2026-11-15 23:22:24 +00:00
|
|
|
|
|
|
|
|
slot_indices = BJ_SEAT_LAYOUT_BY_COUNT.get(len(self.bots), (0, 1, 2, 3))
|
|
|
|
|
|
|
|
|
|
for bot_i, bot in enumerate(self.bots):
|
|
|
|
|
coord_idx = slot_indices[bot_i]
|
2026-11-21 01:20:50 +00:00
|
|
|
is_left_side = coord_idx in (0, 1)
|
|
|
|
|
by = bot_cy if coord_idx in (0, 3) else top_cy
|
2026-11-15 23:22:24 +00:00
|
|
|
|
|
|
|
|
is_turn = (bot_i == self.active_bot_idx)
|
2026-11-21 01:20:50 +00:00
|
|
|
is_out = (bot.folded or bot.busted)
|
|
|
|
|
frame_style = "gold" if is_turn else "purple"
|
|
|
|
|
status_border = ERROR_FG if is_out else None
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
disp_name = t("bj_bot_rebuy", bot.name) if bot.rebought else bot.name
|
2026-11-21 01:20:50 +00:00
|
|
|
name_col = ACCENT_GOLD if is_turn else ACCENT_GOTH
|
|
|
|
|
gold_txt = t("bj_bot_gold_lbl", bot.gold)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-14 23:28:01 +00:00
|
|
|
if reveal_opponents and bot.hand:
|
2026-11-14 04:25:51 +00:00
|
|
|
b_val, _ = HandEvaluator.evaluate(bot.hand)
|
2026-11-14 23:28:01 +00:00
|
|
|
if bot.folded:
|
|
|
|
|
info_txt = t("bj_rank_folded", b_val)
|
|
|
|
|
elif bot.busted:
|
|
|
|
|
info_txt = t("bj_rank_busted", b_val)
|
|
|
|
|
else:
|
|
|
|
|
info_txt = t("bj_bot_showdown_val", b_val, bot.bet_in_pot)
|
2026-11-14 04:25:51 +00:00
|
|
|
elif bot.status_text:
|
|
|
|
|
info_txt = bot.status_text
|
|
|
|
|
elif bot.hand:
|
|
|
|
|
info_txt = t("bj_bot_cards_hidden", len(bot.hand), bot.bet_in_pot)
|
|
|
|
|
else:
|
|
|
|
|
info_txt = ""
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
info_col = ERROR_FG if is_out else FG_COLOR
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
name_sz = max(14, FONT_SIZE_BODY - 1)
|
|
|
|
|
sub_sz = max(13, FONT_SIZE_BODY - 2)
|
|
|
|
|
name_ph = self._make_goth_photo(disp_name, size_px=name_sz, color=name_col, max_width=220)
|
|
|
|
|
gold_ph = self._make_goth_photo(gold_txt, size_px=sub_sz, color=ACCENT_GOLD)
|
|
|
|
|
info_ph = self._make_goth_photo(info_txt, size_px=sub_sz, color=info_col, max_width=220)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
widest_txt = max(
|
|
|
|
|
(ph.width() for ph in (name_ph, gold_ph, info_ph) if ph is not None),
|
|
|
|
|
default=140,
|
|
|
|
|
)
|
|
|
|
|
box_w = max(base_box_w, min(268, widest_txt + 54))
|
|
|
|
|
|
|
|
|
|
if is_left_side:
|
|
|
|
|
bx = max(pad_x + box_w // 2, tx1 + int(box_w * 0.36))
|
|
|
|
|
else:
|
|
|
|
|
bx = min(cw - pad_x - box_w // 2, tx2 - int(box_w * 0.36))
|
|
|
|
|
|
|
|
|
|
self._draw_framed_panel(
|
|
|
|
|
bx, by, box_w, box_h, frame_style=frame_style, status_border=status_border
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
top_y = by - box_h // 2
|
|
|
|
|
bot_y = by + box_h // 2
|
|
|
|
|
cards_cy = by + 6
|
|
|
|
|
|
|
|
|
|
self._place_goth_photo_or_fallback(bx, top_y + 23, name_ph, disp_name, name_sz, name_col)
|
|
|
|
|
self._place_goth_photo_or_fallback(bx, top_y + 42, gold_ph, gold_txt, sub_sz, ACCENT_GOLD)
|
|
|
|
|
|
|
|
|
|
show_faces = reveal_opponents or bot.busted
|
|
|
|
|
bot_photos = []
|
|
|
|
|
for card in bot.hand:
|
|
|
|
|
photo = (
|
|
|
|
|
self.ctx.assets.get_card_photo(card.image_filename, size=cur_card_sz)
|
|
|
|
|
if show_faces
|
|
|
|
|
else self.ctx.assets.get_card_back_photo(
|
|
|
|
|
color=self.cfg["back_color"], size=cur_card_sz
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
if photo:
|
|
|
|
|
self._photo_refs.append(photo)
|
|
|
|
|
bot_photos.append(photo)
|
|
|
|
|
|
|
|
|
|
if bot_photos:
|
|
|
|
|
self._draw_fanned_cards_on_canvas(
|
|
|
|
|
bx,
|
|
|
|
|
cards_cy,
|
|
|
|
|
bot_photos,
|
|
|
|
|
cur_card_sz,
|
|
|
|
|
visible_step=25,
|
|
|
|
|
max_width=box_w - 36,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self._place_goth_photo_or_fallback(bx, bot_y - 21, info_ph, info_txt, sub_sz, info_col)
|
|
|
|
|
|
|
|
|
|
def _draw_player_below_table(self, cw: int, player_zone_top: int, player_zone_bot: int):
|
|
|
|
|
"""Zeichnet deine eigene Hand am unteren Tischrand mit dynamischer Boxbreite."""
|
2026-11-14 04:25:51 +00:00
|
|
|
hands = self.engine.player_hands
|
|
|
|
|
if not hands:
|
|
|
|
|
return
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
avail_h = max(140, player_zone_bot - player_zone_top)
|
|
|
|
|
zone_cy = (player_zone_top + player_zone_bot) // 2
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
if len(hands) == 1:
|
|
|
|
|
h = hands[0]
|
2026-11-21 01:20:50 +00:00
|
|
|
base_w, base_h = PLAYING_CARD_SIZE
|
|
|
|
|
max_card_h = max(88, min(base_h, avail_h - 52))
|
|
|
|
|
scale = max_card_h / max(1, base_h)
|
|
|
|
|
card_sz = (max(60, int(round(base_w * scale))), int(round(base_h * scale)))
|
|
|
|
|
|
2026-11-16 20:07:01 +00:00
|
|
|
p_photos = []
|
|
|
|
|
for card in h.cards:
|
2026-11-21 01:20:50 +00:00
|
|
|
photo = self.ctx.assets.get_card_photo(card.image_filename, size=card_sz)
|
2026-11-14 04:25:51 +00:00
|
|
|
if photo:
|
|
|
|
|
self._photo_refs.append(photo)
|
2026-11-16 20:07:01 +00:00
|
|
|
p_photos.append(photo)
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
p_val, p_soft = HandEvaluator.evaluate(h.cards)
|
|
|
|
|
soft_hint = t("bj_soft_hint", p_val) if p_soft and p_val < 21 else ""
|
|
|
|
|
suffix = self._hand_state_suffix(h)
|
2026-11-21 01:20:50 +00:00
|
|
|
lbl_txt = t("bj_player_total", p_val, soft_hint, h.bet_in_pot, suffix)
|
|
|
|
|
|
|
|
|
|
is_player_turn = (self.engine.state == "ACTION_LOOP" and self.active_bot_idx == -1)
|
|
|
|
|
is_out = (h.busted or h.folded)
|
|
|
|
|
lbl_col = ERROR_FG if is_out else FONT_COLOR_TITLE_MAIN
|
|
|
|
|
lbl_sz = max(14, FONT_SIZE_BODY - 1)
|
|
|
|
|
lbl_ph = self._make_goth_photo(lbl_txt, size_px=lbl_sz, color=lbl_col)
|
|
|
|
|
|
|
|
|
|
n_cards = max(1, len(p_photos))
|
|
|
|
|
step = 36
|
|
|
|
|
fan_w = card_sz[0] + max(0, n_cards - 1) * step
|
|
|
|
|
txt_w = lbl_ph.width() if lbl_ph is not None else 240
|
|
|
|
|
|
|
|
|
|
box_w = max(300, min(560, max(fan_w + 96, txt_w + 72)))
|
|
|
|
|
box_h = min(avail_h, card_sz[1] + 52)
|
|
|
|
|
|
|
|
|
|
self._draw_framed_panel(
|
|
|
|
|
cw // 2,
|
|
|
|
|
zone_cy,
|
|
|
|
|
box_w,
|
|
|
|
|
box_h,
|
|
|
|
|
frame_style="gold" if is_player_turn and not is_out else "purple",
|
|
|
|
|
status_border=ERROR_FG if is_out else None,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cards_cy = zone_cy - 11
|
|
|
|
|
if p_photos:
|
|
|
|
|
self._draw_fanned_cards_on_canvas(
|
|
|
|
|
cw // 2,
|
|
|
|
|
cards_cy,
|
|
|
|
|
p_photos,
|
|
|
|
|
card_sz,
|
|
|
|
|
visible_step=step,
|
|
|
|
|
max_width=box_w - 44,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self._place_goth_photo_or_fallback(
|
|
|
|
|
cw // 2, zone_cy + box_h // 2 - 20, lbl_ph, lbl_txt, lbl_sz, lbl_col
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
# Split-Hände nebeneinander unten
|
|
|
|
|
base_w, base_h = BJ_SPLIT_CARD_SIZE
|
|
|
|
|
max_card_h = max(80, min(base_h, avail_h - 48))
|
|
|
|
|
scale = max_card_h / max(1, base_h)
|
|
|
|
|
card_sz = (max(54, int(round(base_w * scale))), int(round(base_h * scale)))
|
|
|
|
|
box_h = min(avail_h, card_sz[1] + 48)
|
|
|
|
|
lbl_sz = max(13, FONT_SIZE_BODY - 2)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
prepared_splits = []
|
|
|
|
|
max_box_w = 228
|
2026-11-14 04:25:51 +00:00
|
|
|
for idx, h in enumerate(hands):
|
2026-11-21 01:20:50 +00:00
|
|
|
is_active = (
|
|
|
|
|
self.engine.state == "ACTION_LOOP"
|
|
|
|
|
and self.active_bot_idx == -1
|
|
|
|
|
and idx == self.active_hand_idx
|
|
|
|
|
)
|
|
|
|
|
is_out = (h.busted or h.folded)
|
|
|
|
|
p_val, p_soft = HandEvaluator.evaluate(h.cards)
|
|
|
|
|
soft_hint = t("bj_soft_hint", p_val) if p_soft and p_val < 21 else ""
|
|
|
|
|
suffix = self._hand_state_suffix(h)
|
|
|
|
|
lbl_txt = t("bj_hand_box_title", idx + 1, p_val, soft_hint, h.bet_in_pot, suffix)
|
|
|
|
|
lbl_col = ACCENT_GOLD if is_active else (ERROR_FG if is_out else FG_COLOR)
|
|
|
|
|
lbl_ph = self._make_goth_photo(lbl_txt, size_px=lbl_sz, color=lbl_col)
|
|
|
|
|
txt_w = lbl_ph.width() if lbl_ph is not None else 180
|
|
|
|
|
sp_fan_w = card_sz[0] + max(0, len(h.cards) - 1) * 28
|
|
|
|
|
req_w = max(228, min(320, max(sp_fan_w + 64, txt_w + 60)))
|
|
|
|
|
max_box_w = max(max_box_w, req_w)
|
|
|
|
|
prepared_splits.append((idx, h, is_active, is_out, lbl_txt, lbl_col, lbl_ph))
|
|
|
|
|
|
|
|
|
|
n_hands = len(hands)
|
|
|
|
|
slot_gap = max(max_box_w + 14, min(310, (cw - 360) // max(1, n_hands)))
|
|
|
|
|
start_cx = cw // 2 - ((n_hands - 1) * slot_gap) // 2
|
|
|
|
|
|
|
|
|
|
for idx, h, is_active, is_out, lbl_txt, lbl_col, lbl_ph in prepared_splits:
|
|
|
|
|
h_cx = start_cx + idx * slot_gap
|
|
|
|
|
self._draw_framed_panel(
|
|
|
|
|
h_cx,
|
|
|
|
|
zone_cy,
|
|
|
|
|
max_box_w,
|
|
|
|
|
box_h,
|
|
|
|
|
frame_style="gold" if is_active else "purple",
|
|
|
|
|
status_border=ERROR_FG if is_out else None,
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
|
2026-11-16 20:07:01 +00:00
|
|
|
sp_photos = []
|
|
|
|
|
for card in h.cards:
|
2026-11-21 01:20:50 +00:00
|
|
|
photo = self.ctx.assets.get_card_photo(card.image_filename, size=card_sz)
|
2026-11-14 04:25:51 +00:00
|
|
|
if photo:
|
|
|
|
|
self._photo_refs.append(photo)
|
2026-11-16 20:07:01 +00:00
|
|
|
sp_photos.append(photo)
|
|
|
|
|
|
|
|
|
|
if sp_photos:
|
2026-11-21 01:20:50 +00:00
|
|
|
self._draw_fanned_cards_on_canvas(
|
|
|
|
|
h_cx,
|
|
|
|
|
zone_cy - 10,
|
|
|
|
|
sp_photos,
|
|
|
|
|
card_sz,
|
|
|
|
|
visible_step=28,
|
|
|
|
|
max_width=max_box_w - 36,
|
2026-11-16 20:07:01 +00:00
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
self._place_goth_photo_or_fallback(
|
|
|
|
|
h_cx, zone_cy + box_h // 2 - 18, lbl_ph, lbl_txt, lbl_sz, lbl_col
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
def _render_table(self, reveal_opponents: bool, reveal_dealer: bool):
|
2026-11-21 01:20:50 +00:00
|
|
|
self._last_reveal_state = (reveal_opponents, reveal_dealer)
|
|
|
|
|
if not self._canvas_alive():
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
cw = max(760, self.arena_canvas.winfo_width())
|
|
|
|
|
ch = max(460, self.arena_canvas.winfo_height())
|
|
|
|
|
|
|
|
|
|
bg_ids = set(self.arena_canvas.find_withtag("table_bg_slice"))
|
|
|
|
|
for item_id in self.arena_canvas.find_all():
|
|
|
|
|
if item_id not in bg_ids:
|
|
|
|
|
self.arena_canvas.delete(item_id)
|
2026-11-14 04:25:51 +00:00
|
|
|
self._photo_refs.clear()
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
self._bg_renderer.draw_on_canvas(self.arena_canvas, cw, ch)
|
|
|
|
|
|
|
|
|
|
pad_x = max(24, int(cw * 0.022))
|
|
|
|
|
pad_top = 6
|
|
|
|
|
pad_bot = 6
|
|
|
|
|
|
|
|
|
|
player_zone_h = max(152, min(174, int(ch * 0.31)))
|
|
|
|
|
player_zone_bot = ch - pad_bot
|
|
|
|
|
player_zone_top = player_zone_bot - player_zone_h
|
|
|
|
|
|
|
|
|
|
table_top = pad_top
|
|
|
|
|
table_bot = min(ch - pad_bot - 60, player_zone_top + 64)
|
|
|
|
|
table_h = max(280, table_bot - table_top)
|
|
|
|
|
table_w = max(680, cw - 2 * pad_x - 90)
|
|
|
|
|
table_cx = cw // 2
|
|
|
|
|
table_cy = table_top + table_h // 2
|
|
|
|
|
table_rect = (
|
|
|
|
|
table_cx - table_w // 2,
|
|
|
|
|
table_top,
|
|
|
|
|
table_cx + table_w // 2,
|
|
|
|
|
table_top + table_h,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tbl_photo = self._get_stretched_table_photo(table_w, table_h)
|
|
|
|
|
if tbl_photo is not None:
|
|
|
|
|
self.arena_canvas.create_image(
|
|
|
|
|
table_cx, table_cy, image=tbl_photo, anchor="center", tags="fg"
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
2026-11-21 01:20:50 +00:00
|
|
|
else:
|
|
|
|
|
self.arena_canvas.create_oval(
|
|
|
|
|
table_rect[0], table_rect[1], table_rect[2], table_rect[3],
|
|
|
|
|
fill="#14111b", outline=BORDER_COLOR, width=3, tags="fg",
|
2026-11-16 20:07:01 +00:00
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
self._draw_dealer_and_pot_inside_table(table_rect, player_zone_top, reveal_dealer)
|
|
|
|
|
self._draw_bots_at_table_corners(
|
|
|
|
|
cw, ch, pad_x, pad_top, pad_bot, table_rect, reveal_opponents
|
|
|
|
|
)
|
|
|
|
|
self._draw_player_below_table(cw, player_zone_top, player_zone_bot)
|
2026-11-14 04:25:51 +00:00
|
|
|
self._refresh_header()
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------
|
2026-11-21 01:20:50 +00:00
|
|
|
# TISCH-UMLAUF LOGIK & HOVER-HILFE AUF ALLEN AKTIONEN
|
2026-11-14 04:25:51 +00:00
|
|
|
# ---------------------------------------------------------
|
2026-11-14 05:46:46 +00:00
|
|
|
def _begin_new_table_cycle(self):
|
|
|
|
|
if not self.engine.any_contender_alive(self.bots):
|
2026-11-14 04:25:51 +00:00
|
|
|
self._start_showdown_and_dealer()
|
|
|
|
|
return
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
self.engine.cycle_card_drawn = False
|
|
|
|
|
self.settle_only_mode = False
|
2026-11-14 04:25:51 +00:00
|
|
|
self.active_bot_idx = -1
|
|
|
|
|
self.active_hand_idx = 0
|
|
|
|
|
self._step_next_player_hand()
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
def _begin_settle_bets_pass(self):
|
|
|
|
|
self.settle_only_mode = True
|
|
|
|
|
self.active_bot_idx = -1
|
|
|
|
|
self.active_hand_idx = 0
|
|
|
|
|
self._step_next_player_hand()
|
|
|
|
|
|
|
|
|
|
def _on_table_pass_completed(self):
|
|
|
|
|
if not self.engine.any_contender_alive(self.bots):
|
|
|
|
|
self._start_showdown_and_dealer()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
|
|
|
|
wallet = self.bj_account["gold"]
|
|
|
|
|
|
|
|
|
|
if self.settle_only_mode:
|
|
|
|
|
self._start_showdown_and_dealer()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if not self.engine.cycle_card_drawn:
|
|
|
|
|
if self.engine.has_unsettled_bets(self.bots, wallet):
|
|
|
|
|
self._begin_settle_bets_pass()
|
|
|
|
|
else:
|
|
|
|
|
self._start_showdown_and_dealer()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._begin_new_table_cycle()
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
def _step_next_player_hand(self):
|
|
|
|
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
|
|
|
|
wallet = self.bj_account["gold"]
|
|
|
|
|
|
|
|
|
|
while self.active_hand_idx < len(self.engine.player_hands):
|
|
|
|
|
h = self.engine.player_hands[self.active_hand_idx]
|
2026-11-14 05:46:46 +00:00
|
|
|
if not h.is_active_in_pot:
|
|
|
|
|
self.active_hand_idx += 1
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
raw_deficit = max(0, self.engine.highest_bet - h.bet_in_pot)
|
|
|
|
|
to_call = min(wallet, raw_deficit)
|
|
|
|
|
|
|
|
|
|
if self.settle_only_mode:
|
|
|
|
|
if to_call > 0:
|
|
|
|
|
self.turn_step = STEP_MITGEHEN
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 05:46:46 +00:00
|
|
|
return
|
|
|
|
|
self.active_hand_idx += 1
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if to_call > 0:
|
2026-11-14 04:25:51 +00:00
|
|
|
self.turn_step = STEP_MITGEHEN
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
2026-11-14 05:46:46 +00:00
|
|
|
|
|
|
|
|
h_val, _ = HandEvaluator.evaluate(h.cards)
|
|
|
|
|
if not h.cards_locked and not h.doubled and h_val < 21:
|
|
|
|
|
self.turn_step = STEP_ZIEHEN
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 05:46:46 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
dyn_chips = self._get_current_level_chips()
|
|
|
|
|
if wallet >= dyn_chips[0]:
|
|
|
|
|
self.turn_step = STEP_ERHOEHEN
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 05:46:46 +00:00
|
|
|
return
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
self.active_hand_idx += 1
|
|
|
|
|
|
|
|
|
|
self._start_bots_cycle()
|
|
|
|
|
|
|
|
|
|
def _finish_current_hand_turn(self):
|
|
|
|
|
self.active_hand_idx += 1
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._step_next_player_hand()
|
|
|
|
|
|
|
|
|
|
def _render_current_tree_step(self):
|
|
|
|
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
|
|
|
|
wallet = self.bj_account["gold"]
|
|
|
|
|
hand = self.engine.player_hands[self.active_hand_idx]
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
btn_norm = self.ctx.assets.raw_btn_default
|
|
|
|
|
btn_purp = self.ctx.assets.raw_btn_purple
|
|
|
|
|
btn_fire = self.ctx.assets.raw_btn_fire or btn_purp
|
|
|
|
|
|
|
|
|
|
primary_btns: list[ImageButton] = []
|
|
|
|
|
overflow_btns: list[ImageButton] = []
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
if self.turn_step == STEP_MITGEHEN:
|
|
|
|
|
raw_deficit = max(0, self.engine.highest_bet - hand.bet_in_pot)
|
|
|
|
|
to_call = min(wallet, raw_deficit)
|
2026-11-15 23:22:24 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
primary_btns.append(
|
|
|
|
|
ImageButton(
|
|
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_tree_btn_call_yes", to_call),
|
|
|
|
|
btn_fire,
|
|
|
|
|
btn_fire,
|
|
|
|
|
lambda: self._on_step1_call_yes(to_call),
|
|
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=162,
|
|
|
|
|
height=30,
|
|
|
|
|
style="fire",
|
|
|
|
|
hover_text=lambda: t("bj_tip_call_yes"),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
overflow_btns.append(
|
|
|
|
|
ImageButton(
|
|
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_tree_btn_call_no_lose"),
|
|
|
|
|
btn_norm,
|
|
|
|
|
btn_purp,
|
|
|
|
|
self._on_fold_hand,
|
|
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=162,
|
|
|
|
|
height=30,
|
|
|
|
|
style="amethyst",
|
|
|
|
|
hover_text=lambda: t("bj_tip_fold"),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
self._set_bottom_buttons(primary_btns, overflow_buttons=overflow_btns)
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if self.turn_step == STEP_ZIEHEN:
|
2026-11-21 01:20:50 +00:00
|
|
|
primary_btns.append(
|
|
|
|
|
ImageButton(
|
|
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_tree_btn_draw_yes"),
|
|
|
|
|
btn_fire,
|
|
|
|
|
btn_fire,
|
|
|
|
|
self._on_step2_draw_yes,
|
|
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=138,
|
|
|
|
|
height=30,
|
|
|
|
|
style="fire",
|
|
|
|
|
hover_text=lambda: t("bj_tip_draw_yes"),
|
|
|
|
|
)
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
if self.engine.can_double_down(self.active_hand_idx, wallet):
|
2026-11-14 04:25:51 +00:00
|
|
|
dd_cost = self.engine.get_double_down_cost(self.active_hand_idx)
|
2026-11-21 01:20:50 +00:00
|
|
|
primary_btns.append(
|
|
|
|
|
ImageButton(
|
|
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_double_btn", dd_cost),
|
|
|
|
|
btn_norm,
|
|
|
|
|
btn_purp,
|
|
|
|
|
self._on_step2_double_down,
|
|
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=132,
|
|
|
|
|
height=30,
|
|
|
|
|
style="amethyst",
|
|
|
|
|
hover_text=lambda: t("bj_tip_double"),
|
|
|
|
|
)
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
if self.engine.can_split_hand(self.active_hand_idx, wallet):
|
|
|
|
|
sp_cost = self.engine.highest_bet
|
2026-11-21 01:20:50 +00:00
|
|
|
primary_btns.append(
|
|
|
|
|
ImageButton(
|
|
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_split_btn", sp_cost),
|
|
|
|
|
btn_norm,
|
|
|
|
|
btn_purp,
|
|
|
|
|
self._on_step2_split,
|
|
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=124,
|
|
|
|
|
height=30,
|
|
|
|
|
style="amethyst",
|
|
|
|
|
hover_text=lambda: t("bj_tip_split"),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
overflow_btns.append(
|
2026-11-14 04:25:51 +00:00
|
|
|
ImageButton(
|
2026-11-21 01:20:50 +00:00
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_tree_btn_draw_no"),
|
|
|
|
|
btn_norm,
|
|
|
|
|
btn_purp,
|
|
|
|
|
self._on_step2_draw_no,
|
|
|
|
|
sound_mgr=None,
|
|
|
|
|
width=134,
|
|
|
|
|
height=30,
|
|
|
|
|
style="amethyst",
|
|
|
|
|
hover_text=lambda: t("bj_tip_draw_no"),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
overflow_btns.append(
|
|
|
|
|
ImageButton(
|
|
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_fold_btn"),
|
|
|
|
|
btn_norm,
|
|
|
|
|
btn_purp,
|
|
|
|
|
self._on_fold_hand,
|
|
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=110,
|
|
|
|
|
height=30,
|
|
|
|
|
style="amethyst",
|
|
|
|
|
hover_text=lambda: t("bj_tip_fold"),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
self._set_bottom_buttons(primary_btns, overflow_buttons=overflow_btns)
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if self.turn_step == STEP_ERHOEHEN:
|
|
|
|
|
dyn_chips = self._get_current_level_chips()
|
2026-11-16 20:07:01 +00:00
|
|
|
avail_chips = [c for c in dyn_chips if wallet >= c]
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
for chip in avail_chips:
|
|
|
|
|
primary_btns.append(
|
2026-11-14 04:25:51 +00:00
|
|
|
ImageButton(
|
2026-11-21 01:20:50 +00:00
|
|
|
self.bottom_bar,
|
|
|
|
|
f"+{chip}g",
|
|
|
|
|
btn_fire,
|
|
|
|
|
btn_fire,
|
2026-11-14 04:25:51 +00:00
|
|
|
lambda c=chip: self._on_step3_raise_yes(c),
|
2026-11-21 01:20:50 +00:00
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=76,
|
|
|
|
|
height=30,
|
|
|
|
|
style="fire",
|
|
|
|
|
hover_text=lambda: t("bj_tip_raise_chip"),
|
|
|
|
|
)
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
overflow_btns.append(
|
|
|
|
|
ImageButton(
|
|
|
|
|
self.bottom_bar,
|
|
|
|
|
t("bj_tree_btn_raise_no"),
|
|
|
|
|
btn_norm,
|
|
|
|
|
btn_purp,
|
|
|
|
|
self._on_step3_raise_no,
|
|
|
|
|
sound_mgr=self.ctx.sounds,
|
|
|
|
|
width=162,
|
|
|
|
|
height=30,
|
|
|
|
|
style="amethyst",
|
|
|
|
|
hover_text=lambda: t("bj_tip_raise_no"),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
self._set_bottom_buttons(primary_btns, overflow_buttons=overflow_btns)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
# ---------------------------------------------------------
|
2026-11-14 05:46:46 +00:00
|
|
|
# BUTTON-AKTIONEN SPIELER
|
2026-11-14 04:25:51 +00:00
|
|
|
# ---------------------------------------------------------
|
2026-11-14 05:46:46 +00:00
|
|
|
def _advance_to_erhoehen_or_next(self):
|
2026-11-14 04:25:51 +00:00
|
|
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
|
|
|
|
wallet = self.bj_account["gold"]
|
|
|
|
|
dyn_chips = self._get_current_level_chips()
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
if not self.bots and not self.engine.cycle_card_drawn:
|
|
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if wallet >= dyn_chips[0]:
|
2026-11-14 04:25:51 +00:00
|
|
|
self.turn_step = STEP_ERHOEHEN
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 04:25:51 +00:00
|
|
|
else:
|
|
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
def _on_step1_call_yes(self, to_call: int):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
if to_call > 0:
|
|
|
|
|
paid = self.engine.player_add_gold_to_pot(self.active_hand_idx, to_call)
|
|
|
|
|
if paid > 0:
|
|
|
|
|
self.bj_account = Database.update_blackjack_gold(self.bj_account["id"], -paid)
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
if self.settle_only_mode:
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 05:46:46 +00:00
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
hand = self.engine.player_hands[self.active_hand_idx]
|
|
|
|
|
h_val, _ = HandEvaluator.evaluate(hand.cards)
|
|
|
|
|
if not hand.cards_locked and not hand.doubled and h_val < 21:
|
2026-11-14 04:25:51 +00:00
|
|
|
self.turn_step = STEP_ZIEHEN
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 04:25:51 +00:00
|
|
|
else:
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 05:46:46 +00:00
|
|
|
self._advance_to_erhoehen_or_next()
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
def _on_fold_hand(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
hand = self.engine.player_hands[self.active_hand_idx]
|
|
|
|
|
hand.folded = True
|
|
|
|
|
hand.cards_locked = True
|
|
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
|
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
|
|
|
|
|
def _on_step2_draw_yes(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
hand = self.engine.player_hands[self.active_hand_idx]
|
|
|
|
|
self.engine.player_draw_card(self.active_hand_idx)
|
|
|
|
|
|
|
|
|
|
if HandEvaluator.is_triple_seven(hand.cards):
|
|
|
|
|
self._trigger_instant_777_win(winner_is_player=True, winning_bot=None)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
|
|
|
|
if hand.busted:
|
|
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
return
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
self._advance_to_erhoehen_or_next()
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
def _on_step2_draw_no(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 05:46:46 +00:00
|
|
|
self.ctx.sounds.play("stand")
|
|
|
|
|
self._advance_to_erhoehen_or_next()
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
def _on_step2_double_down(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
paid, _card = self.engine.double_down_player_hand(self.active_hand_idx)
|
|
|
|
|
if paid > 0:
|
|
|
|
|
self.bj_account = Database.update_blackjack_gold(self.bj_account["id"], -paid)
|
|
|
|
|
|
|
|
|
|
hand = self.engine.player_hands[self.active_hand_idx]
|
|
|
|
|
if HandEvaluator.is_triple_seven(hand.cards):
|
|
|
|
|
self._trigger_instant_777_win(winner_is_player=True, winning_bot=None)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
|
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
|
|
|
|
|
def _on_step2_split(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
paid = self.engine.split_player_hand()
|
|
|
|
|
if paid > 0:
|
|
|
|
|
self.bj_account = Database.update_blackjack_gold(self.bj_account["id"], -paid)
|
|
|
|
|
self.active_hand_idx = 0
|
|
|
|
|
self.turn_step = STEP_ZIEHEN
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_current_tree_step()
|
2026-11-21 01:20:50 +00:00
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
def _on_step3_raise_yes(self, chip_amount: int):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
paid = self.engine.player_add_gold_to_pot(self.active_hand_idx, chip_amount)
|
|
|
|
|
if paid > 0:
|
|
|
|
|
self.bj_account = Database.update_blackjack_gold(self.bj_account["id"], -paid)
|
|
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
|
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
|
|
|
|
|
def _on_step3_raise_no(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
ImageButton.close_active_hover_tip()
|
2026-11-14 04:25:51 +00:00
|
|
|
self._finish_current_hand_turn()
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------
|
2026-11-14 05:46:46 +00:00
|
|
|
# BOT-ZYKLUS IM UMLAUF
|
2026-11-14 04:25:51 +00:00
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
def _start_bots_cycle(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
self._set_bottom_buttons([])
|
2026-11-14 04:25:51 +00:00
|
|
|
if not self.bots or not self.engine.any_contender_alive(self.bots):
|
2026-11-14 05:46:46 +00:00
|
|
|
self._on_table_pass_completed()
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
self.active_bot_idx = 0
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._step_next_bot()
|
|
|
|
|
|
|
|
|
|
def _step_next_bot(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
if not self._canvas_alive():
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
while self.active_bot_idx < len(self.bots):
|
|
|
|
|
bot = self.bots[self.active_bot_idx]
|
2026-11-14 05:46:46 +00:00
|
|
|
if bot.is_active_in_pot:
|
|
|
|
|
if not self.settle_only_mode:
|
|
|
|
|
break
|
|
|
|
|
if bot.gold > 0 and bot.bet_in_pot < self.engine.highest_bet:
|
|
|
|
|
break
|
2026-11-14 04:25:51 +00:00
|
|
|
self.active_bot_idx += 1
|
|
|
|
|
|
|
|
|
|
if self.active_bot_idx >= len(self.bots):
|
|
|
|
|
self.active_bot_idx = -1
|
|
|
|
|
self._persist_state()
|
2026-11-14 05:46:46 +00:00
|
|
|
self._on_table_pass_completed()
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
bot = self.bots[self.active_bot_idx]
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
2026-11-21 01:20:50 +00:00
|
|
|
self._turn_job = self.ctx.root.after(
|
|
|
|
|
BJ_BOT_TURN_DELAY_MS, lambda: self._execute_bot_action(bot)
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
def _execute_bot_action(self, bot: BlackjackBotSeat):
|
2026-11-21 01:20:50 +00:00
|
|
|
if not self._canvas_alive():
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
upcard = self.engine.dealer_hand[0]
|
|
|
|
|
dyn_chips = self._get_current_level_chips()
|
|
|
|
|
raw_deficit = max(0, self.engine.highest_bet - bot.bet_in_pot)
|
|
|
|
|
to_call = min(bot.gold, raw_deficit)
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
if to_call > 0:
|
|
|
|
|
if not self.bot_ai.decide_step1_mitgehen(
|
|
|
|
|
bot, self.engine.highest_bet, upcard, self.engine.deck.remaining()
|
|
|
|
|
):
|
2026-11-14 04:25:51 +00:00
|
|
|
bot.folded = True
|
|
|
|
|
bot.cards_locked = True
|
|
|
|
|
bot.status_text = t("bj_bot_action_fold")
|
2026-11-14 05:46:46 +00:00
|
|
|
self._finish_bot_step()
|
|
|
|
|
return
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
self.ctx.sounds.play("click")
|
|
|
|
|
self.engine.bot_add_gold_to_pot(bot, to_call)
|
|
|
|
|
|
2026-11-14 05:46:46 +00:00
|
|
|
if self.settle_only_mode:
|
|
|
|
|
bot.status_text = t("bj_bot_action_call", to_call)
|
|
|
|
|
self._finish_bot_step()
|
|
|
|
|
return
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
drew_card = False
|
2026-11-14 05:46:46 +00:00
|
|
|
if not bot.cards_locked and not bot.doubled:
|
2026-11-21 01:20:50 +00:00
|
|
|
if self.bot_ai.wants_double_down(
|
|
|
|
|
bot, upcard, self.engine.highest_bet, self.engine.deck.remaining()
|
|
|
|
|
):
|
2026-11-14 04:25:51 +00:00
|
|
|
dd_cost = max(self.engine.highest_bet, bot.bet_in_pot) * 2 - bot.bet_in_pot
|
|
|
|
|
paid = self.engine.bot_add_gold_to_pot(bot, dd_cost)
|
|
|
|
|
self.ctx.sounds.play("click")
|
|
|
|
|
self.engine.bot_draw_card(bot)
|
|
|
|
|
bot.doubled = True
|
|
|
|
|
bot.cards_locked = True
|
|
|
|
|
|
|
|
|
|
if HandEvaluator.is_triple_seven(bot.hand):
|
|
|
|
|
self._trigger_instant_777_win(winner_is_player=False, winning_bot=bot)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if bot.busted:
|
|
|
|
|
b_val, _ = HandEvaluator.evaluate(bot.hand)
|
|
|
|
|
bot.status_text = t("bj_bot_action_bust", b_val)
|
|
|
|
|
else:
|
|
|
|
|
bot.status_text = t("bj_bot_action_double", paid)
|
|
|
|
|
self._finish_bot_step()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if self.bot_ai.decide_step2_ziehen(bot, upcard, self.engine.deck.remaining()):
|
|
|
|
|
self.ctx.sounds.play("click")
|
|
|
|
|
self.engine.bot_draw_card(bot)
|
|
|
|
|
drew_card = True
|
|
|
|
|
|
|
|
|
|
if HandEvaluator.is_triple_seven(bot.hand):
|
|
|
|
|
self._trigger_instant_777_win(winner_is_player=False, winning_bot=bot)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if bot.busted:
|
|
|
|
|
b_val, _ = HandEvaluator.evaluate(bot.hand)
|
|
|
|
|
bot.status_text = t("bj_bot_action_bust", b_val)
|
|
|
|
|
self._finish_bot_step()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
raise_amt = self.bot_ai.decide_step3_erhoehen(
|
2026-11-14 05:46:46 +00:00
|
|
|
bot, dyn_chips, self.engine.deck.remaining(), upcard
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
if raise_amt > 0:
|
|
|
|
|
self.ctx.sounds.play("click")
|
|
|
|
|
self.engine.bot_add_gold_to_pot(bot, raise_amt)
|
|
|
|
|
bot.status_text = t("bj_bot_action_bet", raise_amt)
|
2026-11-14 05:46:46 +00:00
|
|
|
elif drew_card:
|
|
|
|
|
bot.status_text = t("bj_bot_action_hit", len(bot.hand))
|
|
|
|
|
elif to_call > 0:
|
|
|
|
|
bot.status_text = t("bj_bot_action_call", to_call)
|
2026-11-14 04:25:51 +00:00
|
|
|
else:
|
2026-11-14 05:46:46 +00:00
|
|
|
bot.status_text = t("bj_bot_action_ready", len(bot.hand))
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
self._finish_bot_step()
|
|
|
|
|
|
|
|
|
|
def _finish_bot_step(self):
|
|
|
|
|
self.active_bot_idx += 1
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_table(reveal_opponents=False, reveal_dealer=False)
|
|
|
|
|
self._turn_job = self.ctx.root.after(BJ_BOT_TURN_DELAY_MS, self._step_next_bot)
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
# SHOWDOWN, HAUS-DEALER & ERGEBNIS-POPUP
|
|
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
def _resolve_devils_lock_after_outcome(self, outcome_type: str):
|
|
|
|
|
if not self.devils_locked:
|
|
|
|
|
self._clear_persisted_state()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
updated_acc = Database.get_blackjack_account(self.bj_account["id"])
|
2026-11-21 01:20:50 +00:00
|
|
|
still_only_ten_from_tie = (
|
|
|
|
|
outcome_type == "TIE" and updated_acc["gold"] == GOLD_MIN_TABLE_ENTRY
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
if not still_only_ten_from_tie:
|
|
|
|
|
Database.set_bj_devils_deal_active(self.bj_account["id"], False)
|
|
|
|
|
self.devils_locked = False
|
|
|
|
|
self._clear_persisted_state()
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
def _award_xp_and_record(
|
|
|
|
|
self, outcome_type: str, won_stat: bool | None
|
|
|
|
|
) -> tuple[int, int | None]:
|
2026-11-14 04:25:51 +00:00
|
|
|
duration = max(0.5, time.time() - self.round_start_time)
|
|
|
|
|
prog_before = self.ctx.refresh_game_progress()
|
|
|
|
|
opp_levels = [b.ai_level for b in self.bots]
|
|
|
|
|
|
|
|
|
|
xp_gained = Progression.calculate_match_xp(
|
|
|
|
|
player_level=prog_before["level"],
|
|
|
|
|
opponent_levels=opp_levels,
|
|
|
|
|
outcome_type=outcome_type,
|
|
|
|
|
variant_mult=self.cfg["xp_mult"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if won_stat is None:
|
|
|
|
|
Database.add_game_points(self.ctx.profile["id"], GAME_FOLDER_ID, xp_gained)
|
|
|
|
|
prog_after = self.ctx.refresh_game_progress()
|
|
|
|
|
self.ctx.sounds.play("end_battle")
|
2026-11-21 01:20:50 +00:00
|
|
|
new_lvl = (
|
|
|
|
|
prog_after["level"]
|
|
|
|
|
if prog_after["level"] > prog_before["level"]
|
|
|
|
|
else None
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
return xp_gained, new_lvl
|
|
|
|
|
|
|
|
|
|
old_lvl, new_lvl = self.ctx.record_result(
|
2026-11-21 01:20:50 +00:00
|
|
|
self.variant_key,
|
|
|
|
|
won=won_stat,
|
|
|
|
|
duration_sec=duration,
|
|
|
|
|
points_gained=xp_gained,
|
|
|
|
|
bj_account_id=self.bj_account["id"],
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
return xp_gained, (new_lvl if new_lvl > old_lvl else None)
|
|
|
|
|
|
2026-11-14 23:28:01 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def _format_hand_rank_label(
|
|
|
|
|
cards, is_split: bool = False, busted: bool = False, folded: bool = False
|
|
|
|
|
) -> str:
|
|
|
|
|
val, _ = HandEvaluator.evaluate(cards)
|
|
|
|
|
if folded:
|
|
|
|
|
return t("bj_rank_folded", val)
|
|
|
|
|
if busted or val > 21:
|
|
|
|
|
return t("bj_rank_busted", val)
|
|
|
|
|
if HandEvaluator.is_triple_seven(cards):
|
|
|
|
|
return t("bj_rank_777")
|
|
|
|
|
if not is_split and HandEvaluator.is_natural_blackjack(cards):
|
|
|
|
|
return t("bj_rank_natural_bj")
|
|
|
|
|
if val == 21:
|
|
|
|
|
return t("bj_rank_split_21") if is_split else t("bj_rank_multi_21", len(cards))
|
|
|
|
|
return t("bj_rank_points", val, len(cards))
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
def _collect_showdown_snapshot(
|
|
|
|
|
self, instant_777_winner: str | None = None
|
|
|
|
|
) -> list[dict]:
|
2026-11-14 23:28:01 +00:00
|
|
|
snapshot: list[dict] = []
|
|
|
|
|
|
|
|
|
|
d_cards = self.engine.dealer_hand
|
|
|
|
|
d_val, _ = HandEvaluator.evaluate(d_cards)
|
|
|
|
|
d_rank = self.engine._hand_rank(d_cards)
|
|
|
|
|
snapshot.append({
|
|
|
|
|
"role": "DEALER",
|
|
|
|
|
"name": "",
|
|
|
|
|
"hand_no": 0,
|
|
|
|
|
"card_images": [c.image_filename for c in d_cards],
|
|
|
|
|
"cards_raw": [[c.suit, c.rank] for c in d_cards],
|
|
|
|
|
"is_split": False,
|
|
|
|
|
"busted": d_val > 21,
|
|
|
|
|
"folded": False,
|
|
|
|
|
"rank_tuple": list(d_rank),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
multi_p = len(self.engine.player_hands) > 1
|
|
|
|
|
for idx, h in enumerate(self.engine.player_hands):
|
2026-11-21 01:20:50 +00:00
|
|
|
hr = (
|
|
|
|
|
self.engine._hand_rank(h.cards, is_split=h.is_split_hand)
|
|
|
|
|
if h.is_active_in_pot
|
|
|
|
|
else (0, 0)
|
|
|
|
|
)
|
2026-11-14 23:28:01 +00:00
|
|
|
snapshot.append({
|
|
|
|
|
"role": "PLAYER",
|
|
|
|
|
"name": "",
|
|
|
|
|
"hand_no": (idx + 1) if multi_p else 0,
|
|
|
|
|
"card_images": [c.image_filename for c in h.cards],
|
|
|
|
|
"cards_raw": [[c.suit, c.rank] for c in h.cards],
|
|
|
|
|
"is_split": h.is_split_hand,
|
|
|
|
|
"busted": h.busted,
|
|
|
|
|
"folded": h.folded,
|
|
|
|
|
"rank_tuple": list(hr),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
for b in self.bots:
|
|
|
|
|
br = self.engine._hand_rank(b.hand) if b.is_active_in_pot else (0, 0)
|
|
|
|
|
snapshot.append({
|
|
|
|
|
"role": "BOT",
|
|
|
|
|
"name": b.name,
|
|
|
|
|
"hand_no": 0,
|
|
|
|
|
"card_images": [c.image_filename for c in b.hand],
|
|
|
|
|
"cards_raw": [[c.suit, c.rank] for c in b.hand],
|
|
|
|
|
"is_split": False,
|
|
|
|
|
"busted": b.busted,
|
|
|
|
|
"folded": b.folded,
|
|
|
|
|
"rank_tuple": list(br),
|
|
|
|
|
})
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
contenders = [
|
|
|
|
|
s for s in snapshot
|
|
|
|
|
if s["role"] != "DEALER" and not s["busted"] and not s["folded"]
|
|
|
|
|
]
|
2026-11-14 23:28:01 +00:00
|
|
|
dealer_entry = snapshot[0]
|
|
|
|
|
|
|
|
|
|
if instant_777_winner is not None:
|
|
|
|
|
for s in snapshot:
|
2026-11-21 01:20:50 +00:00
|
|
|
if (
|
|
|
|
|
instant_777_winner == "PLAYER"
|
|
|
|
|
and s["role"] == "PLAYER"
|
|
|
|
|
and s["rank_tuple"] == [3, 21]
|
|
|
|
|
):
|
2026-11-14 23:28:01 +00:00
|
|
|
s["is_winner"] = True
|
2026-11-21 01:20:50 +00:00
|
|
|
elif (
|
|
|
|
|
s["role"] == "BOT"
|
|
|
|
|
and s["name"] == instant_777_winner
|
|
|
|
|
and s["rank_tuple"] == [3, 21]
|
|
|
|
|
):
|
2026-11-14 23:28:01 +00:00
|
|
|
s["is_winner"] = True
|
|
|
|
|
else:
|
|
|
|
|
s["is_winner"] = False
|
|
|
|
|
return snapshot
|
|
|
|
|
|
|
|
|
|
if not contenders:
|
|
|
|
|
dealer_entry["is_winner"] = True
|
|
|
|
|
for s in snapshot[1:]:
|
|
|
|
|
s["is_winner"] = False
|
|
|
|
|
return snapshot
|
|
|
|
|
|
|
|
|
|
best_contender = max(tuple(s["rank_tuple"]) for s in contenders)
|
|
|
|
|
d_rnk = tuple(dealer_entry["rank_tuple"])
|
|
|
|
|
|
|
|
|
|
if d_rnk > best_contender:
|
|
|
|
|
dealer_entry["is_winner"] = True
|
|
|
|
|
for s in snapshot[1:]:
|
|
|
|
|
s["is_winner"] = False
|
|
|
|
|
elif d_rnk == best_contender:
|
|
|
|
|
dealer_entry["is_winner"] = True
|
|
|
|
|
for s in snapshot[1:]:
|
2026-11-21 01:20:50 +00:00
|
|
|
s["is_winner"] = (
|
|
|
|
|
not s["busted"]
|
|
|
|
|
and not s["folded"]
|
|
|
|
|
and tuple(s["rank_tuple"]) == best_contender
|
|
|
|
|
)
|
2026-11-14 23:28:01 +00:00
|
|
|
else:
|
|
|
|
|
dealer_entry["is_winner"] = False
|
|
|
|
|
for s in snapshot[1:]:
|
2026-11-21 01:20:50 +00:00
|
|
|
s["is_winner"] = (
|
|
|
|
|
not s["busted"]
|
|
|
|
|
and not s["folded"]
|
|
|
|
|
and tuple(s["rank_tuple"]) == best_contender
|
|
|
|
|
)
|
2026-11-14 23:28:01 +00:00
|
|
|
|
|
|
|
|
return snapshot
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
def _trigger_instant_777_win(
|
|
|
|
|
self, winner_is_player: bool, winning_bot: BlackjackBotSeat | None
|
|
|
|
|
):
|
2026-11-14 04:25:51 +00:00
|
|
|
self.engine.state = "SHOWDOWN"
|
|
|
|
|
self._count_all_table_cards()
|
|
|
|
|
pot_total = self.engine.pot
|
|
|
|
|
total_p_bet = self.engine.total_player_bet
|
2026-11-14 23:28:01 +00:00
|
|
|
snap = self._collect_showdown_snapshot(
|
|
|
|
|
instant_777_winner="PLAYER" if winner_is_player else winning_bot.name
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
if winner_is_player:
|
|
|
|
|
payout = pot_total + (total_p_bet if not self.bots else 0)
|
|
|
|
|
net = payout - total_p_bet
|
|
|
|
|
self.bj_account = Database.update_blackjack_gold(self.bj_account["id"], payout)
|
|
|
|
|
xp, leveled_to = self._award_xp_and_record("WIN_777", won_stat=True)
|
|
|
|
|
self._resolve_devils_lock_after_outcome("WIN_777")
|
|
|
|
|
payload = {
|
|
|
|
|
"winner_type": "PLAYER",
|
|
|
|
|
"winner_names": [],
|
2026-11-14 23:28:01 +00:00
|
|
|
"instant_777": "PLAYER",
|
2026-11-14 04:25:51 +00:00
|
|
|
"player_won": True,
|
|
|
|
|
"player_net": net,
|
|
|
|
|
"bank_gain": 0,
|
|
|
|
|
"bot_gains": [],
|
|
|
|
|
"xp_gained": xp,
|
|
|
|
|
"leveled_to": leveled_to,
|
2026-11-14 23:28:01 +00:00
|
|
|
"showdown_snapshot": snap,
|
2026-11-14 04:25:51 +00:00
|
|
|
}
|
|
|
|
|
else:
|
|
|
|
|
winning_bot.gold += pot_total
|
|
|
|
|
bot_net = pot_total - winning_bot.bet_in_pot
|
|
|
|
|
xp, leveled_to = self._award_xp_and_record("LOSE", won_stat=False)
|
|
|
|
|
self._resolve_devils_lock_after_outcome("LOSE")
|
|
|
|
|
payload = {
|
|
|
|
|
"winner_type": "BOT",
|
|
|
|
|
"winner_names": [winning_bot.name],
|
2026-11-14 23:28:01 +00:00
|
|
|
"instant_777": winning_bot.name,
|
2026-11-14 04:25:51 +00:00
|
|
|
"player_won": False,
|
|
|
|
|
"player_net": -total_p_bet,
|
|
|
|
|
"bank_gain": 0,
|
|
|
|
|
"bot_gains": [(winning_bot.name, bot_net)] if bot_net > 0 else [],
|
|
|
|
|
"xp_gained": xp,
|
|
|
|
|
"leveled_to": leveled_to,
|
2026-11-14 23:28:01 +00:00
|
|
|
"showdown_snapshot": snap,
|
2026-11-14 04:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self._last_popup_payload = payload
|
|
|
|
|
if self.devils_locked:
|
|
|
|
|
self._persist_state()
|
2026-11-21 01:20:50 +00:00
|
|
|
elif self._canvas_alive():
|
|
|
|
|
self.topbar.set_locked_exit(False)
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
self._open_result_popup(self._build_localized_popup_data(payload))
|
|
|
|
|
|
|
|
|
|
def _start_showdown_and_dealer(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
self._set_bottom_buttons([])
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
if not self.engine.any_contender_alive(self.bots):
|
|
|
|
|
self._finalize_showdown()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self.engine.state = "DEALER_TURN"
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
self._turn_job = self.ctx.root.after(BJ_DEALER_DELAY_MS, self._dealer_draw_step)
|
|
|
|
|
|
|
|
|
|
def _dealer_draw_step(self):
|
2026-11-21 01:20:50 +00:00
|
|
|
if not self._canvas_alive():
|
2026-11-14 04:25:51 +00:00
|
|
|
return
|
|
|
|
|
if self.engine.dealer_should_hit():
|
|
|
|
|
self.ctx.sounds.play("click")
|
|
|
|
|
self.engine.dealer_hit()
|
|
|
|
|
self._persist_state()
|
|
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
self._turn_job = self.ctx.root.after(BJ_DEALER_DELAY_MS, self._dealer_draw_step)
|
|
|
|
|
else:
|
|
|
|
|
self._finalize_showdown()
|
|
|
|
|
|
|
|
|
|
def _count_all_table_cards(self):
|
|
|
|
|
if len(self.engine.dealer_hand) >= 2:
|
|
|
|
|
for c in self.engine.dealer_hand[1:]:
|
|
|
|
|
self.bot_ai.observe_public_card(c)
|
|
|
|
|
for h in self.engine.player_hands:
|
|
|
|
|
for c in h.cards:
|
|
|
|
|
self.bot_ai.observe_public_card(c)
|
|
|
|
|
for b in self.bots:
|
|
|
|
|
for c in b.hand:
|
|
|
|
|
self.bot_ai.observe_public_card(c)
|
|
|
|
|
|
|
|
|
|
def _finalize_showdown(self):
|
|
|
|
|
self._count_all_table_cards()
|
|
|
|
|
res = self.engine.resolve_showdown(self.bots)
|
2026-11-14 23:28:01 +00:00
|
|
|
snap = self._collect_showdown_snapshot(instant_777_winner=None)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
if res["player_payout"] > 0:
|
2026-11-21 01:20:50 +00:00
|
|
|
self.bj_account = Database.update_blackjack_gold(
|
|
|
|
|
self.bj_account["id"], res["player_payout"]
|
|
|
|
|
)
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
w_type = res["winner_type"]
|
|
|
|
|
if w_type == "PLAYER":
|
|
|
|
|
has_natural_bj = any(
|
2026-11-21 01:20:50 +00:00
|
|
|
h.is_active_in_pot
|
|
|
|
|
and not h.is_split_hand
|
|
|
|
|
and HandEvaluator.is_natural_blackjack(h.cards)
|
2026-11-14 04:25:51 +00:00
|
|
|
for h in self.engine.player_hands
|
|
|
|
|
)
|
|
|
|
|
out_code = "WIN_BJ" if has_natural_bj else "WIN"
|
|
|
|
|
xp, leveled_to = self._award_xp_and_record(out_code, won_stat=True)
|
|
|
|
|
player_won_flag = True
|
|
|
|
|
elif w_type == "TIE":
|
|
|
|
|
out_code = "TIE"
|
|
|
|
|
xp, leveled_to = self._award_xp_and_record("TIE", won_stat=None)
|
|
|
|
|
player_won_flag = None
|
|
|
|
|
else:
|
|
|
|
|
out_code = "LOSE"
|
|
|
|
|
xp, leveled_to = self._award_xp_and_record("LOSE", won_stat=False)
|
|
|
|
|
player_won_flag = False
|
|
|
|
|
|
|
|
|
|
self._resolve_devils_lock_after_outcome(out_code)
|
|
|
|
|
|
|
|
|
|
payload = {
|
|
|
|
|
"winner_type": w_type,
|
|
|
|
|
"winner_names": res["winner_names"],
|
2026-11-14 23:28:01 +00:00
|
|
|
"instant_777": None,
|
2026-11-14 04:25:51 +00:00
|
|
|
"player_won": player_won_flag,
|
|
|
|
|
"player_net": res["player_net"],
|
|
|
|
|
"bank_gain": res["bank_gain"],
|
|
|
|
|
"bot_gains": res["bot_gains"],
|
|
|
|
|
"xp_gained": xp,
|
|
|
|
|
"leveled_to": leveled_to,
|
2026-11-14 23:28:01 +00:00
|
|
|
"showdown_snapshot": snap,
|
2026-11-14 04:25:51 +00:00
|
|
|
}
|
|
|
|
|
self._last_popup_payload = payload
|
|
|
|
|
if self.devils_locked:
|
|
|
|
|
self._persist_state()
|
2026-11-21 01:20:50 +00:00
|
|
|
elif self._canvas_alive():
|
|
|
|
|
self.topbar.set_locked_exit(False)
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
self._render_table(reveal_opponents=True, reveal_dealer=True)
|
|
|
|
|
self._open_result_popup(self._build_localized_popup_data(payload))
|
|
|
|
|
|
|
|
|
|
def _build_localized_popup_data(self, payload: dict) -> dict:
|
2026-11-14 23:28:01 +00:00
|
|
|
from models.card import Card
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
w_type = payload["winner_type"]
|
|
|
|
|
if w_type == "BANK":
|
|
|
|
|
headline = t("bj_popup_bank_won")
|
|
|
|
|
elif w_type == "PLAYER":
|
|
|
|
|
headline = t("bj_popup_player_won")
|
|
|
|
|
elif w_type == "BOT":
|
|
|
|
|
headline = t("bj_popup_bot_won", ", ".join(payload["winner_names"]))
|
|
|
|
|
else:
|
|
|
|
|
headline = t("bj_popup_tie")
|
|
|
|
|
|
2026-11-14 23:28:01 +00:00
|
|
|
showdown_hands = []
|
|
|
|
|
raw_snap = payload.get("showdown_snapshot", [])
|
|
|
|
|
for s in raw_snap:
|
|
|
|
|
cards_obj = [Card(sr[0], sr[1]) for sr in s.get("cards_raw", [])]
|
|
|
|
|
if s["role"] == "DEALER":
|
|
|
|
|
owner_lbl = t("bj_showdown_seat_dealer")
|
|
|
|
|
elif s["role"] == "PLAYER":
|
|
|
|
|
owner_lbl = (
|
|
|
|
|
t("bj_showdown_seat_you_hand", s["hand_no"])
|
2026-11-21 01:20:50 +00:00
|
|
|
if s.get("hand_no")
|
|
|
|
|
else t("bj_showdown_seat_you")
|
2026-11-14 23:28:01 +00:00
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
owner_lbl = s["name"]
|
|
|
|
|
|
|
|
|
|
rank_lbl = self._format_hand_rank_label(
|
|
|
|
|
cards_obj,
|
|
|
|
|
is_split=s.get("is_split", False),
|
|
|
|
|
busted=s.get("busted", False),
|
|
|
|
|
folded=s.get("folded", False),
|
|
|
|
|
)
|
|
|
|
|
showdown_hands.append({
|
|
|
|
|
"owner_label": owner_lbl,
|
|
|
|
|
"is_dealer": (s["role"] == "DEALER"),
|
|
|
|
|
"is_winner": s.get("is_winner", False),
|
|
|
|
|
"busted": s.get("busted", False),
|
|
|
|
|
"folded": s.get("folded", False),
|
|
|
|
|
"card_images": s.get("card_images", []),
|
|
|
|
|
"rank_label": rank_lbl,
|
|
|
|
|
"rank_tuple": tuple(s.get("rank_tuple", [0, 0])),
|
|
|
|
|
"role": s["role"],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
reason_text = self._build_showdown_reason(payload, showdown_hands)
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
other_gains = []
|
|
|
|
|
if payload["bank_gain"] > 0:
|
|
|
|
|
other_gains.append(t("bj_popup_bank_gain", payload["bank_gain"]))
|
|
|
|
|
for b_name, b_gain in payload["bot_gains"]:
|
|
|
|
|
if b_gain > 0:
|
|
|
|
|
other_gains.append(t("bj_popup_bot_gain", b_name, b_gain))
|
|
|
|
|
|
|
|
|
|
lvl_to = payload["leveled_to"]
|
|
|
|
|
lvl_str = (
|
|
|
|
|
t("bj_popup_level_up", lvl_to, Progression.get_prestige_title(lvl_to))
|
2026-11-21 01:20:50 +00:00
|
|
|
if lvl_to is not None
|
|
|
|
|
else None
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cur_gold = Database.get_blackjack_account(self.bj_account["id"])["gold"]
|
|
|
|
|
can_cont = cur_gold >= GOLD_MIN_TABLE_ENTRY
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
"headline": headline,
|
2026-11-14 23:28:01 +00:00
|
|
|
"reason_text": reason_text,
|
|
|
|
|
"showdown_hands": showdown_hands,
|
2026-11-14 04:25:51 +00:00
|
|
|
"player_won": payload["player_won"],
|
|
|
|
|
"player_net": payload["player_net"],
|
|
|
|
|
"other_gains": other_gains,
|
|
|
|
|
"xp_gained": payload["xp_gained"],
|
|
|
|
|
"new_level_title": lvl_str,
|
|
|
|
|
"can_continue": can_cont,
|
|
|
|
|
"can_leave_menu": not self.devils_locked,
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-14 23:28:01 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def _build_showdown_reason(payload: dict, showdown_hands: list[dict]) -> str:
|
|
|
|
|
if not showdown_hands:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
inst = payload.get("instant_777")
|
|
|
|
|
if inst:
|
|
|
|
|
who = t("bj_showdown_seat_you") if inst == "PLAYER" else inst
|
|
|
|
|
return t("bj_reason_777_win", who)
|
|
|
|
|
|
|
|
|
|
dealer = showdown_hands[0]
|
2026-11-21 01:20:50 +00:00
|
|
|
contenders = [
|
|
|
|
|
h for h in showdown_hands[1:] if not h["busted"] and not h["folded"]
|
|
|
|
|
]
|
2026-11-14 23:28:01 +00:00
|
|
|
if not contenders:
|
|
|
|
|
return t("bj_reason_all_out")
|
|
|
|
|
|
|
|
|
|
winners = [h for h in showdown_hands if h["is_winner"]]
|
|
|
|
|
if not winners:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
top_rank = winners[0]["rank_tuple"]
|
2026-11-21 01:20:50 +00:00
|
|
|
winner_names_str = ", ".join(
|
|
|
|
|
dict.fromkeys(w["owner_label"] for w in winners if not w["is_dealer"])
|
|
|
|
|
)
|
2026-11-14 23:28:01 +00:00
|
|
|
|
|
|
|
|
if dealer["is_winner"] and len(winners) > 1:
|
|
|
|
|
return t("bj_reason_dealer_tie_push", dealer["rank_label"])
|
|
|
|
|
|
|
|
|
|
losers_with_21 = [
|
2026-11-21 01:20:50 +00:00
|
|
|
h
|
|
|
|
|
for h in showdown_hands
|
|
|
|
|
if not h["is_winner"]
|
|
|
|
|
and not h["busted"]
|
|
|
|
|
and not h["folded"]
|
|
|
|
|
and h["rank_tuple"][1] == 21
|
2026-11-14 23:28:01 +00:00
|
|
|
]
|
|
|
|
|
win_label = dealer["owner_label"] if dealer["is_winner"] else winner_names_str
|
|
|
|
|
if top_rank == (3, 21) and losers_with_21:
|
|
|
|
|
return t("bj_reason_777_beats_21", win_label)
|
|
|
|
|
if top_rank == (2, 21) and losers_with_21:
|
|
|
|
|
return t("bj_reason_nat_beats_reg21", win_label)
|
|
|
|
|
|
|
|
|
|
non_dealer_winners = [w for w in winners if not w["is_dealer"]]
|
|
|
|
|
if len(non_dealer_winners) > 1:
|
2026-11-21 01:20:50 +00:00
|
|
|
return t(
|
|
|
|
|
"bj_reason_split_pot",
|
|
|
|
|
non_dealer_winners[0]["rank_label"],
|
|
|
|
|
winner_names_str,
|
|
|
|
|
)
|
2026-11-14 23:28:01 +00:00
|
|
|
|
|
|
|
|
if dealer["busted"] and not dealer["is_winner"]:
|
2026-11-21 01:20:50 +00:00
|
|
|
return t(
|
|
|
|
|
"bj_reason_dealer_bust",
|
|
|
|
|
dealer["rank_label"],
|
|
|
|
|
win_label,
|
|
|
|
|
winners[0]["rank_label"],
|
|
|
|
|
)
|
2026-11-14 23:28:01 +00:00
|
|
|
|
|
|
|
|
others_alive = [
|
2026-11-21 01:20:50 +00:00
|
|
|
h
|
|
|
|
|
for h in showdown_hands
|
2026-11-14 23:28:01 +00:00
|
|
|
if not h["is_winner"] and not h["busted"] and not h["folded"]
|
|
|
|
|
]
|
|
|
|
|
if others_alive:
|
|
|
|
|
runner_up = max(others_alive, key=lambda x: x["rank_tuple"])
|
|
|
|
|
runner_desc = f"{runner_up['owner_label']}: {runner_up['rank_label']}"
|
|
|
|
|
else:
|
|
|
|
|
runner_desc = f"{dealer['owner_label']}: {dealer['rank_label']}"
|
|
|
|
|
|
2026-11-21 01:20:50 +00:00
|
|
|
return t(
|
|
|
|
|
"bj_reason_higher_score", win_label, winners[0]["rank_label"], runner_desc
|
|
|
|
|
)
|
2026-11-14 23:28:01 +00:00
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
def _open_result_popup(self, popup_data: dict):
|
2026-11-21 01:20:50 +00:00
|
|
|
self._set_bottom_buttons([])
|
2026-11-14 04:25:51 +00:00
|
|
|
|
|
|
|
|
self._result_dialog = BlackjackResultDialog(
|
2026-11-21 01:20:50 +00:00
|
|
|
parent=self.arena_canvas,
|
2026-11-14 04:25:51 +00:00
|
|
|
assets=self.ctx.assets,
|
|
|
|
|
sounds=self.ctx.sounds,
|
|
|
|
|
result_data=popup_data,
|
|
|
|
|
on_next_round=self._start_new_round,
|
2026-11-21 01:20:50 +00:00
|
|
|
on_back_to_menu=lambda: self._cleanup_and_go(
|
|
|
|
|
lambda: self.on_back_to_menu(self.bj_account["id"])
|
|
|
|
|
),
|
2026-11-14 04:25:51 +00:00
|
|
|
)
|