fix(blackjack): adjust oval table layout and fix text clipping
This commit is contained in:
parent
b91ba789d7
commit
4c9b098fcb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -6,7 +6,7 @@
|
||||||
<dict>
|
<dict>
|
||||||
<key>Resources/generated-3eda52a44a36043434a4b45b9f292e6e49efd4bd4d2fe5068820b4b1147a453f.icns</key>
|
<key>Resources/generated-3eda52a44a36043434a4b45b9f292e6e49efd4bd4d2fe5068820b4b1147a453f.icns</key>
|
||||||
<data>
|
<data>
|
||||||
kCADt3Lru3Szu+2fYKRUVK0fUGU=
|
SpdKtHV1/D+9UWQRqibYWn8emBg=
|
||||||
</data>
|
</data>
|
||||||
</dict>
|
</dict>
|
||||||
<key>files2</key>
|
<key>files2</key>
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
<dict>
|
<dict>
|
||||||
<key>hash2</key>
|
<key>hash2</key>
|
||||||
<data>
|
<data>
|
||||||
NJ5ENWgTHgtgsQ7SNP1lezujMxQdvBkDRmzFJAWYBj0=
|
+lEu63lkvN/ui8HGoWbQcJq5JgfCaplGDb3hheWreJ4=
|
||||||
</data>
|
</data>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,8 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/blackjack/views/blackjack_table_view.py
|
# games/blackjack/views/blackjack_table_view.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from pathlib import Path
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
from PIL import Image, ImageTk
|
||||||
|
|
||||||
from games.blackjack.models.blackjack_engine import BlackjackEngine
|
from games.blackjack.models.blackjack_engine import BlackjackEngine
|
||||||
from games.blackjack.models.bot_ai import BlackjackBotAI
|
from games.blackjack.models.bot_ai import BlackjackBotAI
|
||||||
|
|
@ -15,14 +19,29 @@ from models.progression import Progression
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACCENT_GOLD, ACCENT_GOTH, BJ_BOT_CARD_SIZE, BJ_BOT_TURN_DELAY_MS,
|
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_DEALER_DELAY_MS, BJ_INITIAL_ANTE, BJ_SPLIT_CARD_SIZE,
|
||||||
BJ_STARTING_GOLD, BJ_VARIANTS, BORDER_COLOR, CELL_BG, ERROR_FG,
|
BJ_STARTING_GOLD, BJ_VARIANTS, BORDER_COLOR, ERROR_FG,
|
||||||
FG_COLOR, GOLD_MIN_TABLE_ENTRY, MUTED_FG, PANEL_BG,
|
FG_COLOR, GOLD_MIN_TABLE_ENTRY, MUTED_FG, PANEL_BG,
|
||||||
PLAYING_CARD_SIZE, SUBTLE_BORDER, TABLE_BG, XP_TO_GOLD_AMOUNT
|
PK_TABLE_IMAGE, PLAYING_CARD_SIZE, SUBTLE_BORDER, TABLE_BG, XP_TO_GOLD_AMOUNT
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.image_button import ImageButton
|
||||||
|
|
||||||
GAME_FOLDER_ID = "blackjack"
|
GAME_FOLDER_ID = "blackjack"
|
||||||
|
IMAGES_DIR = Path(__file__).resolve().parents[3] / "resources" / "images"
|
||||||
|
|
||||||
|
BJ_OVAL_BOT_COORDS = (
|
||||||
|
(0.160, 0.76), # Platz 1: Unten links (Spieler 1)
|
||||||
|
(0.160, 0.24), # Platz 2: Oben links (Spieler 2)
|
||||||
|
(0.840, 0.24), # Platz 3: Oben rechts (Spieler 3)
|
||||||
|
(0.840, 0.76), # Platz 4: Unten rechts (Spieler 4)
|
||||||
|
)
|
||||||
|
|
||||||
|
BJ_SEAT_LAYOUT_BY_COUNT = {
|
||||||
|
1: (2,),
|
||||||
|
2: (1, 2),
|
||||||
|
3: (1, 2, 3),
|
||||||
|
4: (0, 1, 2, 3),
|
||||||
|
}
|
||||||
|
|
||||||
STEP_MITGEHEN = "MITGEHEN"
|
STEP_MITGEHEN = "MITGEHEN"
|
||||||
STEP_ZIEHEN = "ZIEHEN"
|
STEP_ZIEHEN = "ZIEHEN"
|
||||||
|
|
@ -56,6 +75,10 @@ class BlackjackTableView:
|
||||||
self._photo_refs = []
|
self._photo_refs = []
|
||||||
self._turn_job = None
|
self._turn_job = None
|
||||||
|
|
||||||
|
self._raw_table_pil: Image.Image | None = self._load_raw_table_image()
|
||||||
|
self._scaled_table_photo: ImageTk.PhotoImage | None = None
|
||||||
|
self._last_bg_size: tuple[int, int] = (0, 0)
|
||||||
|
|
||||||
self.ctx.sounds.play_ingame_music()
|
self.ctx.sounds.play_ingame_music()
|
||||||
|
|
||||||
if resume_state_json is not None:
|
if resume_state_json is not None:
|
||||||
|
|
@ -73,6 +96,16 @@ class BlackjackTableView:
|
||||||
self._build_ui()
|
self._build_ui()
|
||||||
self._start_new_round()
|
self._start_new_round()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _load_raw_table_image() -> Image.Image | None:
|
||||||
|
img_path = IMAGES_DIR / PK_TABLE_IMAGE
|
||||||
|
if img_path.is_file():
|
||||||
|
try:
|
||||||
|
return Image.open(img_path).convert("RGB")
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
return None
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# AUTO-SAVE & RESUME (nur aktiv während The Devil's Deal!)
|
# AUTO-SAVE & RESUME (nur aktiv während The Devil's Deal!)
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
@ -183,6 +216,7 @@ class BlackjackTableView:
|
||||||
self._result_dialog.close_dialog()
|
self._result_dialog.close_dialog()
|
||||||
self._result_dialog = None
|
self._result_dialog = None
|
||||||
|
|
||||||
|
self._last_bg_size = (0, 0)
|
||||||
self.ctx.root.clear_window(apply_global_bg=True)
|
self.ctx.root.clear_window(apply_global_bg=True)
|
||||||
|
|
||||||
self.topbar = self.ctx.build_game_topbar(
|
self.topbar = self.ctx.build_game_topbar(
|
||||||
|
|
@ -194,48 +228,102 @@ class BlackjackTableView:
|
||||||
)
|
)
|
||||||
|
|
||||||
self.table_frame = tk.Frame(
|
self.table_frame = tk.Frame(
|
||||||
self.ctx.root, bg=TABLE_BG, padx=18, pady=8,
|
self.ctx.root, bg=TABLE_BG, padx=14, pady=8,
|
||||||
highlightthickness=1, highlightbackground=ERROR_FG if self.devils_locked else BORDER_COLOR
|
highlightthickness=1, highlightbackground=ERROR_FG if self.devils_locked else BORDER_COLOR
|
||||||
)
|
)
|
||||||
self.table_frame.place(relx=0.5, rely=0.53, anchor="center", relwidth=0.94, relheight=0.86)
|
self.table_frame.place(relx=0.5, rely=0.535, anchor="center", relwidth=0.96, relheight=0.88)
|
||||||
|
|
||||||
self.pot_lbl = tk.Label(
|
self.pot_lbl = tk.Label(
|
||||||
self.table_frame, text="", font=("Georgia", 12, "bold"),
|
self.table_frame, text="", font=("Georgia", 11, "bold"),
|
||||||
fg=ACCENT_GOLD, bg=PANEL_BG, pady=4, highlightthickness=1, highlightbackground=SUBTLE_BORDER
|
fg=ACCENT_GOLD, bg=PANEL_BG, pady=4, highlightthickness=1, highlightbackground=SUBTLE_BORDER
|
||||||
)
|
)
|
||||||
self.pot_lbl.pack(fill="x", pady=(0, 4))
|
self.pot_lbl.pack(fill="x", side="top", pady=(0, 4))
|
||||||
|
|
||||||
dealer_sec = tk.Frame(self.table_frame, bg=TABLE_BG)
|
# Kompakte 3-Spalten-Leiste unten (identisch zu Poker)
|
||||||
dealer_sec.pack(fill="x", pady=(2, 2))
|
bottom_area = tk.Frame(self.table_frame, bg=TABLE_BG, height=224)
|
||||||
self.dealer_lbl = tk.Label(dealer_sec, text=t("bj_dealer_title"), font=("Georgia", 11, "bold"), fg=MUTED_FG, bg=TABLE_BG)
|
bottom_area.pack(fill="x", side="bottom", pady=(6, 0))
|
||||||
self.dealer_lbl.pack()
|
bottom_area.pack_propagate(False)
|
||||||
self.dealer_cards_frame = tk.Frame(dealer_sec, bg=TABLE_BG, height=148)
|
|
||||||
self.dealer_cards_frame.pack(pady=2)
|
|
||||||
|
|
||||||
mid_sec = tk.Frame(self.table_frame, bg=TABLE_BG)
|
bottom_area.columnconfigure(0, weight=30, uniform="bjcols")
|
||||||
mid_sec.pack(fill="x")
|
bottom_area.columnconfigure(1, weight=44, uniform="bjcols")
|
||||||
self.status_lbl = tk.Label(mid_sec, text="", font=("Georgia", 11, "bold"), fg=ACCENT_GOLD, bg=TABLE_BG)
|
bottom_area.columnconfigure(2, weight=26, uniform="bjcols")
|
||||||
self.status_lbl.pack(pady=4)
|
bottom_area.rowconfigure(0, weight=1)
|
||||||
|
|
||||||
seats_area = tk.Frame(self.table_frame, bg=TABLE_BG)
|
self.left_info_panel = tk.Frame(
|
||||||
seats_area.pack(fill="both", expand=True, pady=(2, 4))
|
bottom_area, bg=PANEL_BG, padx=8, pady=5,
|
||||||
|
highlightthickness=1, highlightbackground=BORDER_COLOR
|
||||||
|
)
|
||||||
|
self.left_info_panel.grid(row=0, column=0, sticky="nsew", padx=(0, 6))
|
||||||
|
|
||||||
if self.bots:
|
center_player_wrap = tk.Frame(
|
||||||
self.bots_row = tk.Frame(seats_area, bg=TABLE_BG)
|
bottom_area, bg=PANEL_BG, padx=10, pady=6,
|
||||||
self.bots_row.pack(side="left", fill="y", padx=(0, 14))
|
|
||||||
else:
|
|
||||||
self.bots_row = None
|
|
||||||
|
|
||||||
self.player_sec = tk.Frame(seats_area, bg=TABLE_BG)
|
|
||||||
self.player_sec.pack(side="left", fill="both", expand=True)
|
|
||||||
|
|
||||||
self.controls_frame = tk.Frame(
|
|
||||||
self.table_frame, bg=PANEL_BG, padx=14, pady=10,
|
|
||||||
highlightthickness=1, highlightbackground=SUBTLE_BORDER
|
highlightthickness=1, highlightbackground=SUBTLE_BORDER
|
||||||
)
|
)
|
||||||
self.controls_frame.pack(fill="x", side="bottom")
|
center_player_wrap.grid(row=0, column=1, sticky="nsew", padx=4)
|
||||||
|
|
||||||
|
self.status_lbl = tk.Label(
|
||||||
|
center_player_wrap, text="", font=("Georgia", 10, "bold"),
|
||||||
|
fg=ACCENT_GOLD, bg=PANEL_BG, wraplength=410, justify="center"
|
||||||
|
)
|
||||||
|
self.status_lbl.pack(side="top", pady=(0, 3))
|
||||||
|
|
||||||
|
self.player_sec = tk.Frame(center_player_wrap, bg=PANEL_BG)
|
||||||
|
self.player_sec.pack(fill="both", expand=True)
|
||||||
|
|
||||||
|
self.controls_frame = tk.Frame(
|
||||||
|
bottom_area, bg=PANEL_BG, padx=8, pady=5,
|
||||||
|
highlightthickness=1, highlightbackground=BORDER_COLOR
|
||||||
|
)
|
||||||
|
self.controls_frame.grid(row=0, column=2, sticky="nsew", padx=(6, 0))
|
||||||
|
|
||||||
|
# Canvas für den ovalen Tisch (`poker_table.jpg`[cite: 9])
|
||||||
|
self.arena_canvas = tk.Canvas(
|
||||||
|
self.table_frame, bg="#120f18", highlightthickness=1, highlightbackground=SUBTLE_BORDER
|
||||||
|
)
|
||||||
|
self.arena_canvas.pack(fill="both", expand=True)
|
||||||
|
self.arena_canvas.bind("<Configure>", self._on_arena_resize)
|
||||||
|
|
||||||
|
# Bank-Box (oben mittig auf dem Canvas)
|
||||||
|
felt_bg = "#1b1626"
|
||||||
|
self.board_box = tk.Frame(
|
||||||
|
self.arena_canvas, bg=felt_bg, padx=10, pady=6,
|
||||||
|
highlightthickness=1, highlightbackground=SUBTLE_BORDER
|
||||||
|
)
|
||||||
|
self.board_box.place(relx=0.50, rely=0.28, anchor="center")
|
||||||
|
|
||||||
|
self.dealer_lbl = tk.Label(
|
||||||
|
self.board_box, text=t("bj_dealer_title"),
|
||||||
|
font=("Georgia", 9, "bold"), fg=MUTED_FG, bg=felt_bg
|
||||||
|
)
|
||||||
|
self.dealer_lbl.pack(pady=(0, 3))
|
||||||
|
|
||||||
|
self.dealer_cards_frame = tk.Frame(self.board_box, bg=felt_bg, height=PLAYING_CARD_SIZE[1] + 2)
|
||||||
|
self.dealer_cards_frame.pack()
|
||||||
|
|
||||||
|
self._bot_seat_frames: list[tk.Frame] = []
|
||||||
self._refresh_header()
|
self._refresh_header()
|
||||||
|
|
||||||
|
def _on_arena_resize(self, event):
|
||||||
|
w, h = event.width, event.height
|
||||||
|
if w < 80 or h < 80 or (w, h) == self._last_bg_size:
|
||||||
|
return
|
||||||
|
self._last_bg_size = (w, h)
|
||||||
|
|
||||||
|
self.arena_canvas.delete("table_bg")
|
||||||
|
if self._raw_table_pil is not None:
|
||||||
|
fitted = self._raw_table_pil.resize((w, h), Image.Resampling.LANCZOS)
|
||||||
|
self._scaled_table_photo = ImageTk.PhotoImage(fitted)
|
||||||
|
self.arena_canvas.create_image(
|
||||||
|
0, 0, image=self._scaled_table_photo, anchor="nw", tags="table_bg"
|
||||||
|
)
|
||||||
|
self.arena_canvas.tag_lower("table_bg")
|
||||||
|
else:
|
||||||
|
mx, my_top, my_bot = int(w * 0.11), int(h * 0.13), int(h * 0.08)
|
||||||
|
self.arena_canvas.create_oval(
|
||||||
|
mx, my_top, w - mx, h - my_bot,
|
||||||
|
fill="#14111b", outline=BORDER_COLOR, width=3, tags="table_bg"
|
||||||
|
)
|
||||||
|
|
||||||
def _refresh_header(self):
|
def _refresh_header(self):
|
||||||
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
||||||
prof = self.ctx.profile
|
prof = self.ctx.profile
|
||||||
|
|
@ -298,7 +386,7 @@ class BlackjackTableView:
|
||||||
self._begin_new_table_cycle()
|
self._begin_new_table_cycle()
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# RENDERING TISCH & HÄNDE
|
# RENDERING TISCH & SPIELER HÄNDE (Karten mit Überlappung)
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _hand_state_suffix(hand: PlayerHand) -> str:
|
def _hand_state_suffix(hand: PlayerHand) -> str:
|
||||||
|
|
@ -311,29 +399,41 @@ class BlackjackTableView:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def _render_bots(self, reveal_opponents: bool):
|
def _render_bots(self, reveal_opponents: bool):
|
||||||
if not self.bots_row or not self.bots_row.winfo_exists():
|
for old_f in self._bot_seat_frames:
|
||||||
return
|
if old_f.winfo_exists():
|
||||||
for w in self.bots_row.winfo_children():
|
old_f.destroy()
|
||||||
w.destroy()
|
self._bot_seat_frames.clear()
|
||||||
|
|
||||||
|
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]
|
||||||
|
rx, ry = BJ_OVAL_BOT_COORDS[coord_idx]
|
||||||
|
|
||||||
|
is_turn = (bot_i == self.active_bot_idx)
|
||||||
|
if is_turn:
|
||||||
|
b_col, thick = ACCENT_GOLD, 2
|
||||||
|
elif bot.folded or bot.busted:
|
||||||
|
b_col, thick = ERROR_FG, 1
|
||||||
|
else:
|
||||||
|
b_col, thick = BORDER_COLOR, 1
|
||||||
|
|
||||||
for idx, bot in enumerate(self.bots):
|
|
||||||
is_turn = (idx == self.active_bot_idx)
|
|
||||||
border_col = ACCENT_GOLD if is_turn else (ERROR_FG if (bot.busted or bot.folded) else SUBTLE_BORDER)
|
|
||||||
box = tk.Frame(
|
box = tk.Frame(
|
||||||
self.bots_row, bg=CELL_BG, padx=8, pady=5,
|
self.arena_canvas, bg="#191521", padx=8, pady=4, width=175,
|
||||||
highlightthickness=2 if is_turn else 1, highlightbackground=border_col
|
highlightthickness=thick, highlightbackground=b_col
|
||||||
)
|
)
|
||||||
box.pack(side="left", padx=4, fill="y")
|
box.place(relx=rx, rely=ry, anchor="center")
|
||||||
|
self._bot_seat_frames.append(box)
|
||||||
|
|
||||||
disp_name = t("bj_bot_rebuy", bot.name) if bot.rebought else bot.name
|
disp_name = t("bj_bot_rebuy", bot.name) if bot.rebought else bot.name
|
||||||
tk.Label(box, text=disp_name, font=("Georgia", 10, "bold"), fg=ACCENT_GOTH, bg=CELL_BG).pack()
|
tk.Label(box, text=disp_name, font=("Georgia", 9, "bold"), fg=ACCENT_GOTH, bg="#191521").pack()
|
||||||
tk.Label(box, text=t("bj_bot_gold_lbl", bot.gold), font=("Helvetica", 9, "bold"), fg=ACCENT_GOLD, bg=CELL_BG).pack()
|
tk.Label(box, text=t("bj_bot_gold_lbl", bot.gold), font=("Helvetica", 8, "bold"), fg=ACCENT_GOLD, bg="#191521").pack(pady=(1, 2))
|
||||||
|
|
||||||
cards_f = tk.Frame(box, bg=CELL_BG, height=96)
|
cards_f = tk.Frame(box, bg="#191521", height=82)
|
||||||
cards_f.pack(pady=3)
|
cards_f.pack(pady=2)
|
||||||
|
|
||||||
show_faces = reveal_opponents or bot.busted
|
show_faces = reveal_opponents or bot.busted
|
||||||
for card in bot.hand:
|
for c_idx, card in enumerate(bot.hand):
|
||||||
photo = (
|
photo = (
|
||||||
self.ctx.assets.get_card_photo(card.image_filename, size=BJ_BOT_CARD_SIZE)
|
self.ctx.assets.get_card_photo(card.image_filename, size=BJ_BOT_CARD_SIZE)
|
||||||
if show_faces
|
if show_faces
|
||||||
|
|
@ -341,7 +441,11 @@ class BlackjackTableView:
|
||||||
)
|
)
|
||||||
if photo:
|
if photo:
|
||||||
self._photo_refs.append(photo)
|
self._photo_refs.append(photo)
|
||||||
tk.Label(cards_f, image=photo, bg=CELL_BG, bd=0).pack(side="left", padx=2)
|
lbl = tk.Label(cards_f, image=photo, bg="#191521", bd=0)
|
||||||
|
lbl.pack(side="left")
|
||||||
|
if c_idx > 0:
|
||||||
|
# Karten leicht überlappen lassen (~35px sichtbar)
|
||||||
|
lbl.pack_configure(padx=(-38, 0))
|
||||||
|
|
||||||
if reveal_opponents and bot.hand:
|
if reveal_opponents and bot.hand:
|
||||||
b_val, _ = HandEvaluator.evaluate(bot.hand)
|
b_val, _ = HandEvaluator.evaluate(bot.hand)
|
||||||
|
|
@ -359,9 +463,9 @@ class BlackjackTableView:
|
||||||
info_txt = ""
|
info_txt = ""
|
||||||
|
|
||||||
tk.Label(
|
tk.Label(
|
||||||
box, text=info_txt, font=("Helvetica", 9, "bold" if bot.busted else "normal"),
|
box, text=info_txt, font=("Helvetica", 8, "bold" if bot.busted else "normal"),
|
||||||
fg=ERROR_FG if (bot.busted or bot.folded) else FG_COLOR, bg=CELL_BG
|
fg=ERROR_FG if (bot.busted or bot.folded) else FG_COLOR, bg="#191521"
|
||||||
).pack()
|
).pack(pady=(1, 0))
|
||||||
|
|
||||||
def _render_player_hands(self):
|
def _render_player_hands(self):
|
||||||
for w in self.player_sec.winfo_children():
|
for w in self.player_sec.winfo_children():
|
||||||
|
|
@ -373,13 +477,17 @@ class BlackjackTableView:
|
||||||
|
|
||||||
if len(hands) == 1:
|
if len(hands) == 1:
|
||||||
h = hands[0]
|
h = hands[0]
|
||||||
cards_f = tk.Frame(self.player_sec, bg=TABLE_BG, height=150)
|
cards_f = tk.Frame(self.player_sec, bg=PANEL_BG, height=132)
|
||||||
cards_f.pack(pady=3)
|
cards_f.pack(pady=2)
|
||||||
for card in h.cards:
|
for c_idx, card in enumerate(h.cards):
|
||||||
photo = self.ctx.assets.get_card_photo(card.image_filename, size=PLAYING_CARD_SIZE)
|
photo = self.ctx.assets.get_card_photo(card.image_filename, size=PLAYING_CARD_SIZE)
|
||||||
if photo:
|
if photo:
|
||||||
self._photo_refs.append(photo)
|
self._photo_refs.append(photo)
|
||||||
tk.Label(cards_f, image=photo, bg=TABLE_BG, bd=0).pack(side="left", padx=4)
|
lbl = tk.Label(cards_f, image=photo, bg=PANEL_BG, bd=0)
|
||||||
|
lbl.pack(side="left")
|
||||||
|
if c_idx > 0:
|
||||||
|
# Überlappung bei eigener Hand
|
||||||
|
lbl.pack_configure(padx=(-42, 0))
|
||||||
|
|
||||||
p_val, p_soft = HandEvaluator.evaluate(h.cards)
|
p_val, p_soft = HandEvaluator.evaluate(h.cards)
|
||||||
soft_hint = t("bj_soft_hint", p_val) if p_soft and p_val < 21 else ""
|
soft_hint = t("bj_soft_hint", p_val) if p_soft and p_val < 21 else ""
|
||||||
|
|
@ -388,29 +496,32 @@ class BlackjackTableView:
|
||||||
tk.Label(
|
tk.Label(
|
||||||
self.player_sec,
|
self.player_sec,
|
||||||
text=t("bj_player_total", p_val, soft_hint, h.bet_in_pot, suffix),
|
text=t("bj_player_total", p_val, soft_hint, h.bet_in_pot, suffix),
|
||||||
font=("Georgia", 12, "bold"), fg=lbl_col, bg=TABLE_BG
|
font=("Georgia", 11, "bold"), fg=lbl_col, bg=PANEL_BG
|
||||||
).pack()
|
).pack(side="bottom", pady=(2, 2))
|
||||||
return
|
return
|
||||||
|
|
||||||
split_wrap = tk.Frame(self.player_sec, bg=TABLE_BG)
|
split_wrap = tk.Frame(self.player_sec, bg=PANEL_BG)
|
||||||
split_wrap.pack(expand=True)
|
split_wrap.pack(expand=True)
|
||||||
|
|
||||||
for idx, h in enumerate(hands):
|
for idx, h in enumerate(hands):
|
||||||
is_active = (self.engine.state == "ACTION_LOOP" and self.active_bot_idx == -1 and idx == self.active_hand_idx)
|
is_active = (self.engine.state == "ACTION_LOOP" and self.active_bot_idx == -1 and idx == self.active_hand_idx)
|
||||||
b_col = ACCENT_GOLD if is_active else (ERROR_FG if (h.busted or h.folded) else SUBTLE_BORDER)
|
b_col = ACCENT_GOLD if is_active else (ERROR_FG if (h.busted or h.folded) else SUBTLE_BORDER)
|
||||||
hbox = tk.Frame(
|
hbox = tk.Frame(
|
||||||
split_wrap, bg=CELL_BG, padx=10, pady=6,
|
split_wrap, bg=CELL_BG, padx=8, pady=4,
|
||||||
highlightthickness=2 if is_active else 1, highlightbackground=b_col
|
highlightthickness=2 if is_active else 1, highlightbackground=b_col
|
||||||
)
|
)
|
||||||
hbox.pack(side="left", padx=8)
|
hbox.pack(side="left", padx=5)
|
||||||
|
|
||||||
cards_f = tk.Frame(hbox, bg=CELL_BG, height=126)
|
cards_f = tk.Frame(hbox, bg=CELL_BG, height=108)
|
||||||
cards_f.pack(pady=2)
|
cards_f.pack(pady=2)
|
||||||
for card in h.cards:
|
for c_idx, card in enumerate(h.cards):
|
||||||
photo = self.ctx.assets.get_card_photo(card.image_filename, size=BJ_SPLIT_CARD_SIZE)
|
photo = self.ctx.assets.get_card_photo(card.image_filename, size=BJ_SPLIT_CARD_SIZE)
|
||||||
if photo:
|
if photo:
|
||||||
self._photo_refs.append(photo)
|
self._photo_refs.append(photo)
|
||||||
tk.Label(cards_f, image=photo, bg=CELL_BG, bd=0).pack(side="left", padx=3)
|
lbl = tk.Label(cards_f, image=photo, bg=CELL_BG, bd=0)
|
||||||
|
lbl.pack(side="left")
|
||||||
|
if c_idx > 0:
|
||||||
|
lbl.pack_configure(padx=(-36, 0))
|
||||||
|
|
||||||
p_val, p_soft = HandEvaluator.evaluate(h.cards)
|
p_val, p_soft = HandEvaluator.evaluate(h.cards)
|
||||||
soft_hint = t("bj_soft_hint", p_val) if p_soft and p_val < 21 else ""
|
soft_hint = t("bj_soft_hint", p_val) if p_soft and p_val < 21 else ""
|
||||||
|
|
@ -419,40 +530,43 @@ class BlackjackTableView:
|
||||||
tk.Label(
|
tk.Label(
|
||||||
hbox,
|
hbox,
|
||||||
text=t("bj_hand_box_title", idx + 1, p_val, soft_hint, h.bet_in_pot, suffix),
|
text=t("bj_hand_box_title", idx + 1, p_val, soft_hint, h.bet_in_pot, suffix),
|
||||||
font=("Georgia", 10, "bold"), fg=lbl_col, bg=CELL_BG
|
font=("Georgia", 9, "bold"), fg=lbl_col, bg=CELL_BG
|
||||||
).pack(pady=(2, 0))
|
).pack(pady=(1, 0))
|
||||||
|
|
||||||
def _render_table(self, reveal_opponents: bool, reveal_dealer: bool):
|
def _render_table(self, reveal_opponents: bool, reveal_dealer: bool):
|
||||||
self._photo_refs.clear()
|
self._photo_refs.clear()
|
||||||
for w in self.dealer_cards_frame.winfo_children():
|
for w in self.dealer_cards_frame.winfo_children():
|
||||||
w.destroy()
|
w.destroy()
|
||||||
|
|
||||||
for idx, card in enumerate(self.engine.dealer_hand):
|
for c_idx, card in enumerate(self.engine.dealer_hand):
|
||||||
photo = (
|
photo = (
|
||||||
self.ctx.assets.get_card_back_photo(color=self.cfg["back_color"], size=PLAYING_CARD_SIZE)
|
self.ctx.assets.get_card_back_photo(color=self.cfg["back_color"], size=PLAYING_CARD_SIZE)
|
||||||
if idx == 1 and not reveal_dealer
|
if c_idx == 1 and not reveal_dealer
|
||||||
else self.ctx.assets.get_card_photo(card.image_filename, size=PLAYING_CARD_SIZE)
|
else self.ctx.assets.get_card_photo(card.image_filename, size=PLAYING_CARD_SIZE)
|
||||||
)
|
)
|
||||||
if photo:
|
if photo:
|
||||||
self._photo_refs.append(photo)
|
self._photo_refs.append(photo)
|
||||||
tk.Label(self.dealer_cards_frame, image=photo, bg=TABLE_BG, bd=0).pack(side="left", padx=5)
|
lbl = tk.Label(self.dealer_cards_frame, image=photo, bg="#1b1626", bd=0)
|
||||||
|
lbl.pack(side="left")
|
||||||
|
if c_idx > 0:
|
||||||
|
lbl.pack_configure(padx=(-42, 0))
|
||||||
|
|
||||||
|
felt_bg = "#1b1626"
|
||||||
if not reveal_dealer and self.engine.dealer_hand:
|
if not reveal_dealer and self.engine.dealer_hand:
|
||||||
up_val, _ = HandEvaluator.evaluate([self.engine.dealer_hand[0]])
|
up_val, _ = HandEvaluator.evaluate([self.engine.dealer_hand[0]])
|
||||||
self.dealer_lbl.configure(text=t("bj_dealer_shows", up_val))
|
self.dealer_lbl.configure(text=t("bj_dealer_shows", up_val), bg=felt_bg)
|
||||||
elif self.engine.dealer_hand:
|
elif self.engine.dealer_hand:
|
||||||
d_val, _ = HandEvaluator.evaluate(self.engine.dealer_hand)
|
d_val, _ = HandEvaluator.evaluate(self.engine.dealer_hand)
|
||||||
self.dealer_lbl.configure(text=t("bj_dealer_total", d_val))
|
self.dealer_lbl.configure(text=t("bj_dealer_total", d_val), bg=felt_bg)
|
||||||
|
|
||||||
self._render_player_hands()
|
self._render_player_hands()
|
||||||
self._render_bots(reveal_opponents=reveal_opponents)
|
self._render_bots(reveal_opponents=reveal_opponents)
|
||||||
self._refresh_header()
|
self._refresh_header()
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# TISCH-UMLAUF LOGIK (Keine Karte gezogen -> Auto-Showdown!)
|
# TISCH-UMLAUF LOGIK
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
def _begin_new_table_cycle(self):
|
def _begin_new_table_cycle(self):
|
||||||
"""Startet einen neuen Tisch-Umlauf mit cycle_card_drawn = False."""
|
|
||||||
if not self.engine.any_contender_alive(self.bots):
|
if not self.engine.any_contender_alive(self.bots):
|
||||||
self._start_showdown_and_dealer()
|
self._start_showdown_and_dealer()
|
||||||
return
|
return
|
||||||
|
|
@ -464,17 +578,12 @@ class BlackjackTableView:
|
||||||
self._step_next_player_hand()
|
self._step_next_player_hand()
|
||||||
|
|
||||||
def _begin_settle_bets_pass(self):
|
def _begin_settle_bets_pass(self):
|
||||||
"""
|
|
||||||
Niemand hat im Umlauf eine Karte gezogen, aber ein letzter Raise ist noch offen:
|
|
||||||
Jeder mit Rückstand darf nur noch Mitgehen oder Austreten, danach sofort Aufdecken!
|
|
||||||
"""
|
|
||||||
self.settle_only_mode = True
|
self.settle_only_mode = True
|
||||||
self.active_bot_idx = -1
|
self.active_bot_idx = -1
|
||||||
self.active_hand_idx = 0
|
self.active_hand_idx = 0
|
||||||
self._step_next_player_hand()
|
self._step_next_player_hand()
|
||||||
|
|
||||||
def _on_table_pass_completed(self):
|
def _on_table_pass_completed(self):
|
||||||
"""Wird am Ende jedes Tisch-Umlaufs (Spieler + alle Bots) aufgerufen."""
|
|
||||||
if not self.engine.any_contender_alive(self.bots):
|
if not self.engine.any_contender_alive(self.bots):
|
||||||
self._start_showdown_and_dealer()
|
self._start_showdown_and_dealer()
|
||||||
return
|
return
|
||||||
|
|
@ -483,24 +592,18 @@ class BlackjackTableView:
|
||||||
wallet = self.bj_account["gold"]
|
wallet = self.bj_account["gold"]
|
||||||
|
|
||||||
if self.settle_only_mode:
|
if self.settle_only_mode:
|
||||||
# Alle offenen Einsätze beglichen -> sofort aufdecken!
|
|
||||||
self._start_showdown_and_dealer()
|
self._start_showdown_and_dealer()
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.engine.cycle_card_drawn:
|
if not self.engine.cycle_card_drawn:
|
||||||
# KEINER hat in dieser Runde eine Karte gezogen!
|
|
||||||
if self.engine.has_unsettled_bets(self.bots, wallet):
|
if self.engine.has_unsettled_bets(self.bots, wallet):
|
||||||
self._begin_settle_bets_pass()
|
self._begin_settle_bets_pass()
|
||||||
else:
|
else:
|
||||||
self._start_showdown_and_dealer()
|
self._start_showdown_and_dealer()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Mindestens einer hat eine Karte gezogen -> nächster regulärer Umlauf!
|
|
||||||
self._begin_new_table_cycle()
|
self._begin_new_table_cycle()
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# SPIELER-SCHRITTE IM UMLAUF
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
def _step_next_player_hand(self):
|
def _step_next_player_hand(self):
|
||||||
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
self.bj_account = Database.get_blackjack_account(self.bj_account["id"])
|
||||||
wallet = self.bj_account["gold"]
|
wallet = self.bj_account["gold"]
|
||||||
|
|
@ -524,8 +627,6 @@ class BlackjackTableView:
|
||||||
self.active_hand_idx += 1
|
self.active_hand_idx += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Regulärer Zug im Umlauf:
|
|
||||||
# 1. Falls ein Raise offen ist -> erst Mitgehen? fragen
|
|
||||||
if to_call > 0:
|
if to_call > 0:
|
||||||
self.turn_step = STEP_MITGEHEN
|
self.turn_step = STEP_MITGEHEN
|
||||||
self._persist_state()
|
self._persist_state()
|
||||||
|
|
@ -533,7 +634,6 @@ class BlackjackTableView:
|
||||||
self._render_current_tree_step()
|
self._render_current_tree_step()
|
||||||
return
|
return
|
||||||
|
|
||||||
# 2. Kein offener Raise -> direkt fragen: Karte ziehen oder Keine neue Karte?
|
|
||||||
h_val, _ = HandEvaluator.evaluate(h.cards)
|
h_val, _ = HandEvaluator.evaluate(h.cards)
|
||||||
if not h.cards_locked and not h.doubled and h_val < 21:
|
if not h.cards_locked and not h.doubled and h_val < 21:
|
||||||
self.turn_step = STEP_ZIEHEN
|
self.turn_step = STEP_ZIEHEN
|
||||||
|
|
@ -542,7 +642,6 @@ class BlackjackTableView:
|
||||||
self._render_current_tree_step()
|
self._render_current_tree_step()
|
||||||
return
|
return
|
||||||
|
|
||||||
# 3. Hand steht schon bei 21 / Double Down -> darf bei verfügbarem Gold noch erhöhen
|
|
||||||
dyn_chips = self._get_current_level_chips()
|
dyn_chips = self._get_current_level_chips()
|
||||||
if wallet >= dyn_chips[0]:
|
if wallet >= dyn_chips[0]:
|
||||||
self.turn_step = STEP_ERHOEHEN
|
self.turn_step = STEP_ERHOEHEN
|
||||||
|
|
@ -569,81 +668,72 @@ class BlackjackTableView:
|
||||||
hand = self.engine.player_hands[self.active_hand_idx]
|
hand = self.engine.player_hands[self.active_hand_idx]
|
||||||
hand_tag = t("bj_active_hand_tag", self.active_hand_idx + 1) if len(self.engine.player_hands) > 1 else ""
|
hand_tag = t("bj_active_hand_tag", self.active_hand_idx + 1) if len(self.engine.player_hands) > 1 else ""
|
||||||
|
|
||||||
row = tk.Frame(self.controls_frame, bg=PANEL_BG)
|
col = tk.Frame(self.controls_frame, bg=PANEL_BG)
|
||||||
row.pack()
|
col.pack(expand=True)
|
||||||
|
|
||||||
# =====================================================
|
|
||||||
# SCHRITT 1: MITGEHEN? (nur wenn ein Gegner erhöht hat!)
|
|
||||||
# =====================================================
|
|
||||||
if self.turn_step == STEP_MITGEHEN:
|
if self.turn_step == STEP_MITGEHEN:
|
||||||
raw_deficit = max(0, self.engine.highest_bet - hand.bet_in_pot)
|
raw_deficit = max(0, self.engine.highest_bet - hand.bet_in_pot)
|
||||||
to_call = min(wallet, raw_deficit)
|
to_call = min(wallet, raw_deficit)
|
||||||
|
|
||||||
self.status_lbl.configure(text=t("bj_tree_step1_call", hand_tag, to_call))
|
self.status_lbl.configure(text=t("bj_tree_step1_call", hand_tag, to_call))
|
||||||
|
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_tree_btn_call_yes", to_call),
|
col, t("bj_tree_btn_call_yes", to_call),
|
||||||
self.ctx.assets.raw_btn, self.ctx.assets.raw_btn_active,
|
self.ctx.assets.raw_btn, self.ctx.assets.raw_btn_active,
|
||||||
lambda: self._on_step1_call_yes(to_call),
|
lambda: self._on_step1_call_yes(to_call),
|
||||||
sound_mgr=self.ctx.sounds, width=220, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=30, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=8)
|
).pack(pady=2)
|
||||||
|
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_tree_btn_call_no_lose"),
|
col, t("bj_tree_btn_call_no_lose"),
|
||||||
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
||||||
self._on_fold_hand,
|
self._on_fold_hand,
|
||||||
sound_mgr=self.ctx.sounds, width=230, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=30, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=8)
|
).pack(pady=2)
|
||||||
return
|
return
|
||||||
|
|
||||||
# =====================================================
|
|
||||||
# SCHRITT 2: KARTE ZIEHEN ODER KEINE NEUE KARTE?
|
|
||||||
# =====================================================
|
|
||||||
if self.turn_step == STEP_ZIEHEN:
|
if self.turn_step == STEP_ZIEHEN:
|
||||||
self.status_lbl.configure(text=t("bj_tree_step2_draw", hand_tag))
|
self.status_lbl.configure(text=t("bj_tree_step2_draw", hand_tag))
|
||||||
|
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_tree_btn_draw_yes"),
|
col, t("bj_tree_btn_draw_yes"),
|
||||||
self.ctx.assets.raw_btn, self.ctx.assets.raw_btn_active,
|
self.ctx.assets.raw_btn, self.ctx.assets.raw_btn_active,
|
||||||
self._on_step2_draw_yes,
|
self._on_step2_draw_yes,
|
||||||
sound_mgr=self.ctx.sounds, width=185, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=28, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=5)
|
).pack(pady=2)
|
||||||
|
|
||||||
if self.engine.can_double_down(self.active_hand_idx, wallet):
|
if self.engine.can_double_down(self.active_hand_idx, wallet):
|
||||||
dd_cost = self.engine.get_double_down_cost(self.active_hand_idx)
|
dd_cost = self.engine.get_double_down_cost(self.active_hand_idx)
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_double_btn", dd_cost),
|
col, t("bj_double_btn", dd_cost),
|
||||||
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
||||||
self._on_step2_double_down,
|
self._on_step2_double_down,
|
||||||
sound_mgr=self.ctx.sounds, width=170, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=28, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=5)
|
).pack(pady=2)
|
||||||
|
|
||||||
if self.engine.can_split_hand(self.active_hand_idx, wallet):
|
if self.engine.can_split_hand(self.active_hand_idx, wallet):
|
||||||
sp_cost = self.engine.highest_bet
|
sp_cost = self.engine.highest_bet
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_split_btn", sp_cost),
|
col, t("bj_split_btn", sp_cost),
|
||||||
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
||||||
self._on_step2_split,
|
self._on_step2_split,
|
||||||
sound_mgr=self.ctx.sounds, width=145, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=28, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=5)
|
).pack(pady=2)
|
||||||
|
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_tree_btn_draw_no"),
|
col, t("bj_tree_btn_draw_no"),
|
||||||
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
||||||
self._on_step2_draw_no,
|
self._on_step2_draw_no,
|
||||||
sound_mgr=None, width=180, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=None, width=170, height=28, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=5)
|
).pack(pady=2)
|
||||||
|
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_fold_btn"),
|
col, t("bj_fold_btn"),
|
||||||
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
||||||
self._on_fold_hand,
|
self._on_fold_hand,
|
||||||
sound_mgr=self.ctx.sounds, width=120, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=28, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=5)
|
).pack(pady=2)
|
||||||
return
|
return
|
||||||
|
|
||||||
# =====================================================
|
|
||||||
# SCHRITT 3: ERHÖHEN?
|
|
||||||
# =====================================================
|
|
||||||
if self.turn_step == STEP_ERHOEHEN:
|
if self.turn_step == STEP_ERHOEHEN:
|
||||||
self.status_lbl.configure(text=t("bj_tree_step3_raise", hand_tag))
|
self.status_lbl.configure(text=t("bj_tree_step3_raise", hand_tag))
|
||||||
dyn_chips = self._get_current_level_chips()
|
dyn_chips = self._get_current_level_chips()
|
||||||
|
|
@ -651,18 +741,18 @@ class BlackjackTableView:
|
||||||
for chip in dyn_chips:
|
for chip in dyn_chips:
|
||||||
if wallet >= chip:
|
if wallet >= chip:
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, f"+{chip} Gold",
|
col, f"+{chip} Gold",
|
||||||
self.ctx.assets.raw_btn, self.ctx.assets.raw_btn_active,
|
self.ctx.assets.raw_btn, self.ctx.assets.raw_btn_active,
|
||||||
lambda c=chip: self._on_step3_raise_yes(c),
|
lambda c=chip: self._on_step3_raise_yes(c),
|
||||||
sound_mgr=self.ctx.sounds, width=115, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=26, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=5)
|
).pack(pady=1)
|
||||||
|
|
||||||
ImageButton(
|
ImageButton(
|
||||||
row, t("bj_tree_btn_raise_no"),
|
col, t("bj_tree_btn_raise_no"),
|
||||||
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
self.ctx.assets.raw_sel, self.ctx.assets.raw_sel_active,
|
||||||
self._on_step3_raise_no,
|
self._on_step3_raise_no,
|
||||||
sound_mgr=self.ctx.sounds, width=190, height=38, font=("Helvetica", 10, "bold")
|
sound_mgr=self.ctx.sounds, width=170, height=28, font=("Helvetica", 9, "bold")
|
||||||
).pack(side="left", padx=8)
|
).pack(pady=2)
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# BUTTON-AKTIONEN SPIELER
|
# BUTTON-AKTIONEN SPIELER
|
||||||
|
|
@ -672,7 +762,6 @@ class BlackjackTableView:
|
||||||
wallet = self.bj_account["gold"]
|
wallet = self.bj_account["gold"]
|
||||||
dyn_chips = self._get_current_level_chips()
|
dyn_chips = self._get_current_level_chips()
|
||||||
|
|
||||||
# Solo ohne Bots und ohne gezogene Karte im Umlauf -> sofort aufdecken ohne unnötige Erhöhungs-Frage!
|
|
||||||
if not self.bots and not self.engine.cycle_card_drawn:
|
if not self.bots and not self.engine.cycle_card_drawn:
|
||||||
self._finish_current_hand_turn()
|
self._finish_current_hand_turn()
|
||||||
return
|
return
|
||||||
|
|
@ -728,7 +817,6 @@ class BlackjackTableView:
|
||||||
self._advance_to_erhoehen_or_next()
|
self._advance_to_erhoehen_or_next()
|
||||||
|
|
||||||
def _on_step2_draw_no(self):
|
def _on_step2_draw_no(self):
|
||||||
"""Keine neue Karte genommen -> cycle_card_drawn bleibt unverändert!"""
|
|
||||||
self.ctx.sounds.play("stand")
|
self.ctx.sounds.play("stand")
|
||||||
self._advance_to_erhoehen_or_next()
|
self._advance_to_erhoehen_or_next()
|
||||||
|
|
||||||
|
|
@ -812,7 +900,6 @@ class BlackjackTableView:
|
||||||
raw_deficit = max(0, self.engine.highest_bet - bot.bet_in_pot)
|
raw_deficit = max(0, self.engine.highest_bet - bot.bet_in_pot)
|
||||||
to_call = min(bot.gold, raw_deficit)
|
to_call = min(bot.gold, raw_deficit)
|
||||||
|
|
||||||
# 1. Offene Erhöhung mitgehen oder austreten?
|
|
||||||
if to_call > 0:
|
if to_call > 0:
|
||||||
if not self.bot_ai.decide_step1_mitgehen(
|
if not self.bot_ai.decide_step1_mitgehen(
|
||||||
bot, self.engine.highest_bet, upcard, self.engine.deck.remaining()
|
bot, self.engine.highest_bet, upcard, self.engine.deck.remaining()
|
||||||
|
|
@ -826,13 +913,11 @@ class BlackjackTableView:
|
||||||
self.ctx.sounds.play("click")
|
self.ctx.sounds.play("click")
|
||||||
self.engine.bot_add_gold_to_pot(bot, to_call)
|
self.engine.bot_add_gold_to_pot(bot, to_call)
|
||||||
|
|
||||||
# Im Settle-Modus nach kartenlosem Umlauf nur noch begleichen -> fertig!
|
|
||||||
if self.settle_only_mode:
|
if self.settle_only_mode:
|
||||||
bot.status_text = t("bj_bot_action_call", to_call)
|
bot.status_text = t("bj_bot_action_call", to_call)
|
||||||
self._finish_bot_step()
|
self._finish_bot_step()
|
||||||
return
|
return
|
||||||
|
|
||||||
# 2. Karte ziehen oder keine neue Karte?
|
|
||||||
drew_card = False
|
drew_card = False
|
||||||
if not bot.cards_locked and not bot.doubled:
|
if not bot.cards_locked and not bot.doubled:
|
||||||
if self.bot_ai.wants_double_down(bot, upcard, self.engine.highest_bet, self.engine.deck.remaining()):
|
if self.bot_ai.wants_double_down(bot, upcard, self.engine.highest_bet, self.engine.deck.remaining()):
|
||||||
|
|
@ -870,7 +955,6 @@ class BlackjackTableView:
|
||||||
self._finish_bot_step()
|
self._finish_bot_step()
|
||||||
return
|
return
|
||||||
|
|
||||||
# 3. Optional erhöhen (nur wenn im aktuellen Umlauf schon eine Karte gezogen wurde oder man Druck macht)
|
|
||||||
raise_amt = self.bot_ai.decide_step3_erhoehen(
|
raise_amt = self.bot_ai.decide_step3_erhoehen(
|
||||||
bot, dyn_chips, self.engine.deck.remaining(), upcard
|
bot, dyn_chips, self.engine.deck.remaining(), upcard
|
||||||
)
|
)
|
||||||
|
|
@ -952,10 +1036,8 @@ class BlackjackTableView:
|
||||||
return t("bj_rank_points", val, len(cards))
|
return t("bj_rank_points", val, len(cards))
|
||||||
|
|
||||||
def _collect_showdown_snapshot(self, instant_777_winner: str | None = None) -> list[dict]:
|
def _collect_showdown_snapshot(self, instant_777_winner: str | None = None) -> list[dict]:
|
||||||
"""Serialisiert alle Tischhände JSON-sicher für Popup & Devil's-Deal-Save."""
|
|
||||||
snapshot: list[dict] = []
|
snapshot: list[dict] = []
|
||||||
|
|
||||||
# 1. Haus-Dealer
|
|
||||||
d_cards = self.engine.dealer_hand
|
d_cards = self.engine.dealer_hand
|
||||||
d_val, _ = HandEvaluator.evaluate(d_cards)
|
d_val, _ = HandEvaluator.evaluate(d_cards)
|
||||||
d_rank = self.engine._hand_rank(d_cards)
|
d_rank = self.engine._hand_rank(d_cards)
|
||||||
|
|
@ -971,7 +1053,6 @@ class BlackjackTableView:
|
||||||
"rank_tuple": list(d_rank),
|
"rank_tuple": list(d_rank),
|
||||||
})
|
})
|
||||||
|
|
||||||
# 2. Spieler-Hand / Split-Hände
|
|
||||||
multi_p = len(self.engine.player_hands) > 1
|
multi_p = len(self.engine.player_hands) > 1
|
||||||
for idx, h in enumerate(self.engine.player_hands):
|
for idx, h in enumerate(self.engine.player_hands):
|
||||||
hr = self.engine._hand_rank(h.cards, is_split=h.is_split_hand) if h.is_active_in_pot else (0, 0)
|
hr = self.engine._hand_rank(h.cards, is_split=h.is_split_hand) if h.is_active_in_pot else (0, 0)
|
||||||
|
|
@ -987,7 +1068,6 @@ class BlackjackTableView:
|
||||||
"rank_tuple": list(hr),
|
"rank_tuple": list(hr),
|
||||||
})
|
})
|
||||||
|
|
||||||
# 3. Alle Bots am Tisch
|
|
||||||
for b in self.bots:
|
for b in self.bots:
|
||||||
br = self.engine._hand_rank(b.hand) if b.is_active_in_pot else (0, 0)
|
br = self.engine._hand_rank(b.hand) if b.is_active_in_pot else (0, 0)
|
||||||
snapshot.append({
|
snapshot.append({
|
||||||
|
|
@ -1002,7 +1082,6 @@ class BlackjackTableView:
|
||||||
"rank_tuple": list(br),
|
"rank_tuple": list(br),
|
||||||
})
|
})
|
||||||
|
|
||||||
# Gewinner-Markierung anhand derselben Showdown-Regeln wie BlackjackEngine
|
|
||||||
contenders = [s for s in snapshot if s["role"] != "DEALER" and not s["busted"] and not s["folded"]]
|
contenders = [s for s in snapshot if s["role"] != "DEALER" and not s["busted"] and not s["folded"]]
|
||||||
dealer_entry = snapshot[0]
|
dealer_entry = snapshot[0]
|
||||||
|
|
||||||
|
|
@ -1193,7 +1272,6 @@ class BlackjackTableView:
|
||||||
else:
|
else:
|
||||||
headline = t("bj_popup_tie")
|
headline = t("bj_popup_tie")
|
||||||
|
|
||||||
# Lokalisierte Hand-Karten & Begründung aufbauen
|
|
||||||
showdown_hands = []
|
showdown_hands = []
|
||||||
raw_snap = payload.get("showdown_snapshot", [])
|
raw_snap = payload.get("showdown_snapshot", [])
|
||||||
for s in raw_snap:
|
for s in raw_snap:
|
||||||
|
|
@ -1279,11 +1357,9 @@ class BlackjackTableView:
|
||||||
top_rank = winners[0]["rank_tuple"]
|
top_rank = winners[0]["rank_tuple"]
|
||||||
winner_names_str = ", ".join(dict.fromkeys(w["owner_label"] for w in winners if not w["is_dealer"]))
|
winner_names_str = ", ".join(dict.fromkeys(w["owner_label"] for w in winners if not w["is_dealer"]))
|
||||||
|
|
||||||
# Fall 1: Gleichstand mit dem Haus-Dealer (Push)
|
|
||||||
if dealer["is_winner"] and len(winners) > 1:
|
if dealer["is_winner"] and len(winners) > 1:
|
||||||
return t("bj_reason_dealer_tie_push", dealer["rank_label"])
|
return t("bj_reason_dealer_tie_push", dealer["rank_label"])
|
||||||
|
|
||||||
# Fall 2: Jemand hat ebenfalls 21 Punkte, verliert aber wegen 2-Karten-Blackjack oder 7-7-7!
|
|
||||||
losers_with_21 = [
|
losers_with_21 = [
|
||||||
h for h in showdown_hands
|
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
|
if not h["is_winner"] and not h["busted"] and not h["folded"] and h["rank_tuple"][1] == 21
|
||||||
|
|
@ -1294,16 +1370,13 @@ class BlackjackTableView:
|
||||||
if top_rank == (2, 21) and losers_with_21:
|
if top_rank == (2, 21) and losers_with_21:
|
||||||
return t("bj_reason_nat_beats_reg21", win_label)
|
return t("bj_reason_nat_beats_reg21", win_label)
|
||||||
|
|
||||||
# Fall 3: Mehrere Spieler/Bots teilen sich den Sieg
|
|
||||||
non_dealer_winners = [w for w in winners if not w["is_dealer"]]
|
non_dealer_winners = [w for w in winners if not w["is_dealer"]]
|
||||||
if len(non_dealer_winners) > 1:
|
if len(non_dealer_winners) > 1:
|
||||||
return t("bj_reason_split_pot", non_dealer_winners[0]["rank_label"], winner_names_str)
|
return t("bj_reason_split_pot", non_dealer_winners[0]["rank_label"], winner_names_str)
|
||||||
|
|
||||||
# Fall 4: Haus-Dealer hat sich überkauft
|
|
||||||
if dealer["busted"] and not dealer["is_winner"]:
|
if dealer["busted"] and not dealer["is_winner"]:
|
||||||
return t("bj_reason_dealer_bust", dealer["rank_label"], win_label, winners[0]["rank_label"])
|
return t("bj_reason_dealer_bust", dealer["rank_label"], win_label, winners[0]["rank_label"])
|
||||||
|
|
||||||
# Fall 5: Regulärer Punktesieg gegen die nächstbeste Hand am Tisch
|
|
||||||
others_alive = [
|
others_alive = [
|
||||||
h for h in showdown_hands
|
h for h in showdown_hands
|
||||||
if not h["is_winner"] and not h["busted"] and not h["folded"]
|
if not h["is_winner"] and not h["busted"] and not h["folded"]
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ BOT_DEITY_LEVEL = 6
|
||||||
BOT_LEVEL_COUNT = 7
|
BOT_LEVEL_COUNT = 7
|
||||||
|
|
||||||
# --- Blackjack ---
|
# --- Blackjack ---
|
||||||
BJ_MAX_BOTS = 3
|
BJ_MAX_BOTS = 4
|
||||||
BJ_STARTING_GOLD = 1000
|
BJ_STARTING_GOLD = 1000
|
||||||
BJ_INITIAL_ANTE = 10
|
BJ_INITIAL_ANTE = 10
|
||||||
BJ_DEFAULT_BET = 10
|
BJ_DEFAULT_BET = 10
|
||||||
|
|
|
||||||
BIN
user_data.db
BIN
user_data.db
Binary file not shown.
Loading…
Reference in New Issue