Release v0.9.0-beta: compact/mobile split-screen layouts, slide-in burger drawer & modular architecture
This commit is contained in:
parent
31b28652db
commit
a81c8f02de
|
|
@ -0,0 +1,96 @@
|
||||||
|
function DisplayTree {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Path,
|
||||||
|
[string]$Indent = "",
|
||||||
|
[bool]$IsRoot = $false,
|
||||||
|
[switch]$Essentials,
|
||||||
|
[string[]]$ExcludeDirs = @(
|
||||||
|
# Node / Build
|
||||||
|
"node_modules", "build", "dist",
|
||||||
|
# Git
|
||||||
|
".git",
|
||||||
|
# Python virtual envs, pip & package caches
|
||||||
|
".env*", "env", "venv*", ".venv*",
|
||||||
|
"__pycache__", "site-packages", "Lib", "Include", "Scripts",
|
||||||
|
"*.egg-info", "*.dist-info", ".eggs", "wheels", "pip-wheel-metadata",
|
||||||
|
".pytest_cache", ".mypy_cache", ".ruff_cache", ".tox", ".nox"
|
||||||
|
),
|
||||||
|
[string[]]$ExcludeFiles = @(
|
||||||
|
# Git files
|
||||||
|
".gitignore", ".gitattributes", ".gitmodules", ".gitkeep",
|
||||||
|
# Python init & compiled bytecode
|
||||||
|
"__init__.py", "*.pyc", "*.pyo", "*.pyd"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Apply extra exclusions once at the root level when --essentials is active
|
||||||
|
if ($IsRoot -and $Essentials) {
|
||||||
|
$ExcludeDirs += "build_scripts"
|
||||||
|
$ExcludeFiles += @(
|
||||||
|
# Readme files
|
||||||
|
"readme*",
|
||||||
|
# Image formats
|
||||||
|
"*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.svg", "*.ico",
|
||||||
|
"*.webp", "*.tiff", "*.tif", "*.heic", "*.avif", "*.raw", "*.psd",
|
||||||
|
# Music / Audio formats
|
||||||
|
"*.mp3", "*.wav", "*.flac", "*.aac", "*.ogg", "*.oga", "*.wma",
|
||||||
|
"*.m4a", "*.opus", "*.aiff", "*.alac", "*.mid", "*.midi",
|
||||||
|
# Fonts, Databases & PowerShell scripts
|
||||||
|
"*.ttf", "*.db", "*.ps1"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
$outputLines = New-Object System.Collections.Generic.List[string]
|
||||||
|
|
||||||
|
# Recurse into directories (skipping any match in $ExcludeDirs)
|
||||||
|
Get-ChildItem -LiteralPath $Path -Directory -Force -ErrorAction SilentlyContinue | Where-Object {
|
||||||
|
$itemName = $_.Name
|
||||||
|
-not ($ExcludeDirs | Where-Object { $itemName -like $_ })
|
||||||
|
} | ForEach-Object {
|
||||||
|
$subLines = DisplayTree -Path $_.FullName -Indent " $Indent" -Essentials:$Essentials -ExcludeDirs $ExcludeDirs -ExcludeFiles $ExcludeFiles
|
||||||
|
|
||||||
|
# In --essentials mode, hide folders that have zero matching files/subfolders left
|
||||||
|
if (-not $Essentials -or $subLines.Count -gt 0) {
|
||||||
|
$outputLines.Add("$Indent|--- $($_.Name)")
|
||||||
|
foreach ($line in $subLines) {
|
||||||
|
$outputLines.Add($line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Collect files (skipping any match in $ExcludeFiles)
|
||||||
|
Get-ChildItem -LiteralPath $Path -File -Force -ErrorAction SilentlyContinue | Where-Object {
|
||||||
|
$itemName = $_.Name
|
||||||
|
-not ($ExcludeFiles | Where-Object { $itemName -like $_ })
|
||||||
|
} | ForEach-Object {
|
||||||
|
$lineInfo = ""
|
||||||
|
|
||||||
|
if ($Essentials -and $_.Extension -eq ".py") {
|
||||||
|
$rowCount = [System.IO.File]::ReadAllLines($_.FullName).Length
|
||||||
|
$lineInfo = " ($rowCount lines)"
|
||||||
|
}
|
||||||
|
|
||||||
|
$outputLines.Add("$Indent|--- $($_.Name)$lineInfo")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print at root; return list on recursive calls
|
||||||
|
if ($IsRoot) {
|
||||||
|
$rootName = (Get-Item -LiteralPath $Path -Force).Name
|
||||||
|
Write-Host $rootName
|
||||||
|
foreach ($line in $outputLines) {
|
||||||
|
Write-Host $line
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ,$outputLines
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse CLI arguments passed to .\DisplayTree.ps1
|
||||||
|
$useEssentials = ($args -contains "--essentials") -or ($args -contains "-essentials")
|
||||||
|
$targetPath = ($args | Where-Object { $_ -notlike "-*" } | Select-Object -First 1)
|
||||||
|
if (-not $targetPath) {
|
||||||
|
$targetPath = ".\"
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayTree -Path $targetPath -IsRoot $true -Essentials:$useEssentials
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -2,10 +2,10 @@
|
||||||
# controller/app_context.py
|
# controller/app_context.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from view.unified_stats_view import UnifiedStatsView
|
from view.stats.unified_stats_view import UnifiedStatsView
|
||||||
from view.widgets.goth_dropdown import GothDropdown
|
from view.widgets.dropdown.goth_dropdown import GothDropdown
|
||||||
from view.widgets.goth_topbar import GothTopbar, format_compact_user_badge
|
from view.widgets.bars.goth_topbar import GothTopbar, format_compact_user_badge
|
||||||
|
|
||||||
__all__ = ["AppContext", "GothTopbar", "UnifiedStatsView", "format_compact_user_badge"]
|
__all__ = ["AppContext", "GothTopbar", "UnifiedStatsView", "format_compact_user_badge"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ from pathlib import Path
|
||||||
|
|
||||||
from controller.app_context import AppContext
|
from controller.app_context import AppContext
|
||||||
from controller.game_loader import GameLoader
|
from controller.game_loader import GameLoader
|
||||||
from games.solitaire.base.solitaire_tap_prefs import invalidate_tap_prefs_cache
|
from games.solitaire.base.session.solitaire_tap_prefs import invalidate_tap_prefs_cache
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from models.db_locator import DbLocator
|
from models.db.db_locator import DbLocator
|
||||||
from models.online_session import OnlineSessionClient
|
from models.online_session import OnlineSessionClient
|
||||||
from models.sound_manager import SoundManager
|
from models.sound_manager import SoundManager
|
||||||
import resources.code_res.i18n as i18n
|
import resources.code_res.i18n as i18n
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.image_button import set_button_hover_help_enabled
|
from view.widgets.buttons.image_button import set_button_hover_help_enabled
|
||||||
|
|
||||||
|
|
||||||
class AppController:
|
class AppController:
|
||||||
|
|
@ -269,7 +269,7 @@ class AppController:
|
||||||
fresh["online_endpoint"] = self.online_session.endpoint_label
|
fresh["online_endpoint"] = self.online_session.endpoint_label
|
||||||
self.active_profile = fresh
|
self.active_profile = fresh
|
||||||
ctx = AppContext(self, game_folder="")
|
ctx = AppContext(self, game_folder="")
|
||||||
from view.unified_stats_view import UnifiedStatsView
|
from view.stats.unified_stats_view import UnifiedStatsView
|
||||||
UnifiedStatsView.open(ctx, game_endpoint=None, on_back=None)
|
UnifiedStatsView.open(ctx, game_endpoint=None, on_back=None)
|
||||||
|
|
||||||
def show_settings(
|
def show_settings(
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -3,8 +3,8 @@
|
||||||
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
||||||
from games.blackjack.models.hand_evaluator import HandEvaluator
|
from games.blackjack.models.hand_evaluator import HandEvaluator
|
||||||
from games.blackjack.models.player_hand import PlayerHand
|
from games.blackjack.models.player_hand import PlayerHand
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from models.deck import Deck
|
from models.cards.deck import Deck
|
||||||
from resources.code_res.game_constants import BJ_DEALER_STAND, BJ_RESHUFFLE_RATIO, BJ_TARGET_SCORE
|
from resources.code_res.game_constants import BJ_DEALER_STAND, BJ_RESHUFFLE_RATIO, BJ_TARGET_SCORE
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import random
|
import random
|
||||||
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
||||||
from games.blackjack.models.hand_evaluator import HandEvaluator
|
from games.blackjack.models.hand_evaluator import HandEvaluator
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACE_RANK, BJ_STARTING_GOLD, BOT_DEITY_LEVEL, FACE_RANKS, SEVEN_RANK
|
ACE_RANK, BJ_STARTING_GOLD, BOT_DEITY_LEVEL, FACE_RANKS, SEVEN_RANK
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/blackjack/models/bot_seat.py
|
# games/blackjack/models/bot_seat.py
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from resources.code_res.game_constants import BJ_STARTING_GOLD
|
from resources.code_res.game_constants import BJ_STARTING_GOLD
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/blackjack/models/hand_evaluator.py
|
# games/blackjack/models/hand_evaluator.py
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from resources.code_res.game_constants import ACE_RANK, BJ_TARGET_SCORE, SEVEN_RANK
|
from resources.code_res.game_constants import ACE_RANK, BJ_TARGET_SCORE, SEVEN_RANK
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/blackjack/models/player_hand.py
|
# games/blackjack/models/player_hand.py
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/blackjack/start.py
|
# games/blackjack/start.py
|
||||||
from games.blackjack.views.blackjack_menu_view import BlackjackMenuView
|
from games.blackjack.views.blackjack_menu_view import BlackjackMenuView
|
||||||
from games.blackjack.views.blackjack_table_view import BlackjackTableView
|
from games.blackjack.views.blackjack_table_view import BlackjackTableView
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import CAT_LUCK
|
from resources.code_res.game_constants import CAT_LUCK
|
||||||
|
|
||||||
GAME_TITLE_KEY = "game_title_blackjack"
|
GAME_TITLE_KEY = "game_title_blackjack"
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -13,11 +13,13 @@ from resources.code_res.game_constants import (
|
||||||
FG_COLOR,
|
FG_COLOR,
|
||||||
FONT_COLOR_TITLE_MAIN,
|
FONT_COLOR_TITLE_MAIN,
|
||||||
FONT_SIZE_BODY,
|
FONT_SIZE_BODY,
|
||||||
|
FONT_SIZE_SMALL_MIN,
|
||||||
PLAYING_CARD_SIZE,
|
PLAYING_CARD_SIZE,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
|
|
||||||
BJ_DEALER_CARD_SIZE = (86, 125)
|
BJ_DEALER_CARD_SIZE = (86, 125)
|
||||||
|
BJ_COMPACT_BOT_ROW_H = 112
|
||||||
|
|
||||||
BJ_SEAT_LAYOUT_BY_COUNT = {
|
BJ_SEAT_LAYOUT_BY_COUNT = {
|
||||||
1: (2,),
|
1: (2,),
|
||||||
|
|
@ -28,7 +30,7 @@ BJ_SEAT_LAYOUT_BY_COUNT = {
|
||||||
|
|
||||||
|
|
||||||
class BlackjackArenaRenderer:
|
class BlackjackArenaRenderer:
|
||||||
"""Zeichnet Dealer, Pot, Kultisten-Ecken und Spielerhände (inkl. Split) auf das Arena-Canvas."""
|
"""Zeichnet Dealer, Pot, Kultisten (Ecken auf Desktop | Top-Leiste auf Kompakt) und Spielerhände."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def hand_state_suffix(hand: PlayerHand) -> str:
|
def hand_state_suffix(hand: PlayerHand) -> str:
|
||||||
|
|
@ -49,21 +51,32 @@ class BlackjackArenaRenderer:
|
||||||
) -> None:
|
) -> None:
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
t_cx = (tx1 + tx2) // 2
|
t_cx = (tx1 + tx2) // 2
|
||||||
t_h = max(260, ty2 - ty1)
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
|
||||||
|
if compact:
|
||||||
|
top_reserve = (BJ_COMPACT_BOT_ROW_H + 10) if view.bots else 8
|
||||||
|
felt_top = ty1 + top_reserve
|
||||||
|
felt_bot = player_top_y - 8
|
||||||
|
avail_felt_h = max(140, felt_bot - felt_top)
|
||||||
|
d_scale = min(1.0, max(0.76, (avail_felt_h - 54) / max(1, BJ_DEALER_CARD_SIZE[1])))
|
||||||
|
dc_sz = (int(round(BJ_DEALER_CARD_SIZE[0] * d_scale)), int(round(BJ_DEALER_CARD_SIZE[1] * d_scale)))
|
||||||
|
dc_h = dc_sz[1]
|
||||||
|
d_cards_cy = felt_top + dc_h // 2 + max(4, (avail_felt_h - dc_h - 48) // 3)
|
||||||
|
else:
|
||||||
|
t_h = max(260, ty2 - ty1)
|
||||||
felt_top = ty1 + max(36, int(t_h * 0.15))
|
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)
|
felt_bot = min(ty2 - max(28, int(t_h * 0.12)), player_top_y - 12)
|
||||||
|
dc_sz = BJ_DEALER_CARD_SIZE
|
||||||
_dc_w, dc_h = BJ_DEALER_CARD_SIZE
|
dc_h = dc_sz[1]
|
||||||
avail_felt_h = max(170, felt_bot - felt_top)
|
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_cards_cy = felt_top + min(dc_h // 2 + 12, int(avail_felt_h * 0.34))
|
||||||
|
|
||||||
d_photos = []
|
d_photos = []
|
||||||
for c_idx, card in enumerate(view.engine.dealer_hand):
|
for c_idx, card in enumerate(view.engine.dealer_hand):
|
||||||
photo = (
|
photo = (
|
||||||
view.ctx.assets.get_card_back_photo(color=view.cfg["back_color"], size=BJ_DEALER_CARD_SIZE)
|
view.ctx.assets.get_card_back_photo(color=view.cfg["back_color"], size=dc_sz)
|
||||||
if c_idx == 1 and not reveal_dealer
|
if c_idx == 1 and not reveal_dealer
|
||||||
else view.ctx.assets.get_card_photo(card.image_filename, size=BJ_DEALER_CARD_SIZE)
|
else view.ctx.assets.get_card_photo(card.image_filename, size=dc_sz)
|
||||||
)
|
)
|
||||||
if photo:
|
if photo:
|
||||||
view._photo_refs.append(photo)
|
view._photo_refs.append(photo)
|
||||||
|
|
@ -71,26 +84,27 @@ class BlackjackArenaRenderer:
|
||||||
|
|
||||||
if d_photos:
|
if d_photos:
|
||||||
view._draw_fanned_cards_on_canvas(
|
view._draw_fanned_cards_on_canvas(
|
||||||
t_cx, d_cards_cy, d_photos, BJ_DEALER_CARD_SIZE, visible_step=38, max_width=340
|
t_cx, d_cards_cy, d_photos, dc_sz, visible_step=34 if compact else 38, max_width=320
|
||||||
)
|
)
|
||||||
|
|
||||||
pot_txt = t("bj_pot_banner", view.engine.pot).split("|")[0].strip()
|
pot_txt = t("bj_pot_banner", view.engine.pot).split("|")[0].strip()
|
||||||
pot_cy = min(
|
pot_cy = min(
|
||||||
felt_bot - 22,
|
felt_bot - 20,
|
||||||
max(d_cards_cy + dc_h // 2 + 34, (d_cards_cy + dc_h // 2 + felt_bot) // 2),
|
max(d_cards_cy + dc_h // 2 + (26 if compact else 34), (d_cards_cy + dc_h // 2 + felt_bot) // 2),
|
||||||
)
|
)
|
||||||
pot_size = max(16, FONT_SIZE_BODY + 1)
|
pot_size = max(15 if compact else 16, FONT_SIZE_BODY + (0 if compact else 1))
|
||||||
pot_ph = view._make_goth_photo(pot_txt, size_px=pot_size, color=FONT_COLOR_TITLE_MAIN)
|
pot_ph = view._make_goth_photo(pot_txt, size_px=pot_size, color=FONT_COLOR_TITLE_MAIN)
|
||||||
if pot_ph is not None:
|
if pot_ph is not None:
|
||||||
bw, bh = max(230, pot_ph.width() + 64), max(40, pot_ph.height() + 18)
|
bw, bh = max(210, pot_ph.width() + 56), max(36, pot_ph.height() + 16)
|
||||||
view._draw_framed_panel(t_cx, pot_cy, bw, bh, frame_style="gold")
|
view._draw_framed_panel(t_cx, pot_cy, bw, bh, frame_style="gold")
|
||||||
view.arena_canvas.create_image(t_cx, pot_cy, image=pot_ph, anchor="center", tags="fg")
|
view.arena_canvas.create_image(t_cx, pot_cy, image=pot_ph, anchor="center", tags="fg")
|
||||||
else:
|
else:
|
||||||
view._draw_framed_panel(t_cx, pot_cy, 240, 40, frame_style="gold")
|
view._draw_framed_panel(t_cx, pot_cy, 220, 38, frame_style="gold")
|
||||||
view._place_goth_photo_or_fallback(t_cx, pot_cy, None, pot_txt, pot_size, ACCENT_GOLD)
|
view._place_goth_photo_or_fallback(t_cx, pot_cy, None, pot_txt, pot_size, ACCENT_GOLD)
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def draw_bots_at_corners(
|
def draw_bots_at_corners(
|
||||||
|
cls,
|
||||||
view,
|
view,
|
||||||
cw: int,
|
cw: int,
|
||||||
ch: int,
|
ch: int,
|
||||||
|
|
@ -102,6 +116,9 @@ class BlackjackArenaRenderer:
|
||||||
) -> None:
|
) -> None:
|
||||||
if not view.bots:
|
if not view.bots:
|
||||||
return
|
return
|
||||||
|
if getattr(view, "is_compact_arena", False):
|
||||||
|
cls._draw_bots_top_strip(view, cw, pad_x, pad_top, reveal_opponents)
|
||||||
|
return
|
||||||
|
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
bc_w, bc_h = BJ_BOT_CARD_SIZE
|
bc_w, bc_h = BJ_BOT_CARD_SIZE
|
||||||
|
|
@ -126,84 +143,131 @@ class BlackjackArenaRenderer:
|
||||||
|
|
||||||
is_turn = (bot_i == view.active_bot_idx)
|
is_turn = (bot_i == view.active_bot_idx)
|
||||||
is_out = (bot.folded or bot.busted)
|
is_out = (bot.folded or bot.busted)
|
||||||
frame_style = "gold" if is_turn else "purple"
|
|
||||||
status_border = ERROR_FG if is_out else None
|
|
||||||
|
|
||||||
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
|
||||||
name_col = ACCENT_GOLD if is_turn else ACCENT_GOTH
|
name_col = ACCENT_GOLD if is_turn else ACCENT_GOTH
|
||||||
gold_txt = t("bj_bot_gold_lbl", bot.gold)
|
gold_txt = t("bj_bot_gold_lbl", bot.gold)
|
||||||
|
info_txt = cls._bot_info_text(bot, reveal_opponents)
|
||||||
if reveal_opponents and bot.hand:
|
|
||||||
b_val, _ = HandEvaluator.evaluate(bot.hand)
|
|
||||||
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)
|
|
||||||
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 = ""
|
|
||||||
|
|
||||||
info_col = ERROR_FG if is_out else FG_COLOR
|
info_col = ERROR_FG if is_out else FG_COLOR
|
||||||
|
|
||||||
name_ph = view._make_goth_photo(disp_name, name_sz, name_col, max_width=220)
|
name_ph = view._make_goth_photo(disp_name, name_sz, name_col, max_width=220)
|
||||||
gold_ph = view._make_goth_photo(gold_txt, sub_sz, ACCENT_GOLD)
|
gold_ph = view._make_goth_photo(gold_txt, sub_sz, ACCENT_GOLD)
|
||||||
info_ph = view._make_goth_photo(info_txt, sub_sz, info_col, max_width=220)
|
info_ph = view._make_goth_photo(info_txt, sub_sz, info_col, max_width=220)
|
||||||
|
|
||||||
widest_txt = max((ph.width() for ph in (name_ph, gold_ph, info_ph) if ph), default=140)
|
widest_txt = max((ph.width() for ph in (name_ph, gold_ph, info_ph) if ph), default=140)
|
||||||
box_w = max(base_box_w, min(268, widest_txt + 54))
|
box_w = max(base_box_w, min(268, widest_txt + 54))
|
||||||
|
|
||||||
bx = (
|
bx = (
|
||||||
max(pad_x + box_w // 2, tx1 + int(box_w * 0.36))
|
max(pad_x + box_w // 2, tx1 + int(box_w * 0.36))
|
||||||
if is_left_side else min(cw - pad_x - box_w // 2, tx2 - int(box_w * 0.36))
|
if is_left_side else min(cw - pad_x - box_w // 2, tx2 - int(box_w * 0.36))
|
||||||
)
|
)
|
||||||
|
|
||||||
view._draw_framed_panel(bx, by, box_w, box_h, frame_style=frame_style, status_border=status_border)
|
view._draw_framed_panel(
|
||||||
|
bx, by, box_w, box_h,
|
||||||
|
frame_style="gold" if is_turn else "purple",
|
||||||
|
status_border=ERROR_FG if is_out else None,
|
||||||
|
)
|
||||||
top_y, bot_y = by - box_h // 2, by + box_h // 2
|
top_y, bot_y = by - box_h // 2, by + box_h // 2
|
||||||
view._place_goth_photo_or_fallback(bx, top_y + 23, name_ph, disp_name, name_sz, name_col)
|
view._place_goth_photo_or_fallback(bx, top_y + 23, name_ph, disp_name, name_sz, name_col)
|
||||||
view._place_goth_photo_or_fallback(bx, top_y + 42, gold_ph, gold_txt, sub_sz, ACCENT_GOLD)
|
view._place_goth_photo_or_fallback(bx, top_y + 42, gold_ph, gold_txt, sub_sz, ACCENT_GOLD)
|
||||||
|
|
||||||
show_faces = reveal_opponents or bot.busted
|
show_faces = reveal_opponents or bot.busted
|
||||||
bot_photos = []
|
bot_photos = [
|
||||||
for card in bot.hand:
|
ph for card in bot.hand
|
||||||
photo = (
|
if (ph := (
|
||||||
view.ctx.assets.get_card_photo(card.image_filename, size=cur_card_sz)
|
view.ctx.assets.get_card_photo(card.image_filename, size=cur_card_sz)
|
||||||
if show_faces else view.ctx.assets.get_card_back_photo(color=view.cfg["back_color"], size=cur_card_sz)
|
if show_faces else view.ctx.assets.get_card_back_photo(color=view.cfg["back_color"], size=cur_card_sz)
|
||||||
)
|
))
|
||||||
if photo:
|
]
|
||||||
view._photo_refs.append(photo)
|
view._photo_refs.extend(bot_photos)
|
||||||
bot_photos.append(photo)
|
|
||||||
|
|
||||||
if bot_photos:
|
if bot_photos:
|
||||||
view._draw_fanned_cards_on_canvas(
|
view._draw_fanned_cards_on_canvas(bx, by + 6, bot_photos, cur_card_sz, visible_step=25, max_width=box_w - 36)
|
||||||
bx, by + 6, bot_photos, cur_card_sz, visible_step=25, max_width=box_w - 36
|
|
||||||
)
|
|
||||||
view._place_goth_photo_or_fallback(bx, bot_y - 21, info_ph, info_txt, sub_sz, info_col)
|
view._place_goth_photo_or_fallback(bx, bot_y - 21, info_ph, info_txt, sub_sz, info_col)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _draw_bots_top_strip(cls, view, cw: int, pad_x: int, pad_top: int, reveal_opponents: bool) -> None:
|
||||||
|
"""Zeichnet 1..4 Kultisten im Kompaktmodus nebeneinander in einer oberen Reihe."""
|
||||||
|
n = len(view.bots)
|
||||||
|
gap = 6
|
||||||
|
avail_w = max(320, cw - 2 * pad_x)
|
||||||
|
box_w = min(204, (avail_w - (n - 1) * gap) // max(1, n))
|
||||||
|
box_h = BJ_COMPACT_BOT_ROW_H
|
||||||
|
start_x = (cw - (n * box_w + (n - 1) * gap)) // 2 + box_w // 2
|
||||||
|
by = pad_top + box_h // 2 + 2
|
||||||
|
|
||||||
|
mini_sz = (36, 52)
|
||||||
|
name_sz = max(12, FONT_SIZE_SMALL_MIN)
|
||||||
|
sub_sz = max(11, FONT_SIZE_SMALL_MIN - 1)
|
||||||
|
max_tw = max(72, box_w - 18)
|
||||||
|
|
||||||
|
for bot_i, bot in enumerate(view.bots):
|
||||||
|
bx = start_x + bot_i * (box_w + gap)
|
||||||
|
is_turn = (bot_i == view.active_bot_idx)
|
||||||
|
is_out = (bot.folded or bot.busted)
|
||||||
|
|
||||||
|
view._draw_framed_panel(
|
||||||
|
bx, by, box_w, box_h,
|
||||||
|
frame_style="gold" if is_turn else "purple",
|
||||||
|
status_border=ERROR_FG if is_out else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
disp_name = f"{bot.name} ({bot.gold}g)"
|
||||||
|
name_col = ACCENT_GOLD if is_turn else ACCENT_GOTH
|
||||||
|
info_txt = cls._bot_info_text(bot, reveal_opponents)
|
||||||
|
info_col = ERROR_FG if is_out else FG_COLOR
|
||||||
|
|
||||||
|
name_ph = view._make_goth_photo(disp_name, name_sz, name_col, max_width=max_tw)
|
||||||
|
info_ph = view._make_goth_photo(info_txt, sub_sz, info_col, max_width=max_tw)
|
||||||
|
view._place_goth_photo_or_fallback(bx, by - box_h // 2 + 16, name_ph, disp_name, name_sz, name_col)
|
||||||
|
|
||||||
|
show_faces = reveal_opponents or bot.busted
|
||||||
|
bot_photos = [
|
||||||
|
ph for card in bot.hand
|
||||||
|
if (ph := (
|
||||||
|
view.ctx.assets.get_card_photo(card.image_filename, size=mini_sz)
|
||||||
|
if show_faces else view.ctx.assets.get_card_back_photo(color=view.cfg["back_color"], size=mini_sz)
|
||||||
|
))
|
||||||
|
]
|
||||||
|
view._photo_refs.extend(bot_photos)
|
||||||
|
if bot_photos:
|
||||||
|
view._draw_fanned_cards_on_canvas(bx, by + 2, bot_photos, mini_sz, visible_step=16, max_width=box_w - 20)
|
||||||
|
|
||||||
|
view._place_goth_photo_or_fallback(bx, by + box_h // 2 - 14, info_ph, info_txt, sub_sz, info_col)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _bot_info_text(bot, reveal_opponents: bool) -> str:
|
||||||
|
if reveal_opponents and bot.hand:
|
||||||
|
b_val, _ = HandEvaluator.evaluate(bot.hand)
|
||||||
|
if bot.folded:
|
||||||
|
return t("bj_rank_folded", b_val)
|
||||||
|
if bot.busted:
|
||||||
|
return t("bj_rank_busted", b_val)
|
||||||
|
return t("bj_bot_showdown_val", b_val, bot.bet_in_pot)
|
||||||
|
if bot.status_text:
|
||||||
|
return bot.status_text
|
||||||
|
if bot.hand:
|
||||||
|
return t("bj_bot_cards_hidden", len(bot.hand), bot.bet_in_pot)
|
||||||
|
return ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def draw_player_hands(cls, view, cw: int, player_zone_top: int, player_zone_bot: int) -> None:
|
def draw_player_hands(cls, view, cw: int, player_zone_top: int, player_zone_bot: int) -> None:
|
||||||
hands = view.engine.player_hands
|
hands = view.engine.player_hands
|
||||||
if not hands:
|
if not hands:
|
||||||
return
|
return
|
||||||
|
|
||||||
avail_h = max(140, player_zone_bot - player_zone_top)
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
avail_h = max(136 if compact else 140, player_zone_bot - player_zone_top)
|
||||||
zone_cy = (player_zone_top + player_zone_bot) // 2
|
zone_cy = (player_zone_top + player_zone_bot) // 2
|
||||||
|
|
||||||
if len(hands) == 1:
|
if len(hands) == 1:
|
||||||
h = hands[0]
|
h = hands[0]
|
||||||
base_w, base_h = PLAYING_CARD_SIZE
|
base_w, base_h = PLAYING_CARD_SIZE
|
||||||
scale = max(88, min(base_h, avail_h - 52)) / max(1, base_h)
|
scale = max(84, min(base_h, avail_h - 48)) / max(1, base_h)
|
||||||
card_sz = (max(60, int(round(base_w * scale))), int(round(base_h * scale)))
|
card_sz = (max(58, int(round(base_w * scale))), int(round(base_h * scale)))
|
||||||
|
|
||||||
p_photos = []
|
p_photos = [
|
||||||
for card in h.cards:
|
ph for card in h.cards
|
||||||
photo = view.ctx.assets.get_card_photo(card.image_filename, size=card_sz)
|
if (ph := view.ctx.assets.get_card_photo(card.image_filename, size=card_sz))
|
||||||
if photo:
|
]
|
||||||
view._photo_refs.append(photo)
|
view._photo_refs.extend(p_photos)
|
||||||
p_photos.append(photo)
|
|
||||||
|
|
||||||
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 ""
|
||||||
|
|
@ -212,14 +276,14 @@ class BlackjackArenaRenderer:
|
||||||
is_player_turn = (view.engine.state == "ACTION_LOOP" and view.active_bot_idx == -1)
|
is_player_turn = (view.engine.state == "ACTION_LOOP" and view.active_bot_idx == -1)
|
||||||
is_out = (h.busted or h.folded)
|
is_out = (h.busted or h.folded)
|
||||||
lbl_col = ERROR_FG if is_out else FONT_COLOR_TITLE_MAIN
|
lbl_col = ERROR_FG if is_out else FONT_COLOR_TITLE_MAIN
|
||||||
lbl_sz = max(14, FONT_SIZE_BODY - 1)
|
lbl_sz = max(13 if compact else 14, FONT_SIZE_BODY - 1)
|
||||||
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, lbl_col)
|
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, lbl_col, max_width=cw - 56)
|
||||||
|
|
||||||
step = 36
|
step = 34 if compact else 36
|
||||||
fan_w = card_sz[0] + max(0, len(p_photos) - 1) * step
|
fan_w = card_sz[0] + max(0, len(p_photos) - 1) * step
|
||||||
txt_w = lbl_ph.width() if lbl_ph is not None else 240
|
txt_w = lbl_ph.width() if lbl_ph is not None else 220
|
||||||
box_w = max(300, min(560, max(fan_w + 96, txt_w + 72)))
|
box_w = max(280, min(cw - 20 if compact else 560, max(fan_w + 72, txt_w + 56)))
|
||||||
box_h = min(avail_h, card_sz[1] + 52)
|
box_h = min(avail_h, card_sz[1] + 48)
|
||||||
|
|
||||||
view._draw_framed_panel(
|
view._draw_framed_panel(
|
||||||
cw // 2, zone_cy, box_w, box_h,
|
cw // 2, zone_cy, box_w, box_h,
|
||||||
|
|
@ -228,20 +292,23 @@ class BlackjackArenaRenderer:
|
||||||
)
|
)
|
||||||
if p_photos:
|
if p_photos:
|
||||||
view._draw_fanned_cards_on_canvas(
|
view._draw_fanned_cards_on_canvas(
|
||||||
cw // 2, zone_cy - 11, p_photos, card_sz, visible_step=step, max_width=box_w - 44
|
cw // 2, zone_cy - 10, p_photos, card_sz, visible_step=step, max_width=box_w - 36
|
||||||
)
|
)
|
||||||
view._place_goth_photo_or_fallback(cw // 2, zone_cy + box_h // 2 - 20, lbl_ph, lbl_txt, lbl_sz, lbl_col)
|
view._place_goth_photo_or_fallback(cw // 2, zone_cy + box_h // 2 - 18, lbl_ph, lbl_txt, lbl_sz, lbl_col)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Split-Hände nebeneinander
|
# Split-Hände nebeneinander (auf 658px Breite sauber eingepasst)
|
||||||
base_w, base_h = BJ_SPLIT_CARD_SIZE
|
base_w, base_h = BJ_SPLIT_CARD_SIZE
|
||||||
scale = max(80, min(base_h, avail_h - 48)) / max(1, base_h)
|
scale = max(76, min(base_h, avail_h - 46)) / max(1, base_h)
|
||||||
card_sz = (max(54, int(round(base_w * scale))), int(round(base_h * scale)))
|
card_sz = (max(52, int(round(base_w * scale))), int(round(base_h * scale)))
|
||||||
box_h = min(avail_h, card_sz[1] + 48)
|
box_h = min(avail_h, card_sz[1] + 46)
|
||||||
lbl_sz = max(13, FONT_SIZE_BODY - 2)
|
lbl_sz = max(12 if compact else 13, FONT_SIZE_BODY - 2)
|
||||||
|
|
||||||
|
n_hands = len(hands)
|
||||||
|
max_allowed_box_w = (cw - 24 - (n_hands - 1) * 10) // max(1, n_hands) if compact else 320
|
||||||
prepared_splits = []
|
prepared_splits = []
|
||||||
max_box_w = 228
|
max_box_w = min(228, max_allowed_box_w)
|
||||||
|
|
||||||
for idx, h in enumerate(hands):
|
for idx, h in enumerate(hands):
|
||||||
is_active = (
|
is_active = (
|
||||||
view.engine.state == "ACTION_LOOP"
|
view.engine.state == "ACTION_LOOP"
|
||||||
|
|
@ -253,14 +320,13 @@ class BlackjackArenaRenderer:
|
||||||
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 ""
|
||||||
lbl_txt = t("bj_hand_box_title", idx + 1, p_val, soft_hint, h.bet_in_pot, cls.hand_state_suffix(h))
|
lbl_txt = t("bj_hand_box_title", idx + 1, p_val, soft_hint, h.bet_in_pot, cls.hand_state_suffix(h))
|
||||||
lbl_col = ACCENT_GOLD if is_active else (ERROR_FG if is_out else FG_COLOR)
|
lbl_col = ACCENT_GOLD if is_active else (ERROR_FG if is_out else FG_COLOR)
|
||||||
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, lbl_col)
|
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, lbl_col, max_width=max_allowed_box_w - 24)
|
||||||
txt_w = lbl_ph.width() if lbl_ph is not None else 180
|
txt_w = lbl_ph.width() if lbl_ph is not None else 160
|
||||||
sp_fan_w = card_sz[0] + max(0, len(h.cards) - 1) * 28
|
sp_fan_w = card_sz[0] + max(0, len(h.cards) - 1) * 24
|
||||||
max_box_w = max(max_box_w, max(228, min(320, max(sp_fan_w + 64, txt_w + 60))))
|
max_box_w = max(max_box_w, min(max_allowed_box_w, max(sp_fan_w + 48, txt_w + 40)))
|
||||||
prepared_splits.append((h, is_active, is_out, lbl_txt, lbl_col, lbl_ph))
|
prepared_splits.append((h, is_active, is_out, lbl_txt, lbl_col, lbl_ph))
|
||||||
|
|
||||||
n_hands = len(hands)
|
slot_gap = max_box_w + (10 if compact else 14)
|
||||||
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
|
start_cx = cw // 2 - ((n_hands - 1) * slot_gap) // 2
|
||||||
|
|
||||||
for idx, (h, is_active, is_out, lbl_txt, lbl_col, lbl_ph) in enumerate(prepared_splits):
|
for idx, (h, is_active, is_out, lbl_txt, lbl_col, lbl_ph) in enumerate(prepared_splits):
|
||||||
|
|
@ -270,14 +336,13 @@ class BlackjackArenaRenderer:
|
||||||
frame_style="gold" if is_active else "purple",
|
frame_style="gold" if is_active else "purple",
|
||||||
status_border=ERROR_FG if is_out else None,
|
status_border=ERROR_FG if is_out else None,
|
||||||
)
|
)
|
||||||
sp_photos = []
|
sp_photos = [
|
||||||
for card in h.cards:
|
ph for card in h.cards
|
||||||
photo = view.ctx.assets.get_card_photo(card.image_filename, size=card_sz)
|
if (ph := view.ctx.assets.get_card_photo(card.image_filename, size=card_sz))
|
||||||
if photo:
|
]
|
||||||
view._photo_refs.append(photo)
|
view._photo_refs.extend(sp_photos)
|
||||||
sp_photos.append(photo)
|
|
||||||
if sp_photos:
|
if sp_photos:
|
||||||
view._draw_fanned_cards_on_canvas(
|
view._draw_fanned_cards_on_canvas(
|
||||||
h_cx, zone_cy - 10, sp_photos, card_sz, visible_step=28, max_width=max_box_w - 36
|
h_cx, zone_cy - 9, sp_photos, card_sz, visible_step=24, max_width=max_box_w - 28
|
||||||
)
|
)
|
||||||
view._place_goth_photo_or_fallback(h_cx, zone_cy + box_h // 2 - 18, lbl_ph, lbl_txt, lbl_sz, lbl_col)
|
view._place_goth_photo_or_fallback(h_cx, zone_cy + box_h // 2 - 17, lbl_ph, lbl_txt, lbl_sz, lbl_col)
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.blackjack.views.blackjack_table_view import BlackjackTableView
|
from games.blackjack.views.blackjack_table_view import BlackjackTableView
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
BJ_INITIAL_ANTE,
|
BJ_INITIAL_ANTE,
|
||||||
BJ_MAX_BOTS,
|
BJ_MAX_BOTS,
|
||||||
|
|
@ -14,7 +14,7 @@ from resources.code_res.game_constants import (
|
||||||
XP_TO_GOLD_AMOUNT,
|
XP_TO_GOLD_AMOUNT,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.luck_pouch_menu_base import LuckPouchMenuBase
|
from view.widgets.shared_bases.luck_pouch_menu_base import LuckPouchMenuBase
|
||||||
|
|
||||||
GAME_FOLDER_ID = "blackjack"
|
GAME_FOLDER_ID = "blackjack"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ import time
|
||||||
|
|
||||||
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
||||||
from games.blackjack.models.hand_evaluator import HandEvaluator
|
from games.blackjack.models.hand_evaluator import HandEvaluator
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from models.progression import Progression
|
from models.progression import Progression
|
||||||
from resources.code_res.game_constants import GOLD_MIN_TABLE_ENTRY
|
from resources.code_res.game_constants import GOLD_MIN_TABLE_ENTRY
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ from games.blackjack.views.blackjack_turn_driver import (
|
||||||
BlackjackTurnDriver,
|
BlackjackTurnDriver,
|
||||||
)
|
)
|
||||||
from games.blackjack.views.round_result_dialog import BlackjackResultDialog
|
from games.blackjack.views.round_result_dialog import BlackjackResultDialog
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
BJ_DEALER_DELAY_MS,
|
BJ_DEALER_DELAY_MS,
|
||||||
BJ_INITIAL_ANTE,
|
BJ_INITIAL_ANTE,
|
||||||
|
|
@ -27,8 +27,8 @@ from resources.code_res.game_constants import (
|
||||||
GOLD_MIN_TABLE_ENTRY,
|
GOLD_MIN_TABLE_ENTRY,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_arena_base import CasinoArenaBase
|
from view.widgets.shared_bases.casino_arena_base import CasinoArenaBase
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
GAME_FOLDER_ID = "blackjack"
|
GAME_FOLDER_ID = "blackjack"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ from __future__ import annotations
|
||||||
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
from games.blackjack.models.bot_seat import BlackjackBotSeat
|
||||||
from games.blackjack.models.hand_evaluator import HandEvaluator
|
from games.blackjack.models.hand_evaluator import HandEvaluator
|
||||||
from games.blackjack.views.blackjack_showdown_presenter import BlackjackShowdownPresenter
|
from games.blackjack.views.blackjack_showdown_presenter import BlackjackShowdownPresenter
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import BJ_BOT_TURN_DELAY_MS
|
from resources.code_res.game_constants import BJ_BOT_TURN_DELAY_MS
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
STEP_MITGEHEN = "MITGEHEN"
|
STEP_MITGEHEN = "MITGEHEN"
|
||||||
STEP_ZIEHEN = "ZIEHEN"
|
STEP_ZIEHEN = "ZIEHEN"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ from resources.code_res.game_constants import (
|
||||||
FONT_SIZE_SMALL_MIN,
|
FONT_SIZE_SMALL_MIN,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_result_dialog_base import CasinoResultDialogBase
|
from view.widgets.shared_bases.casino_result_dialog_base import CasinoResultDialogBase
|
||||||
|
|
||||||
SHOWDOWN_MINI_CARD_SIZE = (48, 70)
|
SHOWDOWN_MINI_CARD_SIZE = (48, 70)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ from games.party.watten.models.watten_rules import (
|
||||||
is_trump_card,
|
is_trump_card,
|
||||||
trick_card_power,
|
trick_card_power,
|
||||||
)
|
)
|
||||||
from models.bavarian_deck import BavarianCard
|
from models.cards.bavarian_deck import BavarianCard
|
||||||
from resources.code_res.game_constants import BAVARIAN_SUITS
|
from resources.code_res.game_constants import BAVARIAN_SUITS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ from games.party.watten.models.watten_rules import (
|
||||||
get_legal_cards_for_trick,
|
get_legal_cards_for_trick,
|
||||||
is_trump_card,
|
is_trump_card,
|
||||||
)
|
)
|
||||||
from models.bavarian_deck import BavarianCard, create_bavarian_deck
|
from models.cards.bavarian_deck import BavarianCard, create_bavarian_deck
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
BAVARIAN_SUITS,
|
BAVARIAN_SUITS,
|
||||||
WT_GESPANNT_POINTS,
|
WT_GESPANNT_POINTS,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/party/watten/models/watten_rules.py
|
# games/party/watten/models/watten_rules.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from models.bavarian_deck import BavarianCard
|
from models.cards.bavarian_deck import BavarianCard
|
||||||
|
|
||||||
# Natürliche Rangstärke beim Watten innerhalb einer Farbe: 7 < 8 < 9 < 10 < U < O < K < A
|
# Natürliche Rangstärke beim Watten innerhalb einer Farbe: 7 < 8 < 9 < 10 < U < O < K < A
|
||||||
WATTEN_RANKS_32: tuple[str, ...] = ("7", "8", "9", "10", "U", "O", "K", "A")
|
WATTEN_RANKS_32: tuple[str, ...] = ("7", "8", "9", "10", "U", "O", "K", "A")
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from games.party.watten.models.watten_engine import PHASE_TRICK_PLAY
|
from games.party.watten.models.watten_engine import PHASE_TRICK_PLAY
|
||||||
from games.party.watten.models.watten_rules import card_role_badge_key
|
from games.party.watten.models.watten_rules import card_role_badge_key
|
||||||
from models.bavarian_deck import BavarianCard
|
from models.cards.bavarian_deck import BavarianCard
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACCENT_GOLD,
|
ACCENT_GOLD,
|
||||||
ACCENT_GOTH,
|
ACCENT_GOTH,
|
||||||
|
|
@ -29,7 +29,7 @@ WT_HAND_TOP_EXTEND_PX = 20
|
||||||
|
|
||||||
|
|
||||||
class WattenArenaRenderer:
|
class WattenArenaRenderer:
|
||||||
"""Rendert Partner/Gegner, das Ansage- & Stichzentrum sowie die Spielerhand mit Rollen-Badges."""
|
"""Rendert Watten (Desktop-Kreuztisch vs. Kompakt/Mobile mit 3er-Leiste oben & Status-Strip)."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def draw_other_seats(
|
def draw_other_seats(
|
||||||
|
|
@ -42,29 +42,41 @@ class WattenArenaRenderer:
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
eng = view.engine
|
eng = view.engine
|
||||||
if len(eng.seats) < 4:
|
if len(eng.seats) < 4:
|
||||||
return ty1 + 20, tx1 + 60, tx2 - 60
|
return ty1 + 20, tx1 + 20, tx2 - 20
|
||||||
|
|
||||||
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
if compact:
|
||||||
|
gap = 6
|
||||||
|
avail_w = max(320, cw - 2 * pad_x)
|
||||||
|
box_w = min(214, (avail_w - 2 * gap) // 3)
|
||||||
|
box_h = 82
|
||||||
|
start_x = (cw - (3 * box_w + 2 * gap)) // 2 + box_w // 2
|
||||||
|
top_cy = pad_top + box_h // 2 + 2
|
||||||
|
seat_specs = [
|
||||||
|
(eng.seats[1], start_x, top_cy, False),
|
||||||
|
(eng.seats[2], start_x + (box_w + gap), top_cy, True),
|
||||||
|
(eng.seats[3], start_x + 2 * (box_w + gap), top_cy, False),
|
||||||
|
]
|
||||||
|
back_sz = (30, 44)
|
||||||
|
else:
|
||||||
box_w, box_h = 232, 92
|
box_w, box_h = 232, 92
|
||||||
mid_side_y = (ty1 + ty2) // 2 - 14
|
mid_side_y = (ty1 + ty2) // 2 - 14
|
||||||
top_cy = max(pad_top + box_h // 2 - 4, ty1 + int(box_h * 0.30))
|
top_cy = max(pad_top + box_h // 2 - 4, ty1 + int(box_h * 0.30))
|
||||||
left_cx = max(pad_x + box_w // 2 - 10, tx1 + int(box_w * 0.24))
|
left_cx = max(pad_x + box_w // 2 - 10, tx1 + int(box_w * 0.24))
|
||||||
right_cx = min(cw - pad_x - box_w // 2 + 10, tx2 - int(box_w * 0.24))
|
right_cx = min(cw - pad_x - box_w // 2 + 10, tx2 - int(box_w * 0.24))
|
||||||
|
|
||||||
# Sitz 1 = West (Gegner), Sitz 2 = Nord (Partner!), Sitz 3 = Ost (Gegner)
|
|
||||||
seat_specs = [
|
seat_specs = [
|
||||||
(eng.seats[1], left_cx, mid_side_y, False),
|
(eng.seats[1], left_cx, mid_side_y, False),
|
||||||
(eng.seats[2], cw // 2, top_cy, True),
|
(eng.seats[2], cw // 2, top_cy, True),
|
||||||
(eng.seats[3], right_cx, mid_side_y, False),
|
(eng.seats[3], right_cx, mid_side_y, False),
|
||||||
]
|
]
|
||||||
|
back_sz = WT_BOT_BACK_SIZE
|
||||||
|
|
||||||
back_ph = view.ctx.assets.get_card_back_photo(
|
back_ph = view.ctx.assets.get_card_back_photo(size=back_sz, theme=BAVARIAN_CARD_THEME)
|
||||||
size=WT_BOT_BACK_SIZE, theme=BAVARIAN_CARD_THEME
|
|
||||||
)
|
|
||||||
if back_ph is not None:
|
if back_ph is not None:
|
||||||
view._photo_refs.append(back_ph)
|
view._photo_refs.append(back_ph)
|
||||||
|
|
||||||
name_sz = max(14, FONT_SIZE_BODY - 1)
|
name_sz = max(12 if compact else 14, FONT_SIZE_SMALL_MIN if compact else FONT_SIZE_BODY - 1)
|
||||||
sub_sz = max(12, FONT_SIZE_SMALL_MIN)
|
sub_sz = max(11 if compact else 12, FONT_SIZE_SMALL_MIN - (1 if compact else 0))
|
||||||
|
|
||||||
for seat, bx, by, is_partner in seat_specs:
|
for seat, bx, by, is_partner in seat_specs:
|
||||||
is_turn = not eng.is_match_over and eng.turn_seat == seat.seat_id
|
is_turn = not eng.is_match_over and eng.turn_seat == seat.seat_id
|
||||||
|
|
@ -80,44 +92,44 @@ class WattenArenaRenderer:
|
||||||
role_line = " • ".join(role_tags) if role_tags else t("wt_tag_opponent")
|
role_line = " • ".join(role_tags) if role_tags else t("wt_tag_opponent")
|
||||||
|
|
||||||
view._draw_framed_panel(
|
view._draw_framed_panel(
|
||||||
bx,
|
bx, by, box_w, box_h,
|
||||||
by,
|
|
||||||
box_w,
|
|
||||||
box_h,
|
|
||||||
frame_style="gold" if is_turn else "purple",
|
frame_style="gold" if is_turn else "purple",
|
||||||
status_border=FONT_COLOR_STATUS_WIN if is_partner else None,
|
status_border=FONT_COLOR_STATUS_WIN if is_partner else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
if back_ph is not None and n_cards > 0:
|
if back_ph is not None and n_cards > 0 and (not compact or box_w >= 176):
|
||||||
step_b = 8
|
step_b = 6 if compact else 8
|
||||||
bx0 = bx - box_w // 2 + 12
|
bx0 = bx - box_w // 2 + (10 if compact else 12)
|
||||||
by0 = by - WT_BOT_BACK_SIZE[1] // 2
|
by0 = by - back_sz[1] // 2
|
||||||
for bi in range(n_cards):
|
for bi in range(n_cards):
|
||||||
view.arena_canvas.create_image(
|
view.arena_canvas.create_image(
|
||||||
bx0 + bi * step_b, by0, image=back_ph, anchor="nw", tags="fg"
|
bx0 + bi * step_b, by0, image=back_ph, anchor="nw", tags="fg"
|
||||||
)
|
)
|
||||||
txt_cx = bx + 28
|
txt_cx = bx + (20 if compact else 28)
|
||||||
max_tw = box_w - 92
|
max_tw = box_w - (68 if compact else 92)
|
||||||
else:
|
else:
|
||||||
txt_cx = bx
|
txt_cx = bx
|
||||||
max_tw = box_w - 24
|
max_tw = box_w - 18
|
||||||
|
|
||||||
n_col = (
|
n_col = ACCENT_GOLD if is_turn else (FONT_COLOR_STATUS_WIN if is_partner else ACCENT_GOTH)
|
||||||
ACCENT_GOLD
|
|
||||||
if is_turn
|
|
||||||
else (FONT_COLOR_STATUS_WIN if is_partner else ACCENT_GOTH)
|
|
||||||
)
|
|
||||||
act_txt = seat.status_text or "-"
|
act_txt = seat.status_text or "-"
|
||||||
|
|
||||||
n_ph = view._make_goth_photo(seat.name, name_sz, n_col, max_tw)
|
n_ph = view._make_goth_photo(seat.name, name_sz, n_col, max_tw)
|
||||||
r_ph = view._make_goth_photo(role_line, sub_sz - 1, MUTED_FG, max_tw)
|
r_ph = view._make_goth_photo(role_line, max(10, sub_sz - 1), MUTED_FG, max_tw)
|
||||||
a_ph = view._make_goth_photo(act_txt, sub_sz, FG_COLOR, max_tw)
|
a_ph = view._make_goth_photo(act_txt, sub_sz, FG_COLOR, max_tw)
|
||||||
|
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by - 23, n_ph, seat.name, name_sz, n_col)
|
dy = 21 if compact else 23
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by - 1, r_ph, role_line, sub_sz - 1, MUTED_FG)
|
view._place_goth_photo_or_fallback(txt_cx, by - dy, n_ph, seat.name, name_sz, n_col)
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by + 22, a_ph, act_txt, sub_sz, FG_COLOR)
|
view._place_goth_photo_or_fallback(txt_cx, by - 1, r_ph, role_line, max(10, sub_sz - 1), MUTED_FG)
|
||||||
|
view._place_goth_photo_or_fallback(txt_cx, by + dy - 1, a_ph, act_txt, sub_sz, FG_COLOR)
|
||||||
|
|
||||||
return (top_cy + box_h // 2, left_cx + box_w // 2, right_cx - box_w // 2)
|
if compact:
|
||||||
|
return (top_cy + box_h // 2, 0, cw)
|
||||||
|
return (
|
||||||
|
top_cy + box_h // 2,
|
||||||
|
seat_specs[0][1] + box_w // 2,
|
||||||
|
seat_specs[2][1] - box_w // 2,
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def draw_center_trick_area(
|
def draw_center_trick_area(
|
||||||
|
|
@ -130,106 +142,101 @@ class WattenArenaRenderer:
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
top_obs_y, left_obs_x, right_obs_x = bot_bounds
|
top_obs_y, left_obs_x, right_obs_x = bot_bounds
|
||||||
eng = view.engine
|
eng = view.engine
|
||||||
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
|
||||||
|
schlag_txt = t(f"bav_rank_{eng.schlag_rank}") if eng.schlag_rank else "?"
|
||||||
|
trump_txt = t(f"bav_suit_{eng.trump_suit}") if eng.trump_suit else "?"
|
||||||
|
gesp_0, gesp_1 = eng.is_team_gespannt(0), eng.is_team_gespannt(1)
|
||||||
|
|
||||||
|
if compact:
|
||||||
|
# Kompakte zweizeilige Info-Leiste direkt unter den 3 oberen Sitzen
|
||||||
|
strip_w = min(cw - 16, 620)
|
||||||
|
strip_h = 54
|
||||||
|
strip_cy = top_obs_y + 8 + strip_h // 2
|
||||||
|
view._draw_framed_panel(
|
||||||
|
cw // 2, strip_cy, strip_w, strip_h,
|
||||||
|
frame_style="gold" if (gesp_0 or gesp_1) else "purple",
|
||||||
|
)
|
||||||
|
top_line = (
|
||||||
|
f"{t('wt_lbl_schlag')}: {schlag_txt} • "
|
||||||
|
f"{t('wt_lbl_trumpf')}: {trump_txt} • "
|
||||||
|
f"{t('wt_lbl_tricks_pair', eng.team_tricks[0], eng.team_tricks[1])}"
|
||||||
|
)
|
||||||
|
warn_tail = f" • {t('wt_lbl_gespannt_warn')}" if (gesp_0 or gesp_1) else ""
|
||||||
|
bot_line = f"{t('wt_lbl_match_pts', eng.team_points[0], eng.team_points[1])} • {t('wt_lbl_cur_stake', eng.current_stake)}{warn_tail}"
|
||||||
|
|
||||||
|
p1 = view._make_goth_photo(top_line, FONT_SIZE_SMALL_MIN, FONT_COLOR_TITLE_MAIN, strip_w - 28)
|
||||||
|
p2 = view._make_goth_photo(
|
||||||
|
bot_line, FONT_SIZE_SMALL_MIN - 1,
|
||||||
|
ERROR_FG if (gesp_0 or gesp_1) else ACCENT_GOLD, strip_w - 28,
|
||||||
|
)
|
||||||
|
view._place_goth_photo_or_fallback(cw // 2, strip_cy - 11, p1, top_line, FONT_SIZE_SMALL_MIN, FONT_COLOR_TITLE_MAIN)
|
||||||
|
view._place_goth_photo_or_fallback(cw // 2, strip_cy + 12, p2, bot_line, FONT_SIZE_SMALL_MIN - 1, ACCENT_GOLD)
|
||||||
|
|
||||||
|
trick_top = strip_cy + strip_h // 2 + 8
|
||||||
|
trick_bot = player_top_y - 12
|
||||||
|
center_cy = (trick_top + trick_bot) // 2
|
||||||
|
avail_trick_h = max(120, trick_bot - trick_top)
|
||||||
|
t_scale = min(1.0, max(0.76, (avail_trick_h - 52) / max(1, WT_TRICK_CARD_SIZE[1])))
|
||||||
|
trick_sz = (int(round(WT_TRICK_CARD_SIZE[0] * t_scale)), int(round(WT_TRICK_CARD_SIZE[1] * t_scale)))
|
||||||
|
else:
|
||||||
felt_top = max(ty1 + 12, top_obs_y + 10)
|
felt_top = max(ty1 + 12, top_obs_y + 10)
|
||||||
felt_bot = min(ty2 - 12, player_top_y - WT_HAND_TOP_EXTEND_PX - 10)
|
felt_bot = min(ty2 - 12, player_top_y - WT_HAND_TOP_EXTEND_PX - 10)
|
||||||
center_cy = (felt_top + felt_bot) // 2 + 12
|
center_cy = (felt_top + felt_bot) // 2 + 12
|
||||||
center_cx = cw // 2
|
trick_sz = WT_TRICK_CARD_SIZE
|
||||||
|
|
||||||
# 1. Ansage- & Stich-Infotafel oben links auf dem Tischfilz
|
|
||||||
schlag_txt = t(f"bav_rank_{eng.schlag_rank}") if eng.schlag_rank else "?"
|
|
||||||
trump_txt = t(f"bav_suit_{eng.trump_suit}") if eng.trump_suit else "?"
|
|
||||||
info_x = max(left_obs_x + 112, tx1 + 148)
|
info_x = max(left_obs_x + 112, tx1 + 148)
|
||||||
info_y = felt_top + 42
|
info_y = felt_top + 42
|
||||||
|
|
||||||
view._draw_framed_panel(info_x, info_y, 206, 78, frame_style="purple")
|
view._draw_framed_panel(info_x, info_y, 206, 78, frame_style="purple")
|
||||||
l1 = f"{t('wt_lbl_schlag')}: {schlag_txt}"
|
|
||||||
l2 = f"{t('wt_lbl_trumpf')}: {trump_txt}"
|
|
||||||
l3 = t("wt_lbl_tricks_pair", eng.team_tricks[0], eng.team_tricks[1])
|
|
||||||
for dy, txt, col in (
|
for dy, txt, col in (
|
||||||
(-21, l1, ACCENT_GOLD),
|
(-21, f"{t('wt_lbl_schlag')}: {schlag_txt}", ACCENT_GOLD),
|
||||||
(0, l2, FONT_COLOR_TITLE_MAIN),
|
(0, f"{t('wt_lbl_trumpf')}: {trump_txt}", FONT_COLOR_TITLE_MAIN),
|
||||||
(21, l3, FONT_COLOR_STATUS_WIN if eng.team_tricks[0] >= eng.team_tricks[1] else FG_COLOR),
|
(21, t("wt_lbl_tricks_pair", eng.team_tricks[0], eng.team_tricks[1]),
|
||||||
|
FONT_COLOR_STATUS_WIN if eng.team_tricks[0] >= eng.team_tricks[1] else FG_COLOR),
|
||||||
):
|
):
|
||||||
ph = view._make_goth_photo(txt, FONT_SIZE_SMALL_MIN, col, 186)
|
ph = view._make_goth_photo(txt, FONT_SIZE_SMALL_MIN, col, 186)
|
||||||
view._place_goth_photo_or_fallback(info_x, info_y + dy, ph, txt, FONT_SIZE_SMALL_MIN, col)
|
view._place_goth_photo_or_fallback(info_x, info_y + dy, ph, txt, FONT_SIZE_SMALL_MIN, col)
|
||||||
|
|
||||||
# 2. Punktestand- & Einsatz-Tafel oben rechts auf dem Tischfilz
|
|
||||||
score_x = min(right_obs_x - 112, tx2 - 148)
|
score_x = min(right_obs_x - 112, tx2 - 148)
|
||||||
score_y = felt_top + 42
|
score_y = felt_top + 42
|
||||||
gesp_0 = eng.is_team_gespannt(0)
|
|
||||||
gesp_1 = eng.is_team_gespannt(1)
|
|
||||||
view._draw_framed_panel(
|
view._draw_framed_panel(
|
||||||
score_x,
|
score_x, score_y, 206, 78, frame_style="gold" if (gesp_0 or gesp_1) else "purple"
|
||||||
score_y,
|
|
||||||
206,
|
|
||||||
78,
|
|
||||||
frame_style="gold" if (gesp_0 or gesp_1) else "purple",
|
|
||||||
)
|
|
||||||
s1 = t("wt_lbl_match_pts", eng.team_points[0], eng.team_points[1])
|
|
||||||
s2 = t("wt_lbl_cur_stake", eng.current_stake)
|
|
||||||
s3 = (
|
|
||||||
t("wt_lbl_gespannt_warn")
|
|
||||||
if (gesp_0 or gesp_1)
|
|
||||||
else t("wt_lbl_target_11")
|
|
||||||
)
|
)
|
||||||
for dy, txt, col in (
|
for dy, txt, col in (
|
||||||
(-21, s1, FONT_COLOR_TITLE_MAIN),
|
(-21, t("wt_lbl_match_pts", eng.team_points[0], eng.team_points[1]), FONT_COLOR_TITLE_MAIN),
|
||||||
(0, s2, ACCENT_GOLD),
|
(0, t("wt_lbl_cur_stake", eng.current_stake), ACCENT_GOLD),
|
||||||
(21, s3, ERROR_FG if (gesp_0 or gesp_1) else MUTED_FG),
|
(21, t("wt_lbl_gespannt_warn") if (gesp_0 or gesp_1) else t("wt_lbl_target_11"),
|
||||||
|
ERROR_FG if (gesp_0 or gesp_1) else MUTED_FG),
|
||||||
):
|
):
|
||||||
ph = view._make_goth_photo(txt, FONT_SIZE_SMALL_MIN, col, 186)
|
ph = view._make_goth_photo(txt, FONT_SIZE_SMALL_MIN, col, 186)
|
||||||
view._place_goth_photo_or_fallback(score_x, score_y + dy, ph, txt, FONT_SIZE_SMALL_MIN, col)
|
view._place_goth_photo_or_fallback(score_x, score_y + dy, ph, txt, FONT_SIZE_SMALL_MIN, col)
|
||||||
|
|
||||||
# 3. 4 Stich-Ablageplätze kreuzförmig in der Tischmitte (Süd=0, West=1, Nord=2, Ost=3)
|
center_cx = cw // 2
|
||||||
tw, th = WT_TRICK_CARD_SIZE
|
tw, th = trick_sz
|
||||||
slot_offsets = {
|
dx_off = int(tw * 0.98)
|
||||||
0: (0, 32), # Spieler (unten)
|
dy_off = int(th * 0.24)
|
||||||
1: (-86, 0), # Gegner West (links)
|
slot_offsets = {0: (0, dy_off), 1: (-dx_off, 0), 2: (0, -dy_off), 3: (dx_off, 0)}
|
||||||
2: (0, -32), # Partner Nord (oben)
|
|
||||||
3: (86, 0), # Gegner Ost (rechts)
|
|
||||||
}
|
|
||||||
|
|
||||||
active_cards = (
|
active_cards = view._visible_completed_trick if view._visible_completed_trick else eng.current_trick
|
||||||
view._visible_completed_trick
|
|
||||||
if view._visible_completed_trick
|
|
||||||
else eng.current_trick
|
|
||||||
)
|
|
||||||
if not active_cards:
|
if not active_cards:
|
||||||
view.arena_canvas.create_oval(
|
view.arena_canvas.create_oval(
|
||||||
center_cx - 64,
|
center_cx - 56, center_cy - 38, center_cx + 56, center_cy + 38,
|
||||||
center_cy - 44,
|
outline=SUBTLE_BORDER, width=2, dash=(4, 4), tags="fg",
|
||||||
center_cx + 64,
|
|
||||||
center_cy + 44,
|
|
||||||
outline=SUBTLE_BORDER,
|
|
||||||
width=2,
|
|
||||||
dash=(4, 4),
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
win_seat = (
|
win_seat = eng.last_trick_winner if view._visible_completed_trick else None
|
||||||
eng.last_trick_winner if view._visible_completed_trick else None
|
|
||||||
)
|
|
||||||
for seat_id, card in active_cards:
|
for seat_id, card in active_cards:
|
||||||
dx, dy = slot_offsets.get(seat_id, (0, 0))
|
dx, dy = slot_offsets.get(seat_id, (0, 0))
|
||||||
cx, cy = center_cx + dx, center_cy + dy
|
cx, cy = center_cx + dx, center_cy + dy
|
||||||
ph = view.ctx.assets.get_card_photo(
|
ph = view.ctx.assets.get_card_photo(card.image_filename, size=trick_sz, theme=BAVARIAN_CARD_THEME)
|
||||||
card.image_filename, size=WT_TRICK_CARD_SIZE, theme=BAVARIAN_CARD_THEME
|
|
||||||
)
|
|
||||||
if ph is not None:
|
if ph is not None:
|
||||||
view._photo_refs.append(ph)
|
view._photo_refs.append(ph)
|
||||||
view.arena_canvas.create_image(cx, cy, image=ph, anchor="center", tags="fg")
|
view.arena_canvas.create_image(cx, cy, image=ph, anchor="center", tags="fg")
|
||||||
border_c = ACCENT_GOLD if seat_id == win_seat else BORDER_COLOR
|
border_c = ACCENT_GOLD if seat_id == win_seat else BORDER_COLOR
|
||||||
border_w = 3 if seat_id == win_seat else 1
|
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
cx - tw // 2 - 2,
|
cx - tw // 2 - 2, cy - th // 2 - 2, cx + tw // 2 + 2, cy + th // 2 + 2,
|
||||||
cy - th // 2 - 2,
|
outline=border_c, width=3 if seat_id == win_seat else 1, tags="fg",
|
||||||
cx + tw // 2 + 2,
|
|
||||||
cy + th // 2 + 2,
|
|
||||||
outline=border_c,
|
|
||||||
width=border_w,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -238,15 +245,19 @@ class WattenArenaRenderer:
|
||||||
) -> list[tuple[BavarianCard, int, int, int, int]]:
|
) -> list[tuple[BavarianCard, int, int, int, int]]:
|
||||||
eng = view.engine
|
eng = view.engine
|
||||||
human = eng.seats[0]
|
human = eng.seats[0]
|
||||||
eff_top = max(230, player_zone_top - WT_HAND_TOP_EXTEND_PX)
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
avail_h = max(168, player_zone_bot - eff_top)
|
ext = 8 if compact else WT_HAND_TOP_EXTEND_PX
|
||||||
|
eff_top = max(210, player_zone_top - ext)
|
||||||
|
avail_h = max(146 if compact else 168, player_zone_bot - eff_top)
|
||||||
zone_cy = (eff_top + player_zone_bot) // 2
|
zone_cy = (eff_top + player_zone_bot) // 2
|
||||||
|
|
||||||
base_w, base_h = PLAYING_CARD_SIZE
|
base_w, base_h = PLAYING_CARD_SIZE
|
||||||
target_h = max(116, min(WT_MAX_HAND_CARD_H, avail_h - 44))
|
n_cards = len(human.hand)
|
||||||
scale = target_h / max(1, base_h)
|
max_hand_w = max(300, cw - (48 if compact else 120))
|
||||||
card_w = max(78, int(round(base_w * scale)))
|
card_w_by_w = (max_hand_w - max(0, n_cards - 1) * 10) // max(1, max(5, n_cards))
|
||||||
card_h = int(round(base_h * scale))
|
target_h = max(104 if compact else 116, min(WT_MAX_HAND_CARD_H, avail_h - 42))
|
||||||
|
card_w = max(68 if compact else 78, min(card_w_by_w, int(round(base_w * (target_h / max(1, base_h))))))
|
||||||
|
card_h = int(round(card_w * (base_h / max(1, base_w))))
|
||||||
card_sz = (card_w, card_h)
|
card_sz = (card_w, card_h)
|
||||||
|
|
||||||
is_my_play_turn = (
|
is_my_play_turn = (
|
||||||
|
|
@ -256,30 +267,24 @@ class WattenArenaRenderer:
|
||||||
)
|
)
|
||||||
playable_set = set(eng.get_playable_cards(0)) if is_my_play_turn else set()
|
playable_set = set(eng.get_playable_cards(0)) if is_my_play_turn else set()
|
||||||
|
|
||||||
n_cards = len(human.hand)
|
step = card_w + (10 if compact else 14)
|
||||||
step = card_w + 14
|
|
||||||
span_w = card_w + max(0, n_cards - 1) * step if n_cards else card_w
|
span_w = card_w + max(0, n_cards - 1) * step if n_cards else card_w
|
||||||
|
|
||||||
my_role = ""
|
my_role = (
|
||||||
if eng.dealer_seat == 0:
|
f" ({t('wt_tag_dealer')})" if eng.dealer_seat == 0
|
||||||
my_role = f" ({t('wt_tag_dealer')})"
|
else (f" ({t('wt_tag_ansager')})" if eng.ansager_seat == 0 else "")
|
||||||
elif eng.ansager_seat == 0:
|
)
|
||||||
my_role = f" ({t('wt_tag_ansager')})"
|
|
||||||
lbl_txt = f"{t('wt_your_hand_lbl')}{my_role}"
|
lbl_txt = f"{t('wt_your_hand_lbl')}{my_role}"
|
||||||
lbl_sz = max(13, FONT_SIZE_BODY - 2)
|
lbl_sz = max(12 if compact else 13, FONT_SIZE_BODY - 2)
|
||||||
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, FONT_COLOR_TITLE_MAIN)
|
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, FONT_COLOR_TITLE_MAIN)
|
||||||
txt_w = lbl_ph.width() if lbl_ph is not None else 280
|
txt_w = lbl_ph.width() if lbl_ph is not None else 240
|
||||||
|
|
||||||
box_w = max(420, min(cw - 72, max(span_w + 80, txt_w + 68)))
|
box_w = max(320, min(cw - (18 if compact else 72), max(span_w + 48, txt_w + 48)))
|
||||||
box_h = min(avail_h + 6, card_h + 48)
|
box_h = min(avail_h + 6, card_h + 44)
|
||||||
box_cx = cw // 2
|
box_cx = cw // 2
|
||||||
|
|
||||||
view._draw_framed_panel(
|
view._draw_framed_panel(
|
||||||
box_cx,
|
box_cx, zone_cy, box_w, box_h, frame_style="gold" if eng.turn_seat == 0 else "purple"
|
||||||
zone_cy,
|
|
||||||
box_w,
|
|
||||||
box_h,
|
|
||||||
frame_style="gold" if eng.turn_seat == 0 else "purple",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
hit_rects: list[tuple[BavarianCard, int, int, int, int]] = []
|
hit_rects: list[tuple[BavarianCard, int, int, int, int]] = []
|
||||||
|
|
@ -289,28 +294,18 @@ class WattenArenaRenderer:
|
||||||
for idx, card in enumerate(human.hand):
|
for idx, card in enumerate(human.hand):
|
||||||
is_playable = card in playable_set
|
is_playable = card in playable_set
|
||||||
cx_left = start_x + idx * step
|
cx_left = start_x + idx * step
|
||||||
cy_top = base_top - (9 if is_playable else 0)
|
cy_top = base_top - (8 if is_playable else 0)
|
||||||
|
|
||||||
ph = view.ctx.assets.get_card_photo(
|
ph = view.ctx.assets.get_card_photo(card.image_filename, size=card_sz, theme=BAVARIAN_CARD_THEME)
|
||||||
card.image_filename, size=card_sz, theme=BAVARIAN_CARD_THEME
|
|
||||||
)
|
|
||||||
if ph is not None:
|
if ph is not None:
|
||||||
view._photo_refs.append(ph)
|
view._photo_refs.append(ph)
|
||||||
view.arena_canvas.create_image(
|
view.arena_canvas.create_image(cx_left, cy_top, image=ph, anchor="nw", tags="fg")
|
||||||
cx_left, cy_top, image=ph, anchor="nw", tags="fg"
|
|
||||||
)
|
|
||||||
if is_playable:
|
if is_playable:
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
cx_left - 2,
|
cx_left - 2, cy_top - 2, cx_left + card_w + 2, cy_top + card_h + 2,
|
||||||
cy_top - 2,
|
outline=ACCENT_GOLD, width=2, tags="fg",
|
||||||
cx_left + card_w + 2,
|
|
||||||
cy_top + card_h + 2,
|
|
||||||
outline=ACCENT_GOLD,
|
|
||||||
width=2,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Dezentes Rollen-Badge oben auf der Karte (Max, Belli, Spitz, Guade, Schlag, Trumpf)
|
|
||||||
badge_key = card_role_badge_key(card, eng.schlag_rank, eng.trump_suit)
|
badge_key = card_role_badge_key(card, eng.schlag_rank, eng.trump_suit)
|
||||||
if badge_key:
|
if badge_key:
|
||||||
b_txt = t(badge_key)
|
b_txt = t(badge_key)
|
||||||
|
|
@ -320,32 +315,17 @@ class WattenArenaRenderer:
|
||||||
else ACCENT_GOTH
|
else ACCENT_GOTH
|
||||||
)
|
)
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
cx_left + 4,
|
cx_left + 3, cy_top + card_h - 19, cx_left + card_w - 3, cy_top + card_h - 3,
|
||||||
cy_top + card_h - 21,
|
fill="#0d0914", outline=b_col, width=1, tags="fg",
|
||||||
cx_left + card_w - 4,
|
|
||||||
cy_top + card_h - 4,
|
|
||||||
fill="#0d0914",
|
|
||||||
outline=b_col,
|
|
||||||
width=1,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
view.arena_canvas.create_text(
|
view.arena_canvas.create_text(
|
||||||
cx_left + card_w // 2,
|
cx_left + card_w // 2, cy_top + card_h - 11, text=b_txt,
|
||||||
cy_top + card_h - 12,
|
font=("Georgia", 8, "bold"), fill=b_col, tags="fg",
|
||||||
text=b_txt,
|
|
||||||
font=("Georgia", 8, "bold"),
|
|
||||||
fill=b_col,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
hit_rects.append((card, cx_left, cy_top, cx_left + card_w, cy_top + card_h))
|
hit_rects.append((card, cx_left, cy_top, cx_left + card_w, cy_top + card_h))
|
||||||
|
|
||||||
view._place_goth_photo_or_fallback(
|
view._place_goth_photo_or_fallback(
|
||||||
box_cx,
|
box_cx, zone_cy + box_h // 2 - 14, lbl_ph, lbl_txt, lbl_sz, FONT_COLOR_TITLE_MAIN
|
||||||
zone_cy + box_h // 2 - 14,
|
|
||||||
lbl_ph,
|
|
||||||
lbl_txt,
|
|
||||||
lbl_sz,
|
|
||||||
FONT_COLOR_TITLE_MAIN,
|
|
||||||
)
|
)
|
||||||
return hit_rects
|
return hit_rects
|
||||||
|
|
@ -6,7 +6,7 @@ import tkinter as tk
|
||||||
|
|
||||||
from games.party.watten.models.watten_tutorials import build_watten_tutorial_units
|
from games.party.watten.models.watten_tutorials import build_watten_tutorial_units
|
||||||
from games.party.watten.views.watten_table_view import WattenTableView
|
from games.party.watten.views.watten_table_view import WattenTableView
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
BAVARIAN_CARD_THEME,
|
BAVARIAN_CARD_THEME,
|
||||||
BOT_LEVEL_COUNT,
|
BOT_LEVEL_COUNT,
|
||||||
|
|
@ -21,20 +21,21 @@ from resources.code_res.game_constants import (
|
||||||
WT_BOT_COUNT,
|
WT_BOT_COUNT,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
|
from view.layout_mode import LayoutMode
|
||||||
from view.tutorial.tutorial_hub_view import TutorialHubView
|
from view.tutorial.tutorial_hub_view import TutorialHubView
|
||||||
from view.tutorial.tutorial_models import TutorialProgressRepo, TutorialUnit
|
from view.tutorial.tutorial_models import TutorialProgressRepo, TutorialUnit
|
||||||
from view.tutorial.tutorial_runner_view import TutorialRunnerView
|
from view.tutorial.tutorial_runner_view import TutorialRunnerView
|
||||||
from view.widgets.goth_dropdown import GothDropdown
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
from view.widgets.goth_entry import GothEntry
|
from view.widgets.dropdown.goth_dropdown import GothDropdown
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.inputs.goth_entry import GothEntry
|
||||||
from view.widgets.menu_body_canvas import MenuBodyCanvas
|
from view.widgets.shared_bases.menu_body_canvas import MenuBodyCanvas
|
||||||
|
|
||||||
GAME_FOLDER_ID = "party/watten"
|
GAME_FOLDER_ID = "party/watten"
|
||||||
GAME_TITLE_KEY = "game_title_watten"
|
GAME_TITLE_KEY = "game_title_watten"
|
||||||
|
|
||||||
|
|
||||||
class WattenMenuView:
|
class WattenMenuView:
|
||||||
"""Vorauswahl-Menü für Oberbayerisches Watten inkl. interaktivem 4-Kapitel-Tutorial."""
|
"""Vorauswahl-Menü für Oberbayerisches Watten inkl. interaktivem 4-Kapitel-Tutorial (Desktop & Kompakt)."""
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.ctx = context
|
self.ctx = context
|
||||||
|
|
@ -50,15 +51,9 @@ class WattenMenuView:
|
||||||
to_save: dict[int, tuple[str, int]] = {}
|
to_save: dict[int, tuple[str, int]] = {}
|
||||||
|
|
||||||
for idx in range(WT_BOT_COUNT):
|
for idx in range(WT_BOT_COUNT):
|
||||||
raw_name = (
|
raw_name = self._bot_entries[idx].get().strip() if idx < len(self._bot_entries) else ""
|
||||||
self._bot_entries[idx].get().strip()
|
|
||||||
if idx < len(self._bot_entries)
|
|
||||||
else ""
|
|
||||||
)
|
|
||||||
b_name = raw_name or t("bot_default_name", idx + 1)
|
b_name = raw_name or t("bot_default_name", idx + 1)
|
||||||
lvl = lvl_by_label.get(
|
lvl = lvl_by_label.get(self._bot_lvl_vars[idx].get(), min(BOT_LEVEL_COUNT - 1, idx + 1))
|
||||||
self._bot_lvl_vars[idx].get(), min(BOT_LEVEL_COUNT - 1, idx + 1)
|
|
||||||
)
|
|
||||||
active_bots.append((lvl, b_name))
|
active_bots.append((lvl, b_name))
|
||||||
to_save[idx] = (b_name, lvl)
|
to_save[idx] = (b_name, lvl)
|
||||||
|
|
||||||
|
|
@ -116,8 +111,7 @@ class WattenMenuView:
|
||||||
)
|
)
|
||||||
|
|
||||||
cv = MenuBodyCanvas(self.ctx)
|
cv = MenuBodyCanvas(self.ctx)
|
||||||
btn_norm = self.ctx.assets.raw_btn_default
|
btn_norm, btn_purp = self.ctx.assets.raw_btn_default, self.ctx.assets.raw_btn_purple
|
||||||
btn_purp = self.ctx.assets.raw_btn_purple
|
|
||||||
btn_fire = self.ctx.assets.raw_btn_fire or btn_purp
|
btn_fire = self.ctx.assets.raw_btn_fire or btn_purp
|
||||||
|
|
||||||
units = build_watten_tutorial_units()
|
units = build_watten_tutorial_units()
|
||||||
|
|
@ -130,8 +124,8 @@ class WattenMenuView:
|
||||||
btn_fire if tut_unseen else btn_purp,
|
btn_fire if tut_unseen else btn_purp,
|
||||||
self._open_tutorial_hub,
|
self._open_tutorial_hub,
|
||||||
sound_mgr=self.ctx.sounds,
|
sound_mgr=self.ctx.sounds,
|
||||||
width=226,
|
width=216,
|
||||||
height=38,
|
height=36,
|
||||||
style="fire" if tut_unseen else "amethyst",
|
style="fire" if tut_unseen else "amethyst",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -140,97 +134,73 @@ class WattenMenuView:
|
||||||
|
|
||||||
for i in range(WT_BOT_COUNT):
|
for i in range(WT_BOT_COUNT):
|
||||||
def_name = t("bot_default_name", i + 1)
|
def_name = t("bot_default_name", i + 1)
|
||||||
def_lvl = 2
|
|
||||||
if i in saved_bots:
|
if i in saved_bots:
|
||||||
s_name, s_lvl = saved_bots[i]
|
s_name, s_lvl = saved_bots[i]
|
||||||
b_name = s_name or def_name
|
b_name = s_name or def_name
|
||||||
b_lvl = max(0, min(BOT_LEVEL_COUNT - 1, int(s_lvl)))
|
b_lvl = max(0, min(BOT_LEVEL_COUNT - 1, int(s_lvl)))
|
||||||
else:
|
else:
|
||||||
b_name, b_lvl = def_name, def_lvl
|
b_name, b_lvl = def_name, 2
|
||||||
|
|
||||||
entry = GothEntry(
|
entry = GothEntry(cv, self.ctx.assets, width=190, height=36, textvariable=tk.StringVar(value=b_name))
|
||||||
cv,
|
|
||||||
self.ctx.assets,
|
|
||||||
width=230,
|
|
||||||
height=36,
|
|
||||||
textvariable=tk.StringVar(value=b_name),
|
|
||||||
)
|
|
||||||
l_var = tk.StringVar(value=t(f"bot_level_{b_lvl}"))
|
l_var = tk.StringVar(value=t(f"bot_level_{b_lvl}"))
|
||||||
dd = GothDropdown(
|
dd = GothDropdown(
|
||||||
cv,
|
cv, self.ctx.assets, values=ai_labels, textvariable=l_var,
|
||||||
self.ctx.assets,
|
sound_mgr=self.ctx.sounds, width=220, height=36,
|
||||||
values=ai_labels,
|
|
||||||
textvariable=l_var,
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=270,
|
|
||||||
height=36,
|
|
||||||
)
|
)
|
||||||
self._bot_entries.append(entry)
|
self._bot_entries.append(entry)
|
||||||
self._bot_lvl_vars.append(l_var)
|
self._bot_lvl_vars.append(l_var)
|
||||||
self._bot_dds.append(dd)
|
self._bot_dds.append(dd)
|
||||||
|
|
||||||
def start_match():
|
|
||||||
bots = self._collect_and_save_bots()
|
|
||||||
WattenTableView(
|
|
||||||
self.ctx,
|
|
||||||
variant_key="watten_std",
|
|
||||||
bot_configs=bots,
|
|
||||||
on_back_to_menu=self.show,
|
|
||||||
)
|
|
||||||
|
|
||||||
start_btn = ImageButton(
|
start_btn = ImageButton(
|
||||||
cv,
|
cv,
|
||||||
t("wt_start_btn"),
|
t("wt_start_btn"),
|
||||||
btn_fire,
|
btn_fire,
|
||||||
btn_fire,
|
btn_fire,
|
||||||
start_match,
|
lambda: WattenTableView(
|
||||||
|
self.ctx, variant_key="watten_std", bot_configs=self._collect_and_save_bots(), on_back_to_menu=self.show
|
||||||
|
),
|
||||||
sound_mgr=self.ctx.sounds,
|
sound_mgr=self.ctx.sounds,
|
||||||
width=210,
|
width=210,
|
||||||
height=40,
|
height=40,
|
||||||
style="fire",
|
style="fire",
|
||||||
)
|
)
|
||||||
|
|
||||||
seat_role_keys = (
|
seat_role_keys = ("wt_menu_seat_west", "wt_menu_seat_partner", "wt_menu_seat_east")
|
||||||
"wt_menu_seat_west", # idx 0 -> Sitz 1 (Gegner Links)
|
|
||||||
"wt_menu_seat_partner", # idx 1 -> Sitz 2 (Partner Oben!)
|
|
||||||
"wt_menu_seat_east", # idx 2 -> Sitz 3 (Gegner Rechts)
|
|
||||||
)
|
|
||||||
|
|
||||||
def draw_layout(w: int, h: int):
|
def draw_layout(w: int, h: int):
|
||||||
cv.sync_bg(w, h)
|
cv.sync_bg(w, h)
|
||||||
cv.delete("fg")
|
cv.delete("fg")
|
||||||
self._photo_refs.clear()
|
self._photo_refs.clear()
|
||||||
|
|
||||||
box_w = min(940, w - 120)
|
rw, rh = self.ctx.root.winfo_width(), self.ctx.root.winfo_height()
|
||||||
|
is_mobile = LayoutMode.is_compact(rw, rh) or (w < 780)
|
||||||
|
pad_x = LayoutMode.outer_pad_x(w, h, desktop_ratio=0.075, desktop_min=64)
|
||||||
|
|
||||||
|
box_w = min(940, w - 2 * pad_x)
|
||||||
cx = w // 2
|
cx = w // 2
|
||||||
x_left = cx - box_w // 2
|
x_left = cx - box_w // 2
|
||||||
cur_y = max(20, int(h * 0.045))
|
cur_y = 12 if is_mobile else max(20, int(h * 0.045))
|
||||||
|
|
||||||
title_ph = self.ctx.assets.get_goth_text_photo(
|
title_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t(GAME_TITLE_KEY), FONT_SIZE_TITLE_LG, FONT_COLOR_TITLE_MAIN, align="left"
|
t(GAME_TITLE_KEY), FONT_SIZE_TITLE_LG - (4 if is_mobile else 0), FONT_COLOR_TITLE_MAIN, align="left"
|
||||||
)
|
)
|
||||||
sub_ph = self.ctx.assets.get_goth_text_photo(
|
sub_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("wt_menu_subtitle"),
|
t("wt_menu_subtitle"), FONT_SIZE_BODY, FONT_COLOR_BODY_MUTED, max_width=box_w, align="left"
|
||||||
FONT_SIZE_BODY,
|
|
||||||
FONT_COLOR_BODY_MUTED,
|
|
||||||
max_width=box_w,
|
|
||||||
align="left",
|
|
||||||
)
|
)
|
||||||
self._photo_refs.extend([title_ph, sub_ph])
|
self._photo_refs.extend([title_ph, sub_ph])
|
||||||
cv.create_image(x_left, cur_y, image=title_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left, cur_y, image=title_ph, anchor="nw", tags="fg")
|
||||||
cur_y += title_ph.height() + 4
|
cur_y += title_ph.height() + 4
|
||||||
cv.create_image(x_left, cur_y, image=sub_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left, cur_y, image=sub_ph, anchor="nw", tags="fg")
|
||||||
cur_y += sub_ph.height() + 16
|
cur_y += sub_ph.height() + 14
|
||||||
|
|
||||||
# 1. Regelwerk & Lehrmeister-Tutorial-Box
|
|
||||||
s1_ph = self.ctx.assets.get_goth_text_photo(
|
s1_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("wt_rules_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
t("wt_rules_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
||||||
)
|
)
|
||||||
self._photo_refs.append(s1_ph)
|
self._photo_refs.append(s1_ph)
|
||||||
cv.create_image(x_left + 6, cur_y, image=s1_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left + 4, cur_y, image=s1_ph, anchor="nw", tags="fg")
|
||||||
cur_y += s1_ph.height() + 6
|
cur_y += s1_ph.height() + 6
|
||||||
|
|
||||||
r_box_h = 84
|
r_box_h = 114 if is_mobile else 84
|
||||||
r_cy = cur_y + r_box_h // 2
|
r_cy = cur_y + r_box_h // 2
|
||||||
r_box = self.ctx.assets.get_box_photo("box_gold_double", (box_w, r_box_h))
|
r_box = self.ctx.assets.get_box_photo("box_gold_double", (box_w, r_box_h))
|
||||||
if r_box:
|
if r_box:
|
||||||
|
|
@ -241,28 +211,61 @@ class WattenMenuView:
|
||||||
t("variant_watten_std"), FONT_SIZE_HEADING - 3, FONT_COLOR_TITLE_MAIN, align="left"
|
t("variant_watten_std"), FONT_SIZE_HEADING - 3, FONT_COLOR_TITLE_MAIN, align="left"
|
||||||
)
|
)
|
||||||
d_ph = self.ctx.assets.get_goth_text_photo(
|
d_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("wt_rule_summary"),
|
t("wt_rule_summary"), FONT_SIZE_SMALL_MIN, FONT_COLOR_BODY_DEFAULT,
|
||||||
FONT_SIZE_SMALL_MIN,
|
max_width=box_w - (44 if is_mobile else 270), align="left",
|
||||||
FONT_COLOR_BODY_DEFAULT,
|
|
||||||
max_width=box_w - 285,
|
|
||||||
align="left",
|
|
||||||
)
|
)
|
||||||
self._photo_refs.extend([v_ph, d_ph])
|
self._photo_refs.extend([v_ph, d_ph])
|
||||||
|
if is_mobile:
|
||||||
|
cv.create_image(x_left + 22, cur_y + 22, image=v_ph, anchor="w", tags="fg")
|
||||||
|
cv.create_window(x_left + box_w - 20, cur_y + 24, window=tut_btn, anchor="e", tags="fg")
|
||||||
|
cv.create_image(x_left + 22, cur_y + 72, image=d_ph, anchor="w", tags="fg")
|
||||||
|
else:
|
||||||
cv.create_image(x_left + 26, r_cy - 16, image=v_ph, anchor="w", tags="fg")
|
cv.create_image(x_left + 26, r_cy - 16, image=v_ph, anchor="w", tags="fg")
|
||||||
cv.create_image(x_left + 26, r_cy + 16, image=d_ph, anchor="w", tags="fg")
|
cv.create_image(x_left + 26, r_cy + 16, image=d_ph, anchor="w", tags="fg")
|
||||||
cv.create_window(
|
cv.create_window(x_left + box_w - 24, r_cy, window=tut_btn, anchor="e", tags="fg")
|
||||||
x_left + box_w - 24, r_cy, window=tut_btn, anchor="e", tags="fg"
|
cur_y += r_box_h + 14
|
||||||
)
|
|
||||||
cur_y += r_box_h + 16
|
|
||||||
|
|
||||||
# 2. Partner & Gegner konfigurieren
|
|
||||||
s2_ph = self.ctx.assets.get_goth_text_photo(
|
s2_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("wt_bots_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
t("wt_bots_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
||||||
)
|
)
|
||||||
self._photo_refs.append(s2_ph)
|
self._photo_refs.append(s2_ph)
|
||||||
cv.create_image(x_left + 6, cur_y, image=s2_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left + 4, cur_y, image=s2_ph, anchor="nw", tags="fg")
|
||||||
cur_y += s2_ph.height() + 6
|
cur_y += s2_ph.height() + 6
|
||||||
|
|
||||||
|
if is_mobile:
|
||||||
|
b_box_h = 286
|
||||||
|
b_cy = cur_y + b_box_h // 2
|
||||||
|
b_box = self.ctx.assets.get_box_photo("box_big", (box_w, b_box_h))
|
||||||
|
if b_box:
|
||||||
|
self._photo_refs.append(b_box)
|
||||||
|
cv.create_image(cx, b_cy, image=b_box, anchor="center", tags="fg")
|
||||||
|
|
||||||
|
in_w = box_w - 44
|
||||||
|
ent_w = max(140, int(in_w * 0.44))
|
||||||
|
dd_w = max(150, in_w - ent_w - 10)
|
||||||
|
for idx in range(WT_BOT_COUNT):
|
||||||
|
ry = cur_y + 26 + idx * 72
|
||||||
|
seat_lbl = self.ctx.assets.get_goth_text_photo(
|
||||||
|
t(seat_role_keys[idx]), FONT_SIZE_SMALL_MIN + 1, FONT_COLOR_HEADING_SUB, align="left"
|
||||||
|
)
|
||||||
|
self._photo_refs.append(seat_lbl)
|
||||||
|
cv.create_image(x_left + 22, ry, image=seat_lbl, anchor="w", tags="fg")
|
||||||
|
|
||||||
|
ent = self._bot_entries[idx]
|
||||||
|
if hasattr(ent, "resize") and ent._width != ent_w:
|
||||||
|
ent.resize(ent_w)
|
||||||
|
cv.create_window(x_left + 22, ry + 30, window=ent, anchor="w", tags="fg")
|
||||||
|
|
||||||
|
dd = self._bot_dds[idx]
|
||||||
|
if dd._width != dd_w:
|
||||||
|
dd._width = dd_w
|
||||||
|
dd.configure(width=dd_w)
|
||||||
|
dd._render_closed()
|
||||||
|
cv.create_window(x_left + box_w - 22, ry + 30, window=dd, anchor="e", tags="fg")
|
||||||
|
|
||||||
|
cv.create_window(x_left + box_w - 24, cur_y + b_box_h - 32, window=start_btn, anchor="e", tags="fg")
|
||||||
|
cv.set_scrollable_height(cur_y + b_box_h + 20, h)
|
||||||
|
else:
|
||||||
b_box_h = 236
|
b_box_h = 236
|
||||||
b_cy = cur_y + b_box_h // 2
|
b_cy = cur_y + b_box_h // 2
|
||||||
b_box = self.ctx.assets.get_box_photo("box_big", (box_w, b_box_h))
|
b_box = self.ctx.assets.get_box_photo("box_big", (box_w, b_box_h))
|
||||||
|
|
@ -270,7 +273,8 @@ class WattenMenuView:
|
||||||
self._photo_refs.append(b_box)
|
self._photo_refs.append(b_box)
|
||||||
cv.create_image(cx, b_cy, image=b_box, anchor="center", tags="fg")
|
cv.create_image(cx, b_cy, image=b_box, anchor="center", tags="fg")
|
||||||
|
|
||||||
dd_w = max(210, box_w - 460)
|
ent_w = 220
|
||||||
|
dd_w = max(200, box_w - 446)
|
||||||
for idx in range(WT_BOT_COUNT):
|
for idx in range(WT_BOT_COUNT):
|
||||||
ry = cur_y + 38 + idx * 50
|
ry = cur_y + 38 + idx * 50
|
||||||
seat_lbl = self.ctx.assets.get_goth_text_photo(
|
seat_lbl = self.ctx.assets.get_goth_text_photo(
|
||||||
|
|
@ -278,19 +282,22 @@ class WattenMenuView:
|
||||||
)
|
)
|
||||||
self._photo_refs.append(seat_lbl)
|
self._photo_refs.append(seat_lbl)
|
||||||
cv.create_image(x_left + 28, ry, image=seat_lbl, anchor="w", tags="fg")
|
cv.create_image(x_left + 28, ry, image=seat_lbl, anchor="w", tags="fg")
|
||||||
cv.create_window(x_left + 168, ry, window=self._bot_entries[idx], anchor="w", tags="fg")
|
|
||||||
|
ent = self._bot_entries[idx]
|
||||||
|
if hasattr(ent, "resize") and ent._width != ent_w:
|
||||||
|
ent.resize(ent_w)
|
||||||
|
cv.create_window(x_left + 168, ry, window=ent, anchor="w", tags="fg")
|
||||||
|
|
||||||
dd = self._bot_dds[idx]
|
dd = self._bot_dds[idx]
|
||||||
if dd._width != dd_w:
|
if dd._width != dd_w:
|
||||||
dd._width = dd_w
|
dd._width = dd_w
|
||||||
dd.configure(width=dd_w)
|
dd.configure(width=dd_w)
|
||||||
dd._render_closed()
|
dd._render_closed()
|
||||||
cv.create_window(x_left + 416, ry, window=dd, anchor="w", tags="fg")
|
cv.create_window(x_left + 402, ry, window=dd, anchor="w", tags="fg")
|
||||||
|
|
||||||
cv.create_window(
|
cv.create_window(x_left + box_w - 32, cur_y + b_box_h - 36, window=start_btn, anchor="e", tags="fg")
|
||||||
x_left + box_w - 32, cur_y + b_box_h - 36, window=start_btn, anchor="e", tags="fg"
|
cv.set_scrollable_height(cur_y + b_box_h + 20, h)
|
||||||
)
|
|
||||||
|
|
||||||
cv.bind("<Configure>", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None)
|
cv.bind("<Configure>", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None)
|
||||||
self.ctx.root.update_idletasks()
|
self.ctx.root.update_idletasks()
|
||||||
draw_layout(max(900, cv.winfo_width()), max(620, cv.winfo_height()))
|
draw_layout(max(460, cv.winfo_width()), max(560, cv.winfo_height()))
|
||||||
|
|
@ -15,8 +15,8 @@ from resources.code_res.game_constants import (
|
||||||
SUBTLE_BORDER,
|
SUBTLE_BORDER,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_result_dialog_base import CasinoResultDialogBase
|
from view.widgets.shared_bases.casino_result_dialog_base import CasinoResultDialogBase
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
|
|
||||||
class WattenResultDialog(CasinoResultDialogBase):
|
class WattenResultDialog(CasinoResultDialogBase):
|
||||||
|
|
|
||||||
|
|
@ -5,32 +5,25 @@ from __future__ import annotations
|
||||||
import time
|
import time
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
from games.party.watten.models.watten_ai import WattenBotAI
|
|
||||||
from games.party.watten.models.watten_engine import (
|
from games.party.watten.models.watten_engine import (
|
||||||
PHASE_ANSAGE_SCHLAG,
|
|
||||||
PHASE_ANSAGE_TRUMPF,
|
|
||||||
PHASE_AUSSCHAFFEN_REPLY,
|
|
||||||
PHASE_HAND_DONE,
|
PHASE_HAND_DONE,
|
||||||
PHASE_MATCH_DONE,
|
PHASE_MATCH_DONE,
|
||||||
PHASE_SCHOENERE_ASK,
|
|
||||||
PHASE_SCHOENERE_REPLY,
|
|
||||||
PHASE_TRICK_PLAY,
|
PHASE_TRICK_PLAY,
|
||||||
WattenEngine,
|
WattenEngine,
|
||||||
)
|
)
|
||||||
from games.party.watten.models.watten_rules import WATTEN_RANKS_32
|
|
||||||
from games.party.watten.views.watten_arena_renderer import WattenArenaRenderer
|
from games.party.watten.views.watten_arena_renderer import WattenArenaRenderer
|
||||||
from games.party.watten.views.watten_result_dialog import WattenResultDialog
|
from games.party.watten.views.watten_result_dialog import WattenResultDialog
|
||||||
from models.bavarian_deck import BavarianCard
|
from games.party.watten.views.watten_turn_driver import WattenTurnDriver
|
||||||
|
from models.cards.bavarian_deck import BavarianCard
|
||||||
from models.progression import Progression
|
from models.progression import Progression
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
BAVARIAN_SUITS,
|
|
||||||
WT_BOT_TURN_DELAY_MS,
|
WT_BOT_TURN_DELAY_MS,
|
||||||
WT_TRICK_CLEAR_DELAY_MS,
|
WT_TRICK_CLEAR_DELAY_MS,
|
||||||
WT_VARIANTS,
|
WT_VARIANTS,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_arena_base import CasinoArenaBase
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.shared_bases.casino_arena_base import CasinoArenaBase
|
||||||
|
|
||||||
GAME_FOLDER_ID = "party/watten"
|
GAME_FOLDER_ID = "party/watten"
|
||||||
|
|
||||||
|
|
@ -160,167 +153,9 @@ class WattenTableView(CasinoArenaBase):
|
||||||
if self._result_dialog is not None and self._result_dialog.winfo_exists():
|
if self._result_dialog is not None and self._result_dialog.winfo_exists():
|
||||||
tk.Widget.tkraise(self._result_dialog)
|
tk.Widget.tkraise(self._result_dialog)
|
||||||
|
|
||||||
# --- Steuerung & Phasen-Buttons für den menschlichen Spieler (Sitz 0) ---
|
|
||||||
def _sync_turn_controls(self):
|
def _sync_turn_controls(self):
|
||||||
if not hasattr(self, "bottom_bar") or not self.bottom_bar.winfo_exists():
|
WattenTurnDriver.sync_turn_controls(self)
|
||||||
return
|
|
||||||
eng = self.engine
|
|
||||||
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
|
|
||||||
|
|
||||||
if eng.phase == PHASE_MATCH_DONE:
|
|
||||||
self.status_var.set("")
|
|
||||||
self._set_bottom_buttons([])
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_HAND_DONE:
|
|
||||||
w_team = eng.hand_winner_team or 0
|
|
||||||
msg_key = "wt_status_hand_won" if w_team == 0 else "wt_status_hand_lost"
|
|
||||||
self.status_var.set(t(msg_key, eng.hand_points_awarded))
|
|
||||||
nxt_btn = ImageButton(
|
|
||||||
self.bottom_bar,
|
|
||||||
t("wt_btn_next_hand"),
|
|
||||||
btn_fire,
|
|
||||||
btn_fire,
|
|
||||||
self._start_next_hand,
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=188,
|
|
||||||
height=32,
|
|
||||||
style="fire",
|
|
||||||
)
|
|
||||||
self._set_bottom_buttons([nxt_btn], overflow_buttons=[self._menu_btn])
|
|
||||||
return
|
|
||||||
|
|
||||||
if self._visible_completed_trick or eng.turn_seat != 0:
|
|
||||||
if not self._visible_completed_trick:
|
|
||||||
actor = eng.seats[eng.turn_seat].name
|
|
||||||
self.status_var.set(t("wt_status_waiting_for", actor))
|
|
||||||
self._set_bottom_buttons([], overflow_buttons=[self._menu_btn])
|
|
||||||
return
|
|
||||||
|
|
||||||
# Menschlicher Spieler ist am Zug:
|
|
||||||
if eng.phase in (PHASE_SCHOENERE_ASK, PHASE_ANSAGE_SCHLAG):
|
|
||||||
self.status_var.set(t("wt_status_pick_schlag"))
|
|
||||||
rank_btns = [
|
|
||||||
ImageButton(
|
|
||||||
self.bottom_bar,
|
|
||||||
rk,
|
|
||||||
btn_norm,
|
|
||||||
btn_purp,
|
|
||||||
lambda r=rk: self._on_human_schlag(r),
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=54,
|
|
||||||
height=30,
|
|
||||||
style="amethyst",
|
|
||||||
)
|
|
||||||
for rk in WATTEN_RANKS_32
|
|
||||||
]
|
|
||||||
ovf = [self._menu_btn]
|
|
||||||
if eng.phase == PHASE_SCHOENERE_ASK:
|
|
||||||
ovf.insert(
|
|
||||||
0,
|
|
||||||
ImageButton(
|
|
||||||
self.bottom_bar,
|
|
||||||
t("wt_btn_ask_schoenere"),
|
|
||||||
btn_fire,
|
|
||||||
btn_fire,
|
|
||||||
self._on_human_ask_schoenere,
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=136,
|
|
||||||
height=30,
|
|
||||||
style="fire",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
self._set_bottom_buttons(rank_btns, overflow_buttons=ovf)
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_SCHOENERE_REPLY:
|
|
||||||
self.status_var.set(t("wt_status_reply_schoenere", eng.seats[eng.ansager_seat].name))
|
|
||||||
b_yes = ImageButton(
|
|
||||||
self.bottom_bar, t("wt_btn_schoenere_yes"), btn_fire, btn_fire,
|
|
||||||
lambda: self._on_human_reply_schoenere(True),
|
|
||||||
sound_mgr=self.ctx.sounds, width=164, height=32, style="fire",
|
|
||||||
)
|
|
||||||
b_no = ImageButton(
|
|
||||||
self.bottom_bar, t("wt_btn_schoenere_no"), btn_norm, btn_purp,
|
|
||||||
lambda: self._on_human_reply_schoenere(False),
|
|
||||||
sound_mgr=self.ctx.sounds, width=164, height=32, style="amethyst",
|
|
||||||
)
|
|
||||||
self._set_bottom_buttons([b_yes, b_no], overflow_buttons=[self._menu_btn])
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_ANSAGE_TRUMPF:
|
|
||||||
self.status_var.set(t("wt_status_pick_trumpf", t(f"bav_rank_{eng.schlag_rank}")))
|
|
||||||
suit_btns = [
|
|
||||||
ImageButton(
|
|
||||||
self.bottom_bar,
|
|
||||||
t(f"bav_suit_{s}"),
|
|
||||||
btn_fire,
|
|
||||||
btn_fire,
|
|
||||||
lambda su=s: self._on_human_trumpf(su),
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=116,
|
|
||||||
height=32,
|
|
||||||
style="fire",
|
|
||||||
)
|
|
||||||
for s in BAVARIAN_SUITS
|
|
||||||
]
|
|
||||||
self._set_bottom_buttons(suit_btns, overflow_buttons=[self._menu_btn])
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_AUSSCHAFFEN_REPLY:
|
|
||||||
self.status_var.set(t("wt_status_opp_raised", eng.proposed_stake, eng.current_stake))
|
|
||||||
b_hold = ImageButton(
|
|
||||||
self.bottom_bar,
|
|
||||||
t("wt_btn_hold_stake", eng.proposed_stake),
|
|
||||||
btn_fire,
|
|
||||||
btn_fire,
|
|
||||||
lambda: self._on_human_reply_ausschaffen(True),
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=176,
|
|
||||||
height=32,
|
|
||||||
style="fire",
|
|
||||||
)
|
|
||||||
b_fold = ImageButton(
|
|
||||||
self.bottom_bar,
|
|
||||||
t("wt_btn_fold_hand"),
|
|
||||||
btn_norm,
|
|
||||||
btn_purp,
|
|
||||||
lambda: self._on_human_reply_ausschaffen(False),
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=168,
|
|
||||||
height=32,
|
|
||||||
style="amethyst",
|
|
||||||
)
|
|
||||||
self._set_bottom_buttons([b_hold, b_fold], overflow_buttons=[self._menu_btn])
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_TRICK_PLAY:
|
|
||||||
playable = eng.get_playable_cards(0)
|
|
||||||
if len(playable) < len(eng.seats[0].hand):
|
|
||||||
self.status_var.set(t("wt_status_trump_compulsion"))
|
|
||||||
else:
|
|
||||||
self.status_var.set(t("wt_status_your_turn_card"))
|
|
||||||
|
|
||||||
prim: list[ImageButton] = []
|
|
||||||
if eng.can_seat_ausschaffen(0):
|
|
||||||
prim.append(
|
|
||||||
ImageButton(
|
|
||||||
self.bottom_bar,
|
|
||||||
t("wt_btn_ausschaffen", eng.current_stake + 1),
|
|
||||||
btn_fire,
|
|
||||||
btn_fire,
|
|
||||||
self._on_human_ausschaffen,
|
|
||||||
sound_mgr=self.ctx.sounds,
|
|
||||||
width=186,
|
|
||||||
height=32,
|
|
||||||
style="fire",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._set_bottom_buttons(prim, overflow_buttons=[self._menu_btn])
|
|
||||||
|
|
||||||
# --- Menschliche Klick-Aktionen ---
|
|
||||||
def _on_human_ask_schoenere(self):
|
def _on_human_ask_schoenere(self):
|
||||||
if self.engine.ask_schoenere(0):
|
if self.engine.ask_schoenere(0):
|
||||||
self._render_table()
|
self._render_table()
|
||||||
|
|
@ -374,7 +209,6 @@ class WattenTableView(CasinoArenaBase):
|
||||||
self._handle_post_card_play(res)
|
self._handle_post_card_play(res)
|
||||||
return
|
return
|
||||||
|
|
||||||
# --- Spielfluss & KI-Züge ---
|
|
||||||
def _handle_post_card_play(self, res: str):
|
def _handle_post_card_play(self, res: str):
|
||||||
if res in ("trick_completed", "hand_completed", "match_completed"):
|
if res in ("trick_completed", "hand_completed", "match_completed"):
|
||||||
self._visible_completed_trick = list(self.engine.last_completed_trick)
|
self._visible_completed_trick = list(self.engine.last_completed_trick)
|
||||||
|
|
@ -410,85 +244,9 @@ class WattenTableView(CasinoArenaBase):
|
||||||
self._sync_turn_controls()
|
self._sync_turn_controls()
|
||||||
if self.engine.phase != PHASE_HAND_DONE and self.engine.turn_seat != 0:
|
if self.engine.phase != PHASE_HAND_DONE and self.engine.turn_seat != 0:
|
||||||
self._turn_job = self.ctx.root.after(
|
self._turn_job = self.ctx.root.after(
|
||||||
WT_BOT_TURN_DELAY_MS, self._execute_bot_step
|
WT_BOT_TURN_DELAY_MS, lambda: WattenTurnDriver.execute_bot_step(self)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _execute_bot_step(self):
|
|
||||||
self._turn_job = None
|
|
||||||
if not self._canvas_alive() or self.engine.turn_seat == 0:
|
|
||||||
return
|
|
||||||
eng = self.engine
|
|
||||||
bot = eng.seats[eng.turn_seat]
|
|
||||||
|
|
||||||
if eng.phase == PHASE_SCHOENERE_ASK:
|
|
||||||
if WattenBotAI.should_ask_schoenere(bot):
|
|
||||||
bot.status_text = t("wt_act_asked_schoenere")
|
|
||||||
eng.ask_schoenere(bot.seat_id)
|
|
||||||
else:
|
|
||||||
eng.skip_schoenere(bot.seat_id)
|
|
||||||
self._render_table()
|
|
||||||
self._advance_flow()
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_SCHOENERE_REPLY:
|
|
||||||
accept = WattenBotAI.should_accept_schoenere(bot)
|
|
||||||
bot.status_text = (
|
|
||||||
t("wt_act_schoenere_yes") if accept else t("wt_act_schoenere_no")
|
|
||||||
)
|
|
||||||
eng.reply_schoenere(bot.seat_id, accept)
|
|
||||||
if accept:
|
|
||||||
self.ctx.sounds.play("deal")
|
|
||||||
self._render_table()
|
|
||||||
self._advance_flow()
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_ANSAGE_SCHLAG:
|
|
||||||
rk = WattenBotAI.choose_schlag(bot)
|
|
||||||
bot.status_text = f"{t('wt_lbl_schlag')}: {t(f'bav_rank_{rk}')}"
|
|
||||||
eng.declare_schlag(bot.seat_id, rk)
|
|
||||||
self.ctx.sounds.play("click")
|
|
||||||
self._render_table()
|
|
||||||
self._advance_flow()
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_ANSAGE_TRUMPF:
|
|
||||||
su = WattenBotAI.choose_trumpf(bot, eng.schlag_rank or "O")
|
|
||||||
bot.status_text = f"{t('wt_lbl_trumpf')}: {t(f'bav_suit_{su}')}"
|
|
||||||
eng.declare_trumpf(bot.seat_id, su)
|
|
||||||
self.ctx.sounds.play("click")
|
|
||||||
self._render_table()
|
|
||||||
self._advance_flow()
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_AUSSCHAFFEN_REPLY:
|
|
||||||
hold = WattenBotAI.should_hold_ausschaffen(eng, bot)
|
|
||||||
bot.status_text = (
|
|
||||||
t("wt_act_held", eng.proposed_stake)
|
|
||||||
if hold
|
|
||||||
else t("wt_act_folded")
|
|
||||||
)
|
|
||||||
eng.respond_ausschaffen(bot.seat_id, hold)
|
|
||||||
self.ctx.sounds.play("click" if hold else "stand")
|
|
||||||
self._render_table()
|
|
||||||
self._advance_flow()
|
|
||||||
return
|
|
||||||
|
|
||||||
if eng.phase == PHASE_TRICK_PLAY:
|
|
||||||
if WattenBotAI.should_ausschaffen(eng, bot):
|
|
||||||
bot.status_text = t("wt_act_raised", eng.current_stake + 1)
|
|
||||||
eng.initiate_ausschaffen(bot.seat_id)
|
|
||||||
self.ctx.sounds.play("stand")
|
|
||||||
self._render_table()
|
|
||||||
self._advance_flow()
|
|
||||||
return
|
|
||||||
|
|
||||||
chosen = WattenBotAI.choose_card(eng, bot)
|
|
||||||
bot.status_text = f"{t(f'bav_suit_{chosen.suit}')} {chosen.rank}"
|
|
||||||
res = eng.play_card(bot.seat_id, chosen)
|
|
||||||
self.ctx.sounds.play("click")
|
|
||||||
self._handle_post_card_play(res)
|
|
||||||
|
|
||||||
# --- Match-Abschluss & XP ---
|
|
||||||
def _finalize_match(self):
|
def _finalize_match(self):
|
||||||
self._set_bottom_buttons([])
|
self._set_bottom_buttons([])
|
||||||
self.status_var.set("")
|
self.status_var.set("")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,264 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# games/party/watten/views/watten_turn_driver.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from games.party.watten.models.watten_ai import WattenBotAI
|
||||||
|
from games.party.watten.models.watten_engine import (
|
||||||
|
PHASE_ANSAGE_SCHLAG,
|
||||||
|
PHASE_ANSAGE_TRUMPF,
|
||||||
|
PHASE_AUSSCHAFFEN_REPLY,
|
||||||
|
PHASE_HAND_DONE,
|
||||||
|
PHASE_MATCH_DONE,
|
||||||
|
PHASE_SCHOENERE_ASK,
|
||||||
|
PHASE_SCHOENERE_REPLY,
|
||||||
|
PHASE_TRICK_PLAY,
|
||||||
|
)
|
||||||
|
from games.party.watten.models.watten_rules import WATTEN_RANKS_32
|
||||||
|
from resources.code_res.game_constants import BAVARIAN_SUITS
|
||||||
|
from resources.code_res.i18n import t
|
||||||
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
|
|
||||||
|
class WattenTurnDriver:
|
||||||
|
"""Kapselt die Phasen-Buttons der Fußleiste sowie die KI-Zugausführung für Watten."""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sync_turn_controls(view) -> None:
|
||||||
|
if not hasattr(view, "bottom_bar") or not view.bottom_bar.winfo_exists():
|
||||||
|
return
|
||||||
|
eng = view.engine
|
||||||
|
btn_norm = view.ctx.assets.raw_btn_default
|
||||||
|
btn_purp = view.ctx.assets.raw_btn_purple
|
||||||
|
btn_fire = view.ctx.assets.raw_btn_fire or btn_purp
|
||||||
|
|
||||||
|
if eng.phase == PHASE_MATCH_DONE:
|
||||||
|
view.status_var.set("")
|
||||||
|
view._set_bottom_buttons([])
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_HAND_DONE:
|
||||||
|
w_team = eng.hand_winner_team or 0
|
||||||
|
msg_key = "wt_status_hand_won" if w_team == 0 else "wt_status_hand_lost"
|
||||||
|
view.status_var.set(t(msg_key, eng.hand_points_awarded))
|
||||||
|
nxt_btn = ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t("wt_btn_next_hand"),
|
||||||
|
btn_fire,
|
||||||
|
btn_fire,
|
||||||
|
view._start_next_hand,
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=188,
|
||||||
|
height=32,
|
||||||
|
style="fire",
|
||||||
|
)
|
||||||
|
view._set_bottom_buttons([nxt_btn], overflow_buttons=[view._menu_btn])
|
||||||
|
return
|
||||||
|
|
||||||
|
if view._visible_completed_trick or eng.turn_seat != 0:
|
||||||
|
if not view._visible_completed_trick:
|
||||||
|
actor = eng.seats[eng.turn_seat].name
|
||||||
|
view.status_var.set(t("wt_status_waiting_for", actor))
|
||||||
|
view._set_bottom_buttons([], overflow_buttons=[view._menu_btn])
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase in (PHASE_SCHOENERE_ASK, PHASE_ANSAGE_SCHLAG):
|
||||||
|
view.status_var.set(t("wt_status_pick_schlag"))
|
||||||
|
rank_btns = [
|
||||||
|
ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
rk,
|
||||||
|
btn_norm,
|
||||||
|
btn_purp,
|
||||||
|
lambda r=rk: view._on_human_schlag(r),
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=54,
|
||||||
|
height=30,
|
||||||
|
style="amethyst",
|
||||||
|
)
|
||||||
|
for rk in WATTEN_RANKS_32
|
||||||
|
]
|
||||||
|
ovf = [view._menu_btn]
|
||||||
|
if eng.phase == PHASE_SCHOENERE_ASK:
|
||||||
|
ovf.insert(
|
||||||
|
0,
|
||||||
|
ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t("wt_btn_ask_schoenere"),
|
||||||
|
btn_fire,
|
||||||
|
btn_fire,
|
||||||
|
view._on_human_ask_schoenere,
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=136,
|
||||||
|
height=30,
|
||||||
|
style="fire",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
view._set_bottom_buttons(rank_btns, overflow_buttons=ovf)
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_SCHOENERE_REPLY:
|
||||||
|
view.status_var.set(t("wt_status_reply_schoenere", eng.seats[eng.ansager_seat].name))
|
||||||
|
b_yes = ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t("wt_btn_schoenere_yes"),
|
||||||
|
btn_fire,
|
||||||
|
btn_fire,
|
||||||
|
lambda: view._on_human_reply_schoenere(True),
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=164,
|
||||||
|
height=32,
|
||||||
|
style="fire",
|
||||||
|
)
|
||||||
|
b_no = ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t("wt_btn_schoenere_no"),
|
||||||
|
btn_norm,
|
||||||
|
btn_purp,
|
||||||
|
lambda: view._on_human_reply_schoenere(False),
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=164,
|
||||||
|
height=32,
|
||||||
|
style="amethyst",
|
||||||
|
)
|
||||||
|
view._set_bottom_buttons([b_yes, b_no], overflow_buttons=[view._menu_btn])
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_ANSAGE_TRUMPF:
|
||||||
|
view.status_var.set(t("wt_status_pick_trumpf", t(f"bav_rank_{eng.schlag_rank}")))
|
||||||
|
suit_btns = [
|
||||||
|
ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t(f"bav_suit_{s}"),
|
||||||
|
btn_fire,
|
||||||
|
btn_fire,
|
||||||
|
lambda su=s: view._on_human_trumpf(su),
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=116,
|
||||||
|
height=32,
|
||||||
|
style="fire",
|
||||||
|
)
|
||||||
|
for s in BAVARIAN_SUITS
|
||||||
|
]
|
||||||
|
view._set_bottom_buttons(suit_btns, overflow_buttons=[view._menu_btn])
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_AUSSCHAFFEN_REPLY:
|
||||||
|
view.status_var.set(t("wt_status_opp_raised", eng.proposed_stake, eng.current_stake))
|
||||||
|
b_hold = ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t("wt_btn_hold_stake", eng.proposed_stake),
|
||||||
|
btn_fire,
|
||||||
|
btn_fire,
|
||||||
|
lambda: view._on_human_reply_ausschaffen(True),
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=176,
|
||||||
|
height=32,
|
||||||
|
style="fire",
|
||||||
|
)
|
||||||
|
b_fold = ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t("wt_btn_fold_hand"),
|
||||||
|
btn_norm,
|
||||||
|
btn_purp,
|
||||||
|
lambda: view._on_human_reply_ausschaffen(False),
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=168,
|
||||||
|
height=32,
|
||||||
|
style="amethyst",
|
||||||
|
)
|
||||||
|
view._set_bottom_buttons([b_hold, b_fold], overflow_buttons=[view._menu_btn])
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_TRICK_PLAY:
|
||||||
|
playable = eng.get_playable_cards(0)
|
||||||
|
if len(playable) < len(eng.seats[0].hand):
|
||||||
|
view.status_var.set(t("wt_status_trump_compulsion"))
|
||||||
|
else:
|
||||||
|
view.status_var.set(t("wt_status_your_turn_card"))
|
||||||
|
|
||||||
|
prim: list[ImageButton] = []
|
||||||
|
if eng.can_seat_ausschaffen(0):
|
||||||
|
prim.append(
|
||||||
|
ImageButton(
|
||||||
|
view.bottom_bar,
|
||||||
|
t("wt_btn_ausschaffen", eng.current_stake + 1),
|
||||||
|
btn_fire,
|
||||||
|
btn_fire,
|
||||||
|
view._on_human_ausschaffen,
|
||||||
|
sound_mgr=view.ctx.sounds,
|
||||||
|
width=186,
|
||||||
|
height=32,
|
||||||
|
style="fire",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
view._set_bottom_buttons(prim, overflow_buttons=[view._menu_btn])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def execute_bot_step(view) -> None:
|
||||||
|
view._turn_job = None
|
||||||
|
if not view._canvas_alive() or view.engine.turn_seat == 0:
|
||||||
|
return
|
||||||
|
eng = view.engine
|
||||||
|
bot = eng.seats[eng.turn_seat]
|
||||||
|
|
||||||
|
if eng.phase == PHASE_SCHOENERE_ASK:
|
||||||
|
if WattenBotAI.should_ask_schoenere(bot):
|
||||||
|
bot.status_text = t("wt_act_asked_schoenere")
|
||||||
|
eng.ask_schoenere(bot.seat_id)
|
||||||
|
else:
|
||||||
|
eng.skip_schoenere(bot.seat_id)
|
||||||
|
view._render_table()
|
||||||
|
view._advance_flow()
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_SCHOENERE_REPLY:
|
||||||
|
accept = WattenBotAI.should_accept_schoenere(bot)
|
||||||
|
bot.status_text = t("wt_act_schoenere_yes") if accept else t("wt_act_schoenere_no")
|
||||||
|
eng.reply_schoenere(bot.seat_id, accept)
|
||||||
|
if accept:
|
||||||
|
view.ctx.sounds.play("deal")
|
||||||
|
view._render_table()
|
||||||
|
view._advance_flow()
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_ANSAGE_SCHLAG:
|
||||||
|
rk = WattenBotAI.choose_schlag(bot)
|
||||||
|
bot.status_text = f"{t('wt_lbl_schlag')}: {t(f'bav_rank_{rk}')}"
|
||||||
|
eng.declare_schlag(bot.seat_id, rk)
|
||||||
|
view.ctx.sounds.play("click")
|
||||||
|
view._render_table()
|
||||||
|
view._advance_flow()
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_ANSAGE_TRUMPF:
|
||||||
|
su = WattenBotAI.choose_trumpf(bot, eng.schlag_rank or "O")
|
||||||
|
bot.status_text = f"{t('wt_lbl_trumpf')}: {t(f'bav_suit_{su}')}"
|
||||||
|
eng.declare_trumpf(bot.seat_id, su)
|
||||||
|
view.ctx.sounds.play("click")
|
||||||
|
view._render_table()
|
||||||
|
view._advance_flow()
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_AUSSCHAFFEN_REPLY:
|
||||||
|
hold = WattenBotAI.should_hold_ausschaffen(eng, bot)
|
||||||
|
bot.status_text = t("wt_act_held", eng.proposed_stake) if hold else t("wt_act_folded")
|
||||||
|
eng.respond_ausschaffen(bot.seat_id, hold)
|
||||||
|
view.ctx.sounds.play("click" if hold else "stand")
|
||||||
|
view._render_table()
|
||||||
|
view._advance_flow()
|
||||||
|
return
|
||||||
|
|
||||||
|
if eng.phase == PHASE_TRICK_PLAY:
|
||||||
|
if WattenBotAI.should_ausschaffen(eng, bot):
|
||||||
|
bot.status_text = t("wt_act_raised", eng.current_stake + 1)
|
||||||
|
eng.initiate_ausschaffen(bot.seat_id)
|
||||||
|
view.ctx.sounds.play("stand")
|
||||||
|
view._render_table()
|
||||||
|
view._advance_flow()
|
||||||
|
return
|
||||||
|
|
||||||
|
chosen = WattenBotAI.choose_card(eng, bot)
|
||||||
|
bot.status_text = f"{t(f'bav_suit_{chosen.suit}')} {chosen.rank}"
|
||||||
|
res = eng.play_card(bot.seat_id, chosen)
|
||||||
|
view.ctx.sounds.play("click")
|
||||||
|
view._handle_post_card_play(res)
|
||||||
|
|
@ -8,7 +8,7 @@ from games.party.zehner_raus.models.zehner_raus_engine import (
|
||||||
ZehnerRausEngine,
|
ZehnerRausEngine,
|
||||||
ZehnerRausSeat,
|
ZehnerRausSeat,
|
||||||
)
|
)
|
||||||
from models.bavarian_deck import TEN_ORDER_INDEX, BavarianCard
|
from models.cards.bavarian_deck import TEN_ORDER_INDEX, BavarianCard
|
||||||
|
|
||||||
|
|
||||||
class ZehnerRausBotAI:
|
class ZehnerRausBotAI:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from models.bavarian_deck import (
|
from models.cards.bavarian_deck import (
|
||||||
BAVARIAN_RANKS,
|
BAVARIAN_RANKS,
|
||||||
TEN_ORDER_INDEX,
|
TEN_ORDER_INDEX,
|
||||||
BavarianCard,
|
BavarianCard,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/party/zehner_raus/views/zehner_raus_arena_renderer.py
|
# games/party/zehner_raus/views/zehner_raus_arena_renderer.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from models.bavarian_deck import BAVARIAN_RANKS, TEN_ORDER_INDEX, BavarianCard
|
from models.cards.bavarian_deck import BAVARIAN_RANKS, TEN_ORDER_INDEX, BavarianCard
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACCENT_GOLD,
|
ACCENT_GOLD,
|
||||||
ACCENT_GOTH,
|
ACCENT_GOTH,
|
||||||
|
|
@ -23,24 +23,16 @@ ZR_BOT_BACK_SIZE = (42, 62)
|
||||||
ZR_MAX_HAND_CARD_H = 186
|
ZR_MAX_HAND_CARD_H = 186
|
||||||
ZR_HAND_TOP_EXTEND_PX = 22
|
ZR_HAND_TOP_EXTEND_PX = 22
|
||||||
|
|
||||||
# Festes 2x2-Raster: Oben Eichel & Blatt, unten Herz & Schellen
|
|
||||||
ZR_GRID_SUITS = (
|
ZR_GRID_SUITS = (
|
||||||
("E", 0, 0), # Oben links: Eichel
|
("E", 0, 0),
|
||||||
("B", 0, 1), # Oben rechts: Blatt
|
("B", 0, 1),
|
||||||
("H", 1, 0), # Unten links: Herz
|
("H", 1, 0),
|
||||||
("S", 1, 1), # Unten rechts: Schellen
|
("S", 1, 1),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ZehnerRausArenaRenderer:
|
class ZehnerRausArenaRenderer:
|
||||||
"""
|
"""Rendert 10er raus (Desktop mit Seiten-Bots vs. Kompakt/Mobile mit 3er-Bot-Leiste oben)."""
|
||||||
Rendert für 10er raus:
|
|
||||||
- Außen links, oben und rechts die 3 Kultisten-Gegner
|
|
||||||
- Auf dem Tischfilz ein 2x2-Raster mit Mittelkreuz:
|
|
||||||
Oben: Eichel | Blatt
|
|
||||||
Unten: Herz | Schellen
|
|
||||||
- Unten die vergrößerte Spielerhand mit Gold-Highlight für legbare Karten.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def draw_bots(
|
def draw_bots(
|
||||||
|
|
@ -51,29 +43,33 @@ class ZehnerRausArenaRenderer:
|
||||||
pad_top: int,
|
pad_top: int,
|
||||||
table_rect: tuple[int, int, int, int],
|
table_rect: tuple[int, int, int, int],
|
||||||
) -> tuple[int, int, int]:
|
) -> tuple[int, int, int]:
|
||||||
"""Zeichnet die 3 Bots und gibt (top_bot_bottom_y, left_bot_right_x, right_bot_left_x) zurück."""
|
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
bots = view.engine.seats[1:]
|
bots = view.engine.seats[1:]
|
||||||
if len(bots) < 3:
|
if len(bots) < 3:
|
||||||
return ty1 + 20, tx1 + 60, tx2 - 60
|
return ty1 + 20, tx1 + 20, tx2 - 20
|
||||||
|
|
||||||
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
if compact:
|
||||||
|
gap = 6
|
||||||
|
avail_w = max(320, cw - 2 * pad_x)
|
||||||
|
box_w = min(212, (avail_w - 2 * gap) // 3)
|
||||||
|
box_h = 80
|
||||||
|
start_x = (cw - (3 * box_w + 2 * gap)) // 2 + box_w // 2
|
||||||
|
top_cy = pad_top + box_h // 2 + 2
|
||||||
|
coords = [(start_x + i * (box_w + gap), top_cy) for i in range(3)]
|
||||||
|
back_sz = (32, 48)
|
||||||
|
else:
|
||||||
box_w, box_h = 220, 90
|
box_w, box_h = 220, 90
|
||||||
mid_side_y = (ty1 + ty2) // 2 - 18
|
mid_side_y = (ty1 + ty2) // 2 - 18
|
||||||
top_cy = max(pad_top + box_h // 2 - 6, ty1 + int(box_h * 0.30))
|
top_cy = max(pad_top + box_h // 2 - 6, ty1 + int(box_h * 0.30))
|
||||||
left_cx = max(pad_x + box_w // 2 - 10, tx1 + int(box_w * 0.24))
|
left_cx = max(pad_x + box_w // 2 - 10, tx1 + int(box_w * 0.24))
|
||||||
right_cx = min(cw - pad_x - box_w // 2 + 10, tx2 - int(box_w * 0.24))
|
right_cx = min(cw - pad_x - box_w // 2 + 10, tx2 - int(box_w * 0.24))
|
||||||
|
coords = [(left_cx, mid_side_y), (cw // 2, top_cy), (right_cx, mid_side_y)]
|
||||||
|
back_sz = ZR_BOT_BACK_SIZE
|
||||||
|
|
||||||
coords = [
|
name_sz = max(12 if compact else 14, FONT_SIZE_SMALL_MIN if compact else FONT_SIZE_BODY - 1)
|
||||||
(left_cx, mid_side_y), # Sitz 1: Links
|
sub_sz = max(11 if compact else 12, FONT_SIZE_SMALL_MIN - (1 if compact else 0))
|
||||||
(cw // 2, top_cy), # Sitz 2: Oben Mitte
|
back_ph = view.ctx.assets.get_card_back_photo(size=back_sz, theme=BAVARIAN_CARD_THEME)
|
||||||
(right_cx, mid_side_y), # Sitz 3: Rechts
|
|
||||||
]
|
|
||||||
|
|
||||||
name_sz = max(14, FONT_SIZE_BODY - 1)
|
|
||||||
sub_sz = max(12, FONT_SIZE_SMALL_MIN)
|
|
||||||
back_ph = view.ctx.assets.get_card_back_photo(
|
|
||||||
size=ZR_BOT_BACK_SIZE, theme=BAVARIAN_CARD_THEME
|
|
||||||
)
|
|
||||||
if back_ph is not None:
|
if back_ph is not None:
|
||||||
view._photo_refs.append(back_ph)
|
view._photo_refs.append(back_ph)
|
||||||
|
|
||||||
|
|
@ -84,35 +80,28 @@ class ZehnerRausArenaRenderer:
|
||||||
warn_last = n_cards == 1
|
warn_last = n_cards == 1
|
||||||
|
|
||||||
view._draw_framed_panel(
|
view._draw_framed_panel(
|
||||||
bx,
|
bx, by, box_w, box_h,
|
||||||
by,
|
|
||||||
box_w,
|
|
||||||
box_h,
|
|
||||||
frame_style="gold" if is_turn else "purple",
|
frame_style="gold" if is_turn else "purple",
|
||||||
status_border=ERROR_FG if warn_last else None,
|
status_border=ERROR_FG if warn_last else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
if back_ph is not None and n_cards > 0:
|
if back_ph is not None and n_cards > 0 and (not compact or box_w >= 178):
|
||||||
vis_backs = min(5, n_cards)
|
vis_backs = min(4 if compact else 5, n_cards)
|
||||||
step_b = 9
|
step_b = 7 if compact else 9
|
||||||
bx0 = bx - box_w // 2 + 14
|
bx0 = bx - box_w // 2 + (10 if compact else 14)
|
||||||
by0 = by - ZR_BOT_BACK_SIZE[1] // 2
|
by0 = by - back_sz[1] // 2
|
||||||
for bi in range(vis_backs):
|
for bi in range(vis_backs):
|
||||||
view.arena_canvas.create_image(
|
view.arena_canvas.create_image(
|
||||||
bx0 + bi * step_b, by0, image=back_ph, anchor="nw", tags="fg"
|
bx0 + bi * step_b, by0, image=back_ph, anchor="nw", tags="fg"
|
||||||
)
|
)
|
||||||
txt_cx = bx + 30
|
txt_cx = bx + (22 if compact else 30)
|
||||||
max_tw = box_w - 96
|
max_tw = box_w - (74 if compact else 96)
|
||||||
else:
|
else:
|
||||||
txt_cx = bx
|
txt_cx = bx
|
||||||
max_tw = box_w - 28
|
max_tw = box_w - 18
|
||||||
|
|
||||||
n_col = ACCENT_GOLD if is_turn else ACCENT_GOTH
|
n_col = ACCENT_GOLD if is_turn else ACCENT_GOTH
|
||||||
cnt_txt = (
|
cnt_txt = t("zr_bot_one_card_left") if warn_last else t("zr_bot_cards_left", n_cards)
|
||||||
t("zr_bot_one_card_left")
|
|
||||||
if warn_last
|
|
||||||
else t("zr_bot_cards_left", n_cards)
|
|
||||||
)
|
|
||||||
cnt_col = ERROR_FG if warn_last else ACCENT_GOLD
|
cnt_col = ERROR_FG if warn_last else ACCENT_GOLD
|
||||||
act_txt = seat.status_text or "-"
|
act_txt = seat.status_text or "-"
|
||||||
|
|
||||||
|
|
@ -120,14 +109,18 @@ class ZehnerRausArenaRenderer:
|
||||||
c_ph = view._make_goth_photo(cnt_txt, sub_sz, cnt_col, max_tw)
|
c_ph = view._make_goth_photo(cnt_txt, sub_sz, cnt_col, max_tw)
|
||||||
a_ph = view._make_goth_photo(act_txt, sub_sz, FG_COLOR, max_tw)
|
a_ph = view._make_goth_photo(act_txt, sub_sz, FG_COLOR, max_tw)
|
||||||
|
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by - 22, n_ph, seat.name, name_sz, n_col)
|
dy = 20 if compact else 22
|
||||||
|
view._place_goth_photo_or_fallback(txt_cx, by - dy, n_ph, seat.name, name_sz, n_col)
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by, c_ph, cnt_txt, sub_sz, cnt_col)
|
view._place_goth_photo_or_fallback(txt_cx, by, c_ph, cnt_txt, sub_sz, cnt_col)
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by + 22, a_ph, act_txt, sub_sz, FG_COLOR)
|
view._place_goth_photo_or_fallback(txt_cx, by + dy, a_ph, act_txt, sub_sz, FG_COLOR)
|
||||||
|
|
||||||
|
if compact:
|
||||||
|
# Volle Breite links & rechts frei für das 2x2-Farbenkreuz!
|
||||||
|
return (top_cy + box_h // 2, 0, cw)
|
||||||
return (
|
return (
|
||||||
top_cy + box_h // 2,
|
top_cy + box_h // 2,
|
||||||
left_cx + box_w // 2,
|
coords[0][0] + box_w // 2,
|
||||||
right_cx - box_w // 2,
|
coords[2][0] - box_w // 2,
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -137,61 +130,43 @@ class ZehnerRausArenaRenderer:
|
||||||
bot_bounds: tuple[int, int, int],
|
bot_bounds: tuple[int, int, int],
|
||||||
player_top_y: int,
|
player_top_y: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
|
||||||
Zeichnet die 4 Farben kompakt in einem 2x2-Raster direkt auf den Tischfilz
|
|
||||||
(ohne Hintergrundkasten, nur getrennt durch ein sauberes Mittelkreuz):
|
|
||||||
Oben: Eichel | Blatt
|
|
||||||
Unten: Herz | Schellen
|
|
||||||
"""
|
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
top_obs_y, left_obs_x, right_obs_x = bot_bounds
|
top_obs_y, left_obs_x, right_obs_x = bot_bounds
|
||||||
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
|
||||||
hand_real_top = player_top_y - ZR_HAND_TOP_EXTEND_PX
|
hand_real_top = player_top_y - (10 if compact else ZR_HAND_TOP_EXTEND_PX)
|
||||||
felt_top = max(ty1 + 14, top_obs_y + 8)
|
felt_top = max(ty1 + (6 if compact else 14), top_obs_y + 8)
|
||||||
felt_bot = min(ty2 - 12, hand_real_top - 10)
|
felt_bot = min(ty2 - (4 if compact else 12), hand_real_top - 8)
|
||||||
avail_h = max(170, felt_bot - felt_top)
|
avail_h = max(160, felt_bot - felt_top)
|
||||||
|
|
||||||
felt_left = max(tx1 + 48, left_obs_x + 16)
|
side_pad = 6 if compact else 48
|
||||||
felt_right = min(tx2 - 48, right_obs_x - 16)
|
felt_left = max(tx1 + side_pad, left_obs_x + (6 if compact else 16))
|
||||||
avail_w = max(440, felt_right - felt_left)
|
felt_right = min(tx2 - side_pad, right_obs_x - (6 if compact else 16))
|
||||||
|
avail_w = max(340, felt_right - felt_left)
|
||||||
|
|
||||||
grid_w = min(avail_w, 840)
|
grid_w = min(avail_w, 840)
|
||||||
grid_h = min(avail_h, 268)
|
grid_h = min(avail_h, 286 if compact else 268)
|
||||||
gx1 = (felt_left + felt_right - grid_w) // 2
|
gx1 = (felt_left + felt_right - grid_w) // 2
|
||||||
gy1 = felt_top + max(0, (avail_h - grid_h) // 2)
|
gy1 = felt_top + max(0, (avail_h - grid_h) // 2)
|
||||||
gx2 = gx1 + grid_w
|
gx2, gy2 = gx1 + grid_w, gy1 + grid_h
|
||||||
gy2 = gy1 + grid_h
|
mid_x, mid_y = (gx1 + gx2) // 2, (gy1 + gy2) // 2
|
||||||
mid_x = (gx1 + gx2) // 2
|
|
||||||
mid_y = (gy1 + gy2) // 2
|
|
||||||
|
|
||||||
# Nur das freistehende Mittelkreuz direkt auf dem Tischfilz (kein Kasten in den Ecken!)
|
view.arena_canvas.create_line(mid_x, gy1 + 4, mid_x, gy2 - 4, fill=BORDER_COLOR, width=2, tags="fg")
|
||||||
view.arena_canvas.create_line(
|
view.arena_canvas.create_line(gx1 + 8, mid_y, gx2 - 8, mid_y, fill=BORDER_COLOR, width=2, tags="fg")
|
||||||
mid_x, gy1 + 4, mid_x, gy2 - 4,
|
|
||||||
fill=BORDER_COLOR,
|
|
||||||
width=2,
|
|
||||||
tags="fg",
|
|
||||||
)
|
|
||||||
view.arena_canvas.create_line(
|
|
||||||
gx1 + 12, mid_y, gx2 - 12, mid_y,
|
|
||||||
fill=BORDER_COLOR,
|
|
||||||
width=2,
|
|
||||||
tags="fg",
|
|
||||||
)
|
|
||||||
|
|
||||||
quad_w = grid_w // 2
|
quad_w = grid_w // 2
|
||||||
quad_h = grid_h // 2
|
quad_h = grid_h // 2
|
||||||
hdr_h = 24
|
hdr_h = 22 if compact else 24
|
||||||
pad_qx = 14
|
pad_qx = 8 if compact else 14
|
||||||
|
|
||||||
base_w, base_h = PLAYING_CARD_SIZE
|
base_w, base_h = PLAYING_CARD_SIZE
|
||||||
card_h = max(62, min(94, quad_h - hdr_h - 14))
|
card_h = max(56 if compact else 62, min(94, quad_h - hdr_h - 10))
|
||||||
card_w = max(43, int(round(base_w * (card_h / max(1, base_h)))))
|
card_w = max(39 if compact else 43, int(round(base_w * (card_h / max(1, base_h)))))
|
||||||
card_sz = (card_w, card_h)
|
card_sz = (card_w, card_h)
|
||||||
|
|
||||||
inner_cards_w = max(160, quad_w - 2 * pad_qx)
|
inner_cards_w = max(140, quad_w - 2 * pad_qx)
|
||||||
step_x = min(card_w + 3, max(19, (inner_cards_w - card_w) // 8))
|
step_x = min(card_w + 3, max(16 if compact else 19, (inner_cards_w - card_w) // 8))
|
||||||
span_cards_w = card_w + 8 * step_x
|
span_cards_w = card_w + 8 * step_x
|
||||||
|
|
||||||
last_card = view.engine.last_played_card
|
last_card = view.engine.last_played_card
|
||||||
|
|
||||||
for suit, r_idx, c_idx in ZR_GRID_SUITS:
|
for suit, r_idx, c_idx in ZR_GRID_SUITS:
|
||||||
|
|
@ -202,116 +177,70 @@ class ZehnerRausArenaRenderer:
|
||||||
bounds = view.engine.lanes[suit]
|
bounds = view.engine.lanes[suit]
|
||||||
is_done = bounds is not None and bounds[0] == 0 and bounds[1] == 8
|
is_done = bounds is not None and bounds[0] == 0 and bounds[1] == 8
|
||||||
|
|
||||||
# Untere Zeile bekommt minimal Abstand zur horizontalen Kreuzlinie
|
lbl_y = qy1 + (14 if r_idx == 1 else 10)
|
||||||
lbl_y = qy1 + (15 if r_idx == 1 else 11)
|
suit_lbl = f"{t(f'bav_suit_{suit}')} ✓" if is_done else t(f"bav_suit_{suit}")
|
||||||
suit_lbl = t(f"bav_suit_{suit}")
|
|
||||||
if is_done:
|
|
||||||
suit_lbl = f"{suit_lbl} ✓"
|
|
||||||
s_col = ACCENT_GOLD if is_done else FONT_COLOR_TITLE_MAIN
|
s_col = ACCENT_GOLD if is_done else FONT_COLOR_TITLE_MAIN
|
||||||
s_ph = view._make_goth_photo(suit_lbl, FONT_SIZE_SMALL_MIN, s_col, quad_w - 24)
|
s_ph = view._make_goth_photo(suit_lbl, FONT_SIZE_SMALL_MIN, s_col, quad_w - 16)
|
||||||
view._place_goth_photo_or_fallback(
|
view._place_goth_photo_or_fallback(q_cx, lbl_y, s_ph, suit_lbl, FONT_SIZE_SMALL_MIN, s_col)
|
||||||
q_cx, lbl_y, s_ph, suit_lbl, FONT_SIZE_SMALL_MIN, s_col
|
|
||||||
)
|
|
||||||
|
|
||||||
cards_x0 = q_cx - span_cards_w // 2
|
cards_x0 = q_cx - span_cards_w // 2
|
||||||
row_top = qy1 + hdr_h + max(3, (quad_h - hdr_h - card_h) // 2)
|
row_top = qy1 + hdr_h + max(2, (quad_h - hdr_h - card_h) // 2)
|
||||||
row_cy = row_top + card_h // 2
|
row_cy = row_top + card_h // 2
|
||||||
|
|
||||||
ten_x = cards_x0 + TEN_ORDER_INDEX * step_x
|
ten_x = cards_x0 + TEN_ORDER_INDEX * step_x
|
||||||
if bounds is None:
|
if bounds is None:
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
ten_x,
|
ten_x, row_top, ten_x + card_w, row_top + card_h,
|
||||||
row_top,
|
fill="", outline=SUBTLE_BORDER, width=2, tags="fg",
|
||||||
ten_x + card_w,
|
|
||||||
row_top + card_h,
|
|
||||||
fill="",
|
|
||||||
outline=SUBTLE_BORDER,
|
|
||||||
width=2,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
view.arena_canvas.create_text(
|
view.arena_canvas.create_text(
|
||||||
ten_x + card_w // 2,
|
ten_x + card_w // 2, row_cy, text="10",
|
||||||
row_cy,
|
font=("Georgia", max(10, card_w // 3), "bold"), fill=MUTED_FG, tags="fg",
|
||||||
text="10",
|
|
||||||
font=("Georgia", max(11, card_w // 3), "bold"),
|
|
||||||
fill=MUTED_FG,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
low_idx, high_idx = bounds
|
low_idx, high_idx = bounds
|
||||||
|
|
||||||
if low_idx > 0:
|
if low_idx > 0:
|
||||||
nx_low = cards_x0 + (low_idx - 1) * step_x
|
|
||||||
ZehnerRausArenaRenderer._draw_next_hint_slot(
|
ZehnerRausArenaRenderer._draw_next_hint_slot(
|
||||||
view, nx_low, row_top, card_w, card_h, BAVARIAN_RANKS[low_idx - 1]
|
view, cards_x0 + (low_idx - 1) * step_x, row_top, card_w, card_h, BAVARIAN_RANKS[low_idx - 1]
|
||||||
)
|
)
|
||||||
if high_idx < 8:
|
if high_idx < 8:
|
||||||
nx_high = cards_x0 + (high_idx + 1) * step_x
|
|
||||||
ZehnerRausArenaRenderer._draw_next_hint_slot(
|
ZehnerRausArenaRenderer._draw_next_hint_slot(
|
||||||
view, nx_high, row_top, card_w, card_h, BAVARIAN_RANKS[high_idx + 1]
|
view, cards_x0 + (high_idx + 1) * step_x, row_top, card_w, card_h, BAVARIAN_RANKS[high_idx + 1]
|
||||||
)
|
)
|
||||||
|
|
||||||
for r_i in range(low_idx, high_idx + 1):
|
for r_i in range(low_idx, high_idx + 1):
|
||||||
cx_card = cards_x0 + r_i * step_x
|
|
||||||
ZehnerRausArenaRenderer._draw_lane_card(
|
ZehnerRausArenaRenderer._draw_lane_card(
|
||||||
view,
|
view, BavarianCard(suit, BAVARIAN_RANKS[r_i]),
|
||||||
BavarianCard(suit, BAVARIAN_RANKS[r_i]),
|
cards_x0 + r_i * step_x, row_top, card_sz, last_card,
|
||||||
cx_card,
|
|
||||||
row_top,
|
|
||||||
card_sz,
|
|
||||||
last_card,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _draw_next_hint_slot(
|
def _draw_next_hint_slot(view, x: int, y: int, card_w: int, card_h: int, rank_txt: str) -> None:
|
||||||
view, x: int, y: int, card_w: int, card_h: int, rank_txt: str
|
|
||||||
) -> None:
|
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
x,
|
x, y, x + card_w, y + card_h,
|
||||||
y,
|
fill="#120e1b", outline="#2d2340", dash=(3, 3), width=1, tags="fg",
|
||||||
x + card_w,
|
|
||||||
y + card_h,
|
|
||||||
fill="#120e1b",
|
|
||||||
outline="#2d2340",
|
|
||||||
dash=(3, 3),
|
|
||||||
width=1,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
view.arena_canvas.create_text(
|
view.arena_canvas.create_text(
|
||||||
x + card_w // 2,
|
x + card_w // 2, y + card_h // 2, text=rank_txt,
|
||||||
y + card_h // 2,
|
font=("Georgia", max(9, card_w // 4)), fill="#5a4c73", tags="fg",
|
||||||
text=rank_txt,
|
|
||||||
font=("Georgia", max(10, card_w // 4)),
|
|
||||||
fill="#5a4c73",
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _draw_lane_card(
|
def _draw_lane_card(
|
||||||
view,
|
view, card: BavarianCard, x: int, y: int, card_sz: tuple[int, int], last_card: BavarianCard | None
|
||||||
card: BavarianCard,
|
|
||||||
x: int,
|
|
||||||
y: int,
|
|
||||||
card_sz: tuple[int, int],
|
|
||||||
last_card: BavarianCard | None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
cw, ch = card_sz
|
cw, ch = card_sz
|
||||||
if card.order_index == TEN_ORDER_INDEX:
|
if card.order_index == TEN_ORDER_INDEX:
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
x - 2, y - 2, x + cw + 2, y + ch + 2,
|
x - 2, y - 2, x + cw + 2, y + ch + 2, outline=ACCENT_GOTH, width=1, tags="fg"
|
||||||
outline=ACCENT_GOTH, width=1, tags="fg",
|
|
||||||
)
|
|
||||||
ph = view.ctx.assets.get_card_photo(
|
|
||||||
card.image_filename, size=card_sz, theme=BAVARIAN_CARD_THEME
|
|
||||||
)
|
)
|
||||||
|
ph = view.ctx.assets.get_card_photo(card.image_filename, size=card_sz, theme=BAVARIAN_CARD_THEME)
|
||||||
if ph is not None:
|
if ph is not None:
|
||||||
view._photo_refs.append(ph)
|
view._photo_refs.append(ph)
|
||||||
view.arena_canvas.create_image(x, y, image=ph, anchor="nw", tags="fg")
|
view.arena_canvas.create_image(x, y, image=ph, anchor="nw", tags="fg")
|
||||||
if last_card == card:
|
if last_card == card:
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
x - 2, y - 2, x + cw + 2, y + ch + 2,
|
x - 2, y - 2, x + cw + 2, y + ch + 2, outline=ACCENT_GOLD, width=2, tags="fg"
|
||||||
outline=ACCENT_GOLD, width=2, tags="fg",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -319,76 +248,63 @@ class ZehnerRausArenaRenderer:
|
||||||
view, cw: int, player_zone_top: int, player_zone_bot: int
|
view, cw: int, player_zone_top: int, player_zone_bot: int
|
||||||
) -> list[tuple[BavarianCard, int, int, int, int]]:
|
) -> list[tuple[BavarianCard, int, int, int, int]]:
|
||||||
human = view.engine.human_seat
|
human = view.engine.human_seat
|
||||||
eff_top = max(230, player_zone_top - ZR_HAND_TOP_EXTEND_PX)
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
avail_h = max(170, player_zone_bot - eff_top)
|
ext = 10 if compact else ZR_HAND_TOP_EXTEND_PX
|
||||||
|
eff_top = max(210, player_zone_top - ext)
|
||||||
|
avail_h = max(148 if compact else 170, player_zone_bot - eff_top)
|
||||||
zone_cy = (eff_top + player_zone_bot) // 2
|
zone_cy = (eff_top + player_zone_bot) // 2
|
||||||
|
|
||||||
base_w, base_h = PLAYING_CARD_SIZE
|
base_w, base_h = PLAYING_CARD_SIZE
|
||||||
target_h = max(118, min(ZR_MAX_HAND_CARD_H, avail_h - 42))
|
target_h = max(106 if compact else 118, min(ZR_MAX_HAND_CARD_H, avail_h - 40))
|
||||||
scale = target_h / max(1, base_h)
|
scale = target_h / max(1, base_h)
|
||||||
card_w = max(80, int(round(base_w * scale)))
|
card_w = max(72 if compact else 80, int(round(base_w * scale)))
|
||||||
card_h = int(round(base_h * scale))
|
card_h = int(round(base_h * scale))
|
||||||
card_sz = (card_w, card_h)
|
card_sz = (card_w, card_h)
|
||||||
|
|
||||||
is_my_turn = not view.engine.is_finished and view.engine.turn_seat == 0
|
is_my_turn = not view.engine.is_finished and view.engine.turn_seat == 0
|
||||||
playable_set = (
|
playable_set = set(view.engine.get_playable_cards(0)) if is_my_turn else set()
|
||||||
set(view.engine.get_playable_cards(0)) if is_my_turn else set()
|
|
||||||
)
|
|
||||||
|
|
||||||
n_cards = len(human.hand)
|
n_cards = len(human.hand)
|
||||||
max_hand_w = max(380, cw - 180)
|
max_hand_w = max(300, cw - (56 if compact else 180))
|
||||||
step = min(card_w + 10, max(44, (max_hand_w - card_w) // max(1, n_cards - 1)))
|
step = min(card_w + 8, max(32 if compact else 44, (max_hand_w - card_w) // max(1, n_cards - 1)))
|
||||||
span_w = card_w + max(0, n_cards - 1) * step if n_cards else card_w
|
span_w = card_w + max(0, n_cards - 1) * step if n_cards else card_w
|
||||||
|
|
||||||
lbl_txt = t("zr_player_hand_lbl", n_cards)
|
lbl_txt = t("zr_player_hand_lbl", n_cards)
|
||||||
lbl_sz = max(13, FONT_SIZE_BODY - 2)
|
lbl_sz = max(12 if compact else 13, FONT_SIZE_BODY - 2)
|
||||||
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, FONT_COLOR_TITLE_MAIN)
|
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, FONT_COLOR_TITLE_MAIN)
|
||||||
txt_w = lbl_ph.width() if lbl_ph is not None else 280
|
txt_w = lbl_ph.width() if lbl_ph is not None else 240
|
||||||
|
|
||||||
box_w = max(380, min(cw - 72, max(span_w + 76, txt_w + 68)))
|
box_w = max(300, min(cw - (18 if compact else 72), max(span_w + 48, txt_w + 48)))
|
||||||
box_h = min(avail_h + 6, card_h + 44)
|
box_h = min(avail_h + 6, card_h + 42)
|
||||||
box_cx = cw // 2
|
box_cx = cw // 2
|
||||||
|
|
||||||
view._draw_framed_panel(
|
view._draw_framed_panel(
|
||||||
box_cx,
|
box_cx, zone_cy, box_w, box_h, frame_style="gold" if is_my_turn else "purple"
|
||||||
zone_cy,
|
|
||||||
box_w,
|
|
||||||
box_h,
|
|
||||||
frame_style="gold" if is_my_turn else "purple",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
hit_rects: list[tuple[BavarianCard, int, int, int, int]] = []
|
hit_rects: list[tuple[BavarianCard, int, int, int, int]] = []
|
||||||
start_x = box_cx - span_w // 2
|
start_x = box_cx - span_w // 2
|
||||||
base_top = (zone_cy - 10) - card_h // 2
|
base_top = (zone_cy - 9) - card_h // 2
|
||||||
|
|
||||||
for idx, card in enumerate(human.hand):
|
for idx, card in enumerate(human.hand):
|
||||||
is_playable = card in playable_set
|
is_playable = card in playable_set
|
||||||
cx_left = start_x + idx * step
|
cx_left = start_x + idx * step
|
||||||
cy_top = base_top - (10 if is_playable else 0)
|
cy_top = base_top - (9 if is_playable else 0)
|
||||||
|
|
||||||
ph = view.ctx.assets.get_card_photo(
|
ph = view.ctx.assets.get_card_photo(card.image_filename, size=card_sz, theme=BAVARIAN_CARD_THEME)
|
||||||
card.image_filename, size=card_sz, theme=BAVARIAN_CARD_THEME
|
|
||||||
)
|
|
||||||
if ph is not None:
|
if ph is not None:
|
||||||
view._photo_refs.append(ph)
|
view._photo_refs.append(ph)
|
||||||
view.arena_canvas.create_image(
|
view.arena_canvas.create_image(cx_left, cy_top, image=ph, anchor="nw", tags="fg")
|
||||||
cx_left, cy_top, image=ph, anchor="nw", tags="fg"
|
|
||||||
)
|
|
||||||
if is_playable:
|
if is_playable:
|
||||||
view.arena_canvas.create_rectangle(
|
view.arena_canvas.create_rectangle(
|
||||||
cx_left - 2,
|
cx_left - 2, cy_top - 2, cx_left + card_w + 2, cy_top + card_h + 2,
|
||||||
cy_top - 2,
|
outline=ACCENT_GOLD, width=2, tags="fg",
|
||||||
cx_left + card_w + 2,
|
|
||||||
cy_top + card_h + 2,
|
|
||||||
outline=ACCENT_GOLD,
|
|
||||||
width=2,
|
|
||||||
tags="fg",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
hit_right = (cx_left + card_w) if idx == n_cards - 1 else (cx_left + step)
|
hit_right = (cx_left + card_w) if idx == n_cards - 1 else (cx_left + step)
|
||||||
hit_rects.append((card, cx_left, cy_top, hit_right, cy_top + card_h))
|
hit_rects.append((card, cx_left, cy_top, hit_right, cy_top + card_h))
|
||||||
|
|
||||||
view._place_goth_photo_or_fallback(
|
view._place_goth_photo_or_fallback(
|
||||||
box_cx, zone_cy + box_h // 2 - 15, lbl_ph, lbl_txt, lbl_sz, FONT_COLOR_TITLE_MAIN
|
box_cx, zone_cy + box_h // 2 - 14, lbl_ph, lbl_txt, lbl_sz, FONT_COLOR_TITLE_MAIN
|
||||||
)
|
)
|
||||||
return hit_rects
|
return hit_rects
|
||||||
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
from games.party.zehner_raus.views.zehner_raus_table_view import ZehnerRausTableView
|
from games.party.zehner_raus.views.zehner_raus_table_view import ZehnerRausTableView
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
BOT_LEVEL_COUNT,
|
BOT_LEVEL_COUNT,
|
||||||
FONT_COLOR_BODY_DEFAULT,
|
FONT_COLOR_BODY_DEFAULT,
|
||||||
|
|
@ -19,17 +19,18 @@ from resources.code_res.game_constants import (
|
||||||
ZR_BOT_COUNT,
|
ZR_BOT_COUNT,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.goth_dropdown import GothDropdown
|
from view.layout_mode import LayoutMode
|
||||||
from view.widgets.goth_entry import GothEntry
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.dropdown.goth_dropdown import GothDropdown
|
||||||
from view.widgets.menu_body_canvas import MenuBodyCanvas
|
from view.widgets.inputs.goth_entry import GothEntry
|
||||||
|
from view.widgets.shared_bases.menu_body_canvas import MenuBodyCanvas
|
||||||
|
|
||||||
GAME_FOLDER_ID = "party/zehner_raus"
|
GAME_FOLDER_ID = "party/zehner_raus"
|
||||||
GAME_TITLE_KEY = "game_title_zehner_raus"
|
GAME_TITLE_KEY = "game_title_zehner_raus"
|
||||||
|
|
||||||
|
|
||||||
class ZehnerRausMenuView:
|
class ZehnerRausMenuView:
|
||||||
"""Vorauswahl-Menü für 10er raus mit 3 festen Pflicht-Mitspielern (ohne Goldbeutel)."""
|
"""Vorauswahl-Menü für 10er raus mit 3 festen Pflicht-Mitspielern (Desktop & Kompakt/Mobile)."""
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.ctx = context
|
self.ctx = context
|
||||||
|
|
@ -107,7 +108,7 @@ class ZehnerRausMenuView:
|
||||||
entry = GothEntry(
|
entry = GothEntry(
|
||||||
cv,
|
cv,
|
||||||
self.ctx.assets,
|
self.ctx.assets,
|
||||||
width=240,
|
width=200,
|
||||||
height=36,
|
height=36,
|
||||||
textvariable=tk.StringVar(value=b_name),
|
textvariable=tk.StringVar(value=b_name),
|
||||||
)
|
)
|
||||||
|
|
@ -118,28 +119,24 @@ class ZehnerRausMenuView:
|
||||||
values=ai_labels,
|
values=ai_labels,
|
||||||
textvariable=l_var,
|
textvariable=l_var,
|
||||||
sound_mgr=self.ctx.sounds,
|
sound_mgr=self.ctx.sounds,
|
||||||
width=270,
|
width=230,
|
||||||
height=36,
|
height=36,
|
||||||
)
|
)
|
||||||
self._bot_entries.append(entry)
|
self._bot_entries.append(entry)
|
||||||
self._bot_lvl_vars.append(l_var)
|
self._bot_lvl_vars.append(l_var)
|
||||||
self._bot_dds.append(dd)
|
self._bot_dds.append(dd)
|
||||||
|
|
||||||
def start_round():
|
|
||||||
bots = self._collect_and_save_bots()
|
|
||||||
ZehnerRausTableView(
|
|
||||||
self.ctx,
|
|
||||||
variant_key="zehner_raus_std",
|
|
||||||
bot_configs=bots,
|
|
||||||
on_back_to_menu=self.show,
|
|
||||||
)
|
|
||||||
|
|
||||||
start_btn = ImageButton(
|
start_btn = ImageButton(
|
||||||
cv,
|
cv,
|
||||||
t("zr_start_btn"),
|
t("zr_start_btn"),
|
||||||
btn_fire,
|
btn_fire,
|
||||||
btn_fire,
|
btn_fire,
|
||||||
start_round,
|
lambda: ZehnerRausTableView(
|
||||||
|
self.ctx,
|
||||||
|
variant_key="zehner_raus_std",
|
||||||
|
bot_configs=self._collect_and_save_bots(),
|
||||||
|
on_back_to_menu=self.show,
|
||||||
|
),
|
||||||
sound_mgr=self.ctx.sounds,
|
sound_mgr=self.ctx.sounds,
|
||||||
width=210,
|
width=210,
|
||||||
height=40,
|
height=40,
|
||||||
|
|
@ -151,13 +148,20 @@ class ZehnerRausMenuView:
|
||||||
cv.delete("fg")
|
cv.delete("fg")
|
||||||
self._photo_refs.clear()
|
self._photo_refs.clear()
|
||||||
|
|
||||||
box_w = min(940, w - 120)
|
rw, rh = self.ctx.root.winfo_width(), self.ctx.root.winfo_height()
|
||||||
|
is_mobile = LayoutMode.is_compact(rw, rh) or (w < 780)
|
||||||
|
pad_x = LayoutMode.outer_pad_x(w, h, desktop_ratio=0.075, desktop_min=64)
|
||||||
|
|
||||||
|
box_w = min(940, w - 2 * pad_x)
|
||||||
cx = w // 2
|
cx = w // 2
|
||||||
x_left = cx - box_w // 2
|
x_left = cx - box_w // 2
|
||||||
cur_y = max(22, int(h * 0.05))
|
cur_y = 12 if is_mobile else max(22, int(h * 0.05))
|
||||||
|
|
||||||
title_ph = self.ctx.assets.get_goth_text_photo(
|
title_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t(GAME_TITLE_KEY), FONT_SIZE_TITLE_LG, FONT_COLOR_TITLE_MAIN, align="left"
|
t(GAME_TITLE_KEY),
|
||||||
|
FONT_SIZE_TITLE_LG - (4 if is_mobile else 0),
|
||||||
|
FONT_COLOR_TITLE_MAIN,
|
||||||
|
align="left",
|
||||||
)
|
)
|
||||||
sub_ph = self.ctx.assets.get_goth_text_photo(
|
sub_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("zr_menu_subtitle"),
|
t("zr_menu_subtitle"),
|
||||||
|
|
@ -170,40 +174,86 @@ class ZehnerRausMenuView:
|
||||||
cv.create_image(x_left, cur_y, image=title_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left, cur_y, image=title_ph, anchor="nw", tags="fg")
|
||||||
cur_y += title_ph.height() + 4
|
cur_y += title_ph.height() + 4
|
||||||
cv.create_image(x_left, cur_y, image=sub_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left, cur_y, image=sub_ph, anchor="nw", tags="fg")
|
||||||
cur_y += sub_ph.height() + 18
|
cur_y += sub_ph.height() + (14 if is_mobile else 18)
|
||||||
|
|
||||||
|
# 1. Spielmodus & Regeln
|
||||||
s1_ph = self.ctx.assets.get_goth_text_photo(
|
s1_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("zr_rules_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
t("zr_rules_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
||||||
)
|
)
|
||||||
self._photo_refs.append(s1_ph)
|
self._photo_refs.append(s1_ph)
|
||||||
cv.create_image(x_left + 6, cur_y, image=s1_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left + 4, cur_y, image=s1_ph, anchor="nw", tags="fg")
|
||||||
cur_y += s1_ph.height() + 6
|
cur_y += s1_ph.height() + 6
|
||||||
|
|
||||||
r_box_h = 74
|
v_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
|
t("variant_zehner_raus_std"), FONT_SIZE_HEADING - 3, FONT_COLOR_TITLE_MAIN, align="left"
|
||||||
|
)
|
||||||
|
d_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
|
t("zr_rule_summary"),
|
||||||
|
FONT_SIZE_SMALL_MIN,
|
||||||
|
FONT_COLOR_BODY_DEFAULT,
|
||||||
|
max_width=box_w - 48,
|
||||||
|
align="left",
|
||||||
|
)
|
||||||
|
self._photo_refs.extend([v_ph, d_ph])
|
||||||
|
|
||||||
|
r_box_h = max(74, 34 + d_ph.height() + 18)
|
||||||
r_cy = cur_y + r_box_h // 2
|
r_cy = cur_y + r_box_h // 2
|
||||||
r_box = self.ctx.assets.get_box_photo("box_gold_double", (box_w, r_box_h))
|
r_box = self.ctx.assets.get_box_photo("box_gold_double", (box_w, r_box_h))
|
||||||
if r_box:
|
if r_box:
|
||||||
self._photo_refs.append(r_box)
|
self._photo_refs.append(r_box)
|
||||||
cv.create_image(cx, r_cy, image=r_box, anchor="center", tags="fg")
|
cv.create_image(cx, r_cy, image=r_box, anchor="center", tags="fg")
|
||||||
|
|
||||||
v_ph = self.ctx.assets.get_goth_text_photo(
|
cv.create_image(x_left + 24, cur_y + 22, image=v_ph, anchor="w", tags="fg")
|
||||||
t("variant_zehner_raus_std"), FONT_SIZE_HEADING - 3, FONT_COLOR_TITLE_MAIN, align="left"
|
cv.create_image(x_left + 24, cur_y + 42, image=d_ph, anchor="nw", tags="fg")
|
||||||
)
|
cur_y += r_box_h + (14 if is_mobile else 18)
|
||||||
d_ph = self.ctx.assets.get_goth_text_photo(
|
|
||||||
t("zr_rule_summary"), FONT_SIZE_SMALL_MIN, FONT_COLOR_BODY_DEFAULT, max_width=box_w - 56, align="left"
|
|
||||||
)
|
|
||||||
self._photo_refs.extend([v_ph, d_ph])
|
|
||||||
cv.create_image(x_left + 28, r_cy - 14, image=v_ph, anchor="w", tags="fg")
|
|
||||||
cv.create_image(x_left + 28, r_cy + 15, image=d_ph, anchor="w", tags="fg")
|
|
||||||
cur_y += r_box_h + 18
|
|
||||||
|
|
||||||
|
# 2. 3 Pflicht-Mitspieler konfigurieren
|
||||||
s2_ph = self.ctx.assets.get_goth_text_photo(
|
s2_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("zr_bots_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
t("zr_bots_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB, align="left"
|
||||||
)
|
)
|
||||||
self._photo_refs.append(s2_ph)
|
self._photo_refs.append(s2_ph)
|
||||||
cv.create_image(x_left + 6, cur_y, image=s2_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left + 4, cur_y, image=s2_ph, anchor="nw", tags="fg")
|
||||||
cur_y += s2_ph.height() + 6
|
cur_y += s2_ph.height() + 6
|
||||||
|
|
||||||
|
if is_mobile:
|
||||||
|
b_box_h = 286
|
||||||
|
b_cy = cur_y + b_box_h // 2
|
||||||
|
b_box = self.ctx.assets.get_box_photo("box_big", (box_w, b_box_h))
|
||||||
|
if b_box:
|
||||||
|
self._photo_refs.append(b_box)
|
||||||
|
cv.create_image(cx, b_cy, image=b_box, anchor="center", tags="fg")
|
||||||
|
|
||||||
|
in_w = box_w - 44
|
||||||
|
ent_w = max(140, int(in_w * 0.44))
|
||||||
|
dd_w = max(150, in_w - ent_w - 10)
|
||||||
|
for idx in range(ZR_BOT_COUNT):
|
||||||
|
ry = cur_y + 26 + idx * 72
|
||||||
|
seat_lbl = self.ctx.assets.get_goth_text_photo(
|
||||||
|
t("zr_seat_lbl", idx + 2),
|
||||||
|
FONT_SIZE_SMALL_MIN + 1,
|
||||||
|
FONT_COLOR_HEADING_SUB,
|
||||||
|
align="left",
|
||||||
|
)
|
||||||
|
self._photo_refs.append(seat_lbl)
|
||||||
|
cv.create_image(x_left + 22, ry, image=seat_lbl, anchor="w", tags="fg")
|
||||||
|
|
||||||
|
ent = self._bot_entries[idx]
|
||||||
|
if hasattr(ent, "resize") and ent._width != ent_w:
|
||||||
|
ent.resize(ent_w)
|
||||||
|
cv.create_window(x_left + 22, ry + 30, window=ent, anchor="w", tags="fg")
|
||||||
|
|
||||||
|
dd = self._bot_dds[idx]
|
||||||
|
if dd._width != dd_w:
|
||||||
|
dd._width = dd_w
|
||||||
|
dd.configure(width=dd_w)
|
||||||
|
dd._render_closed()
|
||||||
|
cv.create_window(x_left + box_w - 22, ry + 30, window=dd, anchor="e", tags="fg")
|
||||||
|
|
||||||
|
cv.create_window(
|
||||||
|
x_left + box_w - 24, cur_y + b_box_h - 32, window=start_btn, anchor="e", tags="fg"
|
||||||
|
)
|
||||||
|
cv.set_scrollable_height(cur_y + b_box_h + 20, h)
|
||||||
|
else:
|
||||||
b_box_h = 236
|
b_box_h = 236
|
||||||
b_cy = cur_y + b_box_h // 2
|
b_cy = cur_y + b_box_h // 2
|
||||||
b_box = self.ctx.assets.get_box_photo("box_big", (box_w, b_box_h))
|
b_box = self.ctx.assets.get_box_photo("box_big", (box_w, b_box_h))
|
||||||
|
|
@ -211,7 +261,8 @@ class ZehnerRausMenuView:
|
||||||
self._photo_refs.append(b_box)
|
self._photo_refs.append(b_box)
|
||||||
cv.create_image(cx, b_cy, image=b_box, anchor="center", tags="fg")
|
cv.create_image(cx, b_cy, image=b_box, anchor="center", tags="fg")
|
||||||
|
|
||||||
dd_w = max(220, box_w - 430)
|
ent_w = 230
|
||||||
|
dd_w = max(210, box_w - 426)
|
||||||
for idx in range(ZR_BOT_COUNT):
|
for idx in range(ZR_BOT_COUNT):
|
||||||
ry = cur_y + 38 + idx * 50
|
ry = cur_y + 38 + idx * 50
|
||||||
seat_lbl = self.ctx.assets.get_goth_text_photo(
|
seat_lbl = self.ctx.assets.get_goth_text_photo(
|
||||||
|
|
@ -219,19 +270,24 @@ class ZehnerRausMenuView:
|
||||||
)
|
)
|
||||||
self._photo_refs.append(seat_lbl)
|
self._photo_refs.append(seat_lbl)
|
||||||
cv.create_image(x_left + 32, ry, image=seat_lbl, anchor="w", tags="fg")
|
cv.create_image(x_left + 32, ry, image=seat_lbl, anchor="w", tags="fg")
|
||||||
cv.create_window(x_left + 130, ry, window=self._bot_entries[idx], anchor="w", tags="fg")
|
|
||||||
|
ent = self._bot_entries[idx]
|
||||||
|
if hasattr(ent, "resize") and ent._width != ent_w:
|
||||||
|
ent.resize(ent_w)
|
||||||
|
cv.create_window(x_left + 130, ry, window=ent, anchor="w", tags="fg")
|
||||||
|
|
||||||
dd = self._bot_dds[idx]
|
dd = self._bot_dds[idx]
|
||||||
if dd._width != dd_w:
|
if dd._width != dd_w:
|
||||||
dd._width = dd_w
|
dd._width = dd_w
|
||||||
dd.configure(width=dd_w)
|
dd.configure(width=dd_w)
|
||||||
dd._render_closed()
|
dd._render_closed()
|
||||||
cv.create_window(x_left + 390, ry, window=dd, anchor="w", tags="fg")
|
cv.create_window(x_left + 382, ry, window=dd, anchor="w", tags="fg")
|
||||||
|
|
||||||
cv.create_window(
|
cv.create_window(
|
||||||
x_left + box_w - 32, cur_y + b_box_h - 36, window=start_btn, anchor="e", tags="fg"
|
x_left + box_w - 32, cur_y + b_box_h - 36, window=start_btn, anchor="e", tags="fg"
|
||||||
)
|
)
|
||||||
|
cv.set_scrollable_height(cur_y + b_box_h + 20, h)
|
||||||
|
|
||||||
cv.bind("<Configure>", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None)
|
cv.bind("<Configure>", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None)
|
||||||
self.ctx.root.update_idletasks()
|
self.ctx.root.update_idletasks()
|
||||||
draw_layout(max(900, cv.winfo_width()), max(620, cv.winfo_height()))
|
draw_layout(max(460, cv.winfo_width()), max(560, cv.winfo_height()))
|
||||||
|
|
@ -15,8 +15,8 @@ from resources.code_res.game_constants import (
|
||||||
SUBTLE_BORDER,
|
SUBTLE_BORDER,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_result_dialog_base import CasinoResultDialogBase
|
from view.widgets.shared_bases.casino_result_dialog_base import CasinoResultDialogBase
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
MINI_BAV_CARD_SIZE = (40, 58)
|
MINI_BAV_CARD_SIZE = (40, 58)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ from games.party.zehner_raus.views.zehner_raus_arena_renderer import (
|
||||||
from games.party.zehner_raus.views.zehner_raus_result_dialog import (
|
from games.party.zehner_raus.views.zehner_raus_result_dialog import (
|
||||||
ZehnerRausResultDialog,
|
ZehnerRausResultDialog,
|
||||||
)
|
)
|
||||||
from models.bavarian_deck import BavarianCard
|
from models.cards.bavarian_deck import BavarianCard
|
||||||
from models.progression import Progression
|
from models.progression import Progression
|
||||||
from resources.code_res.game_constants import ZR_BOT_TURN_DELAY_MS, ZR_VARIANTS
|
from resources.code_res.game_constants import ZR_BOT_TURN_DELAY_MS, ZR_VARIANTS
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_arena_base import CasinoArenaBase
|
from view.widgets.shared_bases.casino_arena_base import CasinoArenaBase
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
GAME_FOLDER_ID = "party/zehner_raus"
|
GAME_FOLDER_ID = "party/zehner_raus"
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -3,7 +3,7 @@
|
||||||
import random
|
import random
|
||||||
from games.poker.models.poker_evaluator import PokerEvaluator
|
from games.poker.models.poker_evaluator import PokerEvaluator
|
||||||
from games.poker.models.poker_seat import PokerSeat
|
from games.poker.models.poker_seat import PokerSeat
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from resources.code_res.game_constants import BOT_DEITY_LEVEL, PK_STARTING_GOLD, RANKS, SUITS
|
from resources.code_res.game_constants import BOT_DEITY_LEVEL, PK_STARTING_GOLD, RANKS, SUITS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
# games/poker/models/poker_engine.py
|
# games/poker/models/poker_engine.py
|
||||||
from games.poker.models.poker_evaluator import PokerEvaluator
|
from games.poker.models.poker_evaluator import PokerEvaluator
|
||||||
from games.poker.models.poker_seat import PokerSeat
|
from games.poker.models.poker_seat import PokerSeat
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from models.deck import Deck
|
from models.cards.deck import Deck
|
||||||
|
|
||||||
|
|
||||||
class PokerEngine:
|
class PokerEngine:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/poker/models/poker_evaluator.py
|
# games/poker/models/poker_evaluator.py
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from itertools import combinations
|
from itertools import combinations
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
|
|
||||||
RANK_VAL = {
|
RANK_VAL = {
|
||||||
"2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8,
|
"2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/poker/models/poker_seat.py
|
# games/poker/models/poker_seat.py
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/poker/start.py
|
# games/poker/start.py
|
||||||
from games.poker.views.poker_menu_view import PokerMenuView
|
from games.poker.views.poker_menu_view import PokerMenuView
|
||||||
from games.poker.views.poker_table_view import PokerTableView
|
from games.poker.views.poker_table_view import PokerTableView
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import CAT_LUCK, PK_MAX_BOTS
|
from resources.code_res.game_constants import CAT_LUCK, PK_MAX_BOTS
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -4,6 +4,9 @@ from __future__ import annotations
|
||||||
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
|
from games.poker.models.poker_evaluator import PokerEvaluator
|
||||||
|
from models.db.database import Database
|
||||||
|
from models.progression import Progression
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACCENT_GOLD,
|
ACCENT_GOLD,
|
||||||
ACCENT_GOTH,
|
ACCENT_GOTH,
|
||||||
|
|
@ -11,14 +14,12 @@ from resources.code_res.game_constants import (
|
||||||
FG_COLOR,
|
FG_COLOR,
|
||||||
FONT_COLOR_TITLE_MAIN,
|
FONT_COLOR_TITLE_MAIN,
|
||||||
FONT_SIZE_BODY,
|
FONT_SIZE_BODY,
|
||||||
|
FONT_SIZE_SMALL_MIN,
|
||||||
MUTED_FG,
|
MUTED_FG,
|
||||||
PLAYING_CARD_SIZE,
|
PLAYING_CARD_SIZE,
|
||||||
SUBTLE_BORDER,
|
SUBTLE_BORDER,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from games.poker.models.poker_evaluator import PokerEvaluator
|
|
||||||
from models.database import Database
|
|
||||||
from models.progression import Progression
|
|
||||||
|
|
||||||
PK_OVAL_BOARD_CARD = (78, 114)
|
PK_OVAL_BOARD_CARD = (78, 114)
|
||||||
PK_BOT_SHOWDOWN_CARD = (42, 62)
|
PK_BOT_SHOWDOWN_CARD = (42, 62)
|
||||||
|
|
@ -33,7 +34,7 @@ SEAT_LAYOUT_BY_COUNT = {
|
||||||
|
|
||||||
|
|
||||||
class PokerArenaRenderer:
|
class PokerArenaRenderer:
|
||||||
"""Zeichnet die 6-Max-Tischszene für Texas Hold'em auf das Arena-Canvas."""
|
"""Zeichnet die 6-Max-Tischszene für Texas Hold'em (Desktop-Oval vs. tischlose Kompakt-Ansicht)."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def role_badge(eng, seat_idx: int) -> str:
|
def role_badge(eng, seat_idx: int) -> str:
|
||||||
|
|
@ -59,7 +60,10 @@ class PokerArenaRenderer:
|
||||||
) -> int:
|
) -> int:
|
||||||
bot_seats = view.engine.seats[1:]
|
bot_seats = view.engine.seats[1:]
|
||||||
if not bot_seats:
|
if not bot_seats:
|
||||||
return table_rect[1] + 24
|
return table_rect[1] + 12
|
||||||
|
|
||||||
|
if getattr(view, "is_compact_arena", False):
|
||||||
|
return cls._draw_bots_top_grid(view, bot_seats, cw, pad_x, pad_top)
|
||||||
|
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
is_showdown = (view.engine.street == "SHOWDOWN")
|
is_showdown = (view.engine.street == "SHOWDOWN")
|
||||||
|
|
@ -114,26 +118,89 @@ class PokerArenaRenderer:
|
||||||
by = top_cy if coord_idx == 3 else bot_cy
|
by = top_cy if coord_idx == 3 else bot_cy
|
||||||
|
|
||||||
view._draw_framed_panel(bx, by, box_w, box_h, frame_style=frame_style, status_border=status_border)
|
view._draw_framed_panel(bx, by, box_w, box_h, frame_style=frame_style, status_border=status_border)
|
||||||
|
cls._draw_bot_box_contents(
|
||||||
|
view, seat, bx, by, box_w, show_bot_cards, PK_BOT_SHOWDOWN_CARD,
|
||||||
|
title_ph, title_txt, title_col, stack_ph, stack_txt, st_ph, st_txt, st_col, name_sz, sub_sz,
|
||||||
|
)
|
||||||
|
|
||||||
if show_bot_cards:
|
return top_center_bottom
|
||||||
c_w, c_h = PK_BOT_SHOWDOWN_CARD
|
|
||||||
step_x = 22
|
@classmethod
|
||||||
fan_left, fan_top = bx - box_w // 2 + 16, by - c_h // 2
|
def _draw_bots_top_grid(cls, view, bot_seats: list, cw: int, pad_x: int, pad_top: int) -> int:
|
||||||
|
"""Zeichnet 1..5 Poker-Bots im Kompaktmodus oben nebeneinander (max. 3 pro Reihe)."""
|
||||||
|
is_showdown = (view.engine.street == "SHOWDOWN")
|
||||||
|
n = len(bot_seats)
|
||||||
|
cols = min(3, n)
|
||||||
|
rows = (n + cols - 1) // cols
|
||||||
|
gap_x, gap_y = 6, 6
|
||||||
|
|
||||||
|
avail_w = max(320, cw - 2 * pad_x)
|
||||||
|
box_w = min(214, (avail_w - (cols - 1) * gap_x) // max(1, cols))
|
||||||
|
box_h = 74 if rows == 2 else 82
|
||||||
|
|
||||||
|
mini_card = (34, 50)
|
||||||
|
name_sz = max(12, FONT_SIZE_SMALL_MIN)
|
||||||
|
sub_sz = max(11, FONT_SIZE_SMALL_MIN - 1)
|
||||||
|
|
||||||
|
bottom_edge = pad_top
|
||||||
|
for idx, seat in enumerate(bot_seats):
|
||||||
|
r, c = divmod(idx, cols)
|
||||||
|
in_row = min(cols, n - r * cols)
|
||||||
|
row_start_x = (cw - (in_row * box_w + (in_row - 1) * gap_x)) // 2 + box_w // 2
|
||||||
|
bx = row_start_x + c * (box_w + gap_x)
|
||||||
|
by = pad_top + r * (box_h + gap_y) + box_h // 2
|
||||||
|
bottom_edge = max(bottom_edge, by + box_h // 2)
|
||||||
|
|
||||||
|
is_turn = (not is_showdown and view.engine.turn_pos == seat.seat_id)
|
||||||
|
show_bot_cards = is_showdown and bool(seat.hole_cards) and (not seat.folded)
|
||||||
|
status_border = ERROR_FG if seat.folded else (ACCENT_GOTH if seat.all_in else None)
|
||||||
|
|
||||||
|
base_name = t("bj_bot_rebuy", seat.name) if seat.rebought else seat.name
|
||||||
|
title_txt = f"{base_name}{cls.role_badge(view.engine, seat.seat_id)}"
|
||||||
|
title_col = MUTED_FG if seat.folded else (ACCENT_GOLD if is_turn else ACCENT_GOTH)
|
||||||
|
stack_txt = t("pk_bot_stack_lbl", seat.stack, seat.street_bet)
|
||||||
|
st_txt = seat.status_text or "-"
|
||||||
|
st_col = ERROR_FG if seat.folded else (ACCENT_GOLD if is_turn else FG_COLOR)
|
||||||
|
|
||||||
|
max_tw = max(72, box_w - (68 if show_bot_cards else 18))
|
||||||
|
title_ph = view._make_goth_photo(title_txt, name_sz, title_col, max_tw)
|
||||||
|
stack_ph = view._make_goth_photo(stack_txt, sub_sz, ACCENT_GOLD, max_tw)
|
||||||
|
st_ph = view._make_goth_photo(st_txt, sub_sz, st_col, max_tw)
|
||||||
|
|
||||||
|
view._draw_framed_panel(
|
||||||
|
bx, by, box_w, box_h,
|
||||||
|
frame_style="gold" if is_turn else "purple",
|
||||||
|
status_border=status_border,
|
||||||
|
)
|
||||||
|
cls._draw_bot_box_contents(
|
||||||
|
view, seat, bx, by, box_w, show_bot_cards, mini_card,
|
||||||
|
title_ph, title_txt, title_col, stack_ph, stack_txt, st_ph, st_txt, st_col,
|
||||||
|
name_sz, sub_sz, dy=20 if rows == 2 else 22,
|
||||||
|
)
|
||||||
|
|
||||||
|
return bottom_edge
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _draw_bot_box_contents(
|
||||||
|
view, seat, bx: int, by: int, box_w: int, show_cards: bool, card_sz: tuple[int, int],
|
||||||
|
title_ph, title_txt: str, title_col: str, stack_ph, stack_txt: str,
|
||||||
|
st_ph, st_txt: str, st_col: str, name_sz: int, sub_sz: int, dy: int = 23,
|
||||||
|
) -> None:
|
||||||
|
if show_cards:
|
||||||
|
c_w, c_h = card_sz
|
||||||
|
step_x = max(16, c_w // 2)
|
||||||
|
fan_left, fan_top = bx - box_w // 2 + 10, by - c_h // 2
|
||||||
for ci, c_obj in enumerate(seat.hole_cards[:2]):
|
for ci, c_obj in enumerate(seat.hole_cards[:2]):
|
||||||
c_ph = view.ctx.assets.get_card_photo(c_obj.image_filename, size=PK_BOT_SHOWDOWN_CARD)
|
c_ph = view.ctx.assets.get_card_photo(c_obj.image_filename, size=card_sz)
|
||||||
if c_ph is not None:
|
if c_ph is not None:
|
||||||
view._photo_refs.append(c_ph)
|
view._photo_refs.append(c_ph)
|
||||||
view.arena_canvas.create_image(fan_left + ci * step_x, fan_top, image=c_ph, anchor="nw", tags="fg")
|
view.arena_canvas.create_image(fan_left + ci * step_x, fan_top, image=c_ph, anchor="nw", tags="fg")
|
||||||
txt_cx = bx + (c_w + step_x) // 2 + 4
|
txt_cx = bx + (c_w + step_x) // 2 + 2
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by - 24, title_ph, title_txt, name_sz, title_col)
|
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by, stack_ph, stack_txt, sub_sz, ACCENT_GOLD)
|
|
||||||
view._place_goth_photo_or_fallback(txt_cx, by + 24, st_ph, st_txt, sub_sz, st_col)
|
|
||||||
else:
|
else:
|
||||||
view._place_goth_photo_or_fallback(bx, by - 23, title_ph, title_txt, name_sz, title_col)
|
txt_cx = bx
|
||||||
view._place_goth_photo_or_fallback(bx, by, stack_ph, stack_txt, sub_sz, ACCENT_GOLD)
|
view._place_goth_photo_or_fallback(txt_cx, by - dy, title_ph, title_txt, name_sz, title_col)
|
||||||
view._place_goth_photo_or_fallback(bx, by + 23, st_ph, st_txt, sub_sz, st_col)
|
view._place_goth_photo_or_fallback(txt_cx, by, stack_ph, stack_txt, sub_sz, ACCENT_GOLD)
|
||||||
|
view._place_goth_photo_or_fallback(txt_cx, by + dy, st_ph, st_txt, sub_sz, st_col)
|
||||||
return top_center_bottom
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def draw_board_and_pot(
|
def draw_board_and_pot(
|
||||||
|
|
@ -141,20 +208,29 @@ class PokerArenaRenderer:
|
||||||
) -> None:
|
) -> None:
|
||||||
tx1, ty1, tx2, ty2 = table_rect
|
tx1, ty1, tx2, ty2 = table_rect
|
||||||
t_cx = (tx1 + tx2) // 2
|
t_cx = (tx1 + tx2) // 2
|
||||||
t_h = max(260, ty2 - ty1)
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
|
||||||
|
if compact:
|
||||||
|
felt_top = top_obstacle_y + 10
|
||||||
|
felt_bot = player_top_y - 8
|
||||||
|
else:
|
||||||
|
t_h = max(260, ty2 - ty1)
|
||||||
felt_top = max(ty1 + max(32, int(t_h * 0.14)), top_obstacle_y + 12)
|
felt_top = max(ty1 + max(32, int(t_h * 0.14)), top_obstacle_y + 12)
|
||||||
felt_bot = min(ty2 - max(24, int(t_h * 0.10)), player_top_y - 10)
|
felt_bot = min(ty2 - max(24, int(t_h * 0.10)), player_top_y - 10)
|
||||||
avail_h = max(148, felt_bot - felt_top)
|
|
||||||
|
avail_h = max(124 if compact else 148, felt_bot - felt_top)
|
||||||
|
avail_w = max(320, tx2 - tx1 - 16)
|
||||||
|
|
||||||
base_cw, base_ch = PK_OVAL_BOARD_CARD
|
base_cw, base_ch = PK_OVAL_BOARD_CARD
|
||||||
scale = max(84, min(base_ch, avail_h - 58)) / max(1, base_ch)
|
scale_h = max(72, min(base_ch, avail_h - 48)) / max(1, base_ch)
|
||||||
card_w, card_h = max(58, int(round(base_cw * scale))), int(round(base_ch * scale))
|
scale_w = (avail_w / 5.6) / max(1, base_cw)
|
||||||
|
scale = min(1.0, scale_h, scale_w)
|
||||||
|
card_w, card_h = max(52, int(round(base_cw * scale))), max(76, int(round(base_ch * scale)))
|
||||||
card_sz = (card_w, card_h)
|
card_sz = (card_w, card_h)
|
||||||
|
|
||||||
gap = max(8, int(card_w * 0.13))
|
gap = max(6, int(card_w * 0.12))
|
||||||
start_x = t_cx - (5 * card_w + 4 * gap) // 2
|
start_x = t_cx - (5 * card_w + 4 * gap) // 2
|
||||||
board_cy = felt_top + card_h // 2 + max(4, (avail_h - card_h - 52) // 3)
|
board_cy = felt_top + card_h // 2 + max(2, (avail_h - card_h - 46) // 3)
|
||||||
card_top = board_cy - card_h // 2
|
card_top = board_cy - card_h // 2
|
||||||
|
|
||||||
for slot_i in range(5):
|
for slot_i in range(5):
|
||||||
|
|
@ -171,34 +247,34 @@ class PokerArenaRenderer:
|
||||||
)
|
)
|
||||||
|
|
||||||
pot_txt = t("pk_pot_banner", view.engine.total_pot).split("|")[0].strip()
|
pot_txt = t("pk_pot_banner", view.engine.total_pot).split("|")[0].strip()
|
||||||
pot_cy = min(felt_bot - 20, max(board_cy + card_h // 2 + 28, (board_cy + card_h // 2 + felt_bot) // 2))
|
pot_cy = min(felt_bot - 18, max(board_cy + card_h // 2 + 24, (board_cy + card_h // 2 + felt_bot) // 2))
|
||||||
pot_sz = max(15, FONT_SIZE_BODY)
|
pot_sz = max(14 if compact else 15, FONT_SIZE_BODY - (1 if compact else 0))
|
||||||
pot_ph = view._make_goth_photo(pot_txt, pot_sz, FONT_COLOR_TITLE_MAIN)
|
pot_ph = view._make_goth_photo(pot_txt, pot_sz, FONT_COLOR_TITLE_MAIN)
|
||||||
if pot_ph is not None:
|
if pot_ph is not None:
|
||||||
bw, bh = max(230, pot_ph.width() + 64), max(38, pot_ph.height() + 16)
|
bw, bh = max(206, pot_ph.width() + 54), max(34, pot_ph.height() + 14)
|
||||||
view._draw_framed_panel(t_cx, pot_cy, bw, bh, frame_style="gold")
|
view._draw_framed_panel(t_cx, pot_cy, bw, bh, frame_style="gold")
|
||||||
view.arena_canvas.create_image(t_cx, pot_cy, image=pot_ph, anchor="center", tags="fg")
|
view.arena_canvas.create_image(t_cx, pot_cy, image=pot_ph, anchor="center", tags="fg")
|
||||||
else:
|
else:
|
||||||
view._draw_framed_panel(t_cx, pot_cy, 240, 38, frame_style="gold")
|
view._draw_framed_panel(t_cx, pot_cy, 220, 36, frame_style="gold")
|
||||||
view._place_goth_photo_or_fallback(t_cx, pot_cy, None, pot_txt, pot_sz, ACCENT_GOLD)
|
view._place_goth_photo_or_fallback(t_cx, pot_cy, None, pot_txt, pot_sz, ACCENT_GOLD)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def draw_human_hand(cls, view, cw: int, pad_x: int, player_zone_top: int, player_zone_bot: int) -> None:
|
def draw_human_hand(cls, view, cw: int, pad_x: int, player_zone_top: int, player_zone_bot: int) -> None:
|
||||||
human = view.engine.human_seat
|
human = view.engine.human_seat
|
||||||
avail_h = max(140, player_zone_bot - player_zone_top)
|
compact = getattr(view, "is_compact_arena", False)
|
||||||
|
avail_h = max(136 if compact else 140, player_zone_bot - player_zone_top)
|
||||||
zone_cy = (player_zone_top + player_zone_bot) // 2
|
zone_cy = (player_zone_top + player_zone_bot) // 2
|
||||||
|
|
||||||
base_w, base_h = PLAYING_CARD_SIZE
|
base_w, base_h = PLAYING_CARD_SIZE
|
||||||
scale = max(88, min(base_h, avail_h - 52)) / max(1, base_h)
|
scale = max(82, min(base_h, avail_h - 48)) / max(1, base_h)
|
||||||
card_w, card_h = max(60, int(round(base_w * scale))), int(round(base_h * scale))
|
card_w, card_h = max(56, int(round(base_w * scale))), int(round(base_h * scale))
|
||||||
card_sz = (card_w, card_h)
|
card_sz = (card_w, card_h)
|
||||||
|
|
||||||
p_photos = []
|
p_photos = [
|
||||||
for card in human.hole_cards:
|
ph for card in human.hole_cards
|
||||||
photo = view.ctx.assets.get_card_photo(card.image_filename, size=card_sz)
|
if (ph := view.ctx.assets.get_card_photo(card.image_filename, size=card_sz))
|
||||||
if photo:
|
]
|
||||||
view._photo_refs.append(photo)
|
view._photo_refs.extend(p_photos)
|
||||||
p_photos.append(photo)
|
|
||||||
|
|
||||||
state_tag = t("pk_state_folded") if human.folded else (t("pk_state_allin") if human.all_in else "")
|
state_tag = t("pk_state_folded") if human.folded else (t("pk_state_allin") if human.all_in else "")
|
||||||
role_str = cls.role_badge(view.engine, 0) or t("pk_role_player")
|
role_str = cls.role_badge(view.engine, 0) or t("pk_role_player")
|
||||||
|
|
@ -206,15 +282,15 @@ class PokerArenaRenderer:
|
||||||
|
|
||||||
is_my_turn = (view.engine.street != "SHOWDOWN" and view.engine.turn_pos == 0 and human.can_act)
|
is_my_turn = (view.engine.street != "SHOWDOWN" and view.engine.turn_pos == 0 and human.can_act)
|
||||||
lbl_col = ERROR_FG if human.folded else FONT_COLOR_TITLE_MAIN
|
lbl_col = ERROR_FG if human.folded else FONT_COLOR_TITLE_MAIN
|
||||||
lbl_sz = max(14, FONT_SIZE_BODY - 1)
|
lbl_sz = max(13 if compact else 14, FONT_SIZE_BODY - 1)
|
||||||
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, lbl_col)
|
lbl_ph = view._make_goth_photo(lbl_txt, lbl_sz, lbl_col, max_width=cw - 56)
|
||||||
|
|
||||||
cards_gap = 12
|
cards_gap = 10 if compact else 12
|
||||||
cards_span_w = len(p_photos) * card_w + max(0, len(p_photos) - 1) * cards_gap if p_photos else card_w * 2
|
cards_span_w = len(p_photos) * card_w + max(0, len(p_photos) - 1) * cards_gap if p_photos else card_w * 2
|
||||||
txt_w = lbl_ph.width() if lbl_ph is not None else 250
|
txt_w = lbl_ph.width() if lbl_ph is not None else 220
|
||||||
|
|
||||||
box_w = max(300, min(540, max(cards_span_w + 96, txt_w + 72)))
|
box_w = max(280, min(cw - 24 if compact else 540, max(cards_span_w + 76, txt_w + 56)))
|
||||||
box_h = min(avail_h, card_h + 52)
|
box_h = min(avail_h, card_h + 48)
|
||||||
box_cx = cw // 2
|
box_cx = cw // 2
|
||||||
|
|
||||||
status_bdr = ERROR_FG if human.folded else (ACCENT_GOTH if human.all_in else None)
|
status_bdr = ERROR_FG if human.folded else (ACCENT_GOTH if human.all_in else None)
|
||||||
|
|
@ -225,13 +301,13 @@ class PokerArenaRenderer:
|
||||||
|
|
||||||
if p_photos:
|
if p_photos:
|
||||||
c_start_x = box_cx - cards_span_w // 2
|
c_start_x = box_cx - cards_span_w // 2
|
||||||
c_top_y = (zone_cy - 11) - card_h // 2
|
c_top_y = (zone_cy - 10) - card_h // 2
|
||||||
for idx, ph in enumerate(p_photos):
|
for idx, ph in enumerate(p_photos):
|
||||||
view.arena_canvas.create_image(
|
view.arena_canvas.create_image(
|
||||||
c_start_x + idx * (card_w + cards_gap), c_top_y, image=ph, anchor="nw", tags="fg"
|
c_start_x + idx * (card_w + cards_gap), c_top_y, image=ph, anchor="nw", tags="fg"
|
||||||
)
|
)
|
||||||
|
|
||||||
view._place_goth_photo_or_fallback(box_cx, zone_cy + box_h // 2 - 20, lbl_ph, lbl_txt, lbl_sz, lbl_col)
|
view._place_goth_photo_or_fallback(box_cx, zone_cy + box_h // 2 - 18, lbl_ph, lbl_txt, lbl_sz, lbl_col)
|
||||||
|
|
||||||
ref_btn = view._card_ref_btn
|
ref_btn = view._card_ref_btn
|
||||||
if ref_btn is not None and ref_btn.winfo_exists():
|
if ref_btn is not None and ref_btn.winfo_exists():
|
||||||
|
|
@ -239,6 +315,10 @@ class PokerArenaRenderer:
|
||||||
ref_btn.place_forget()
|
ref_btn.place_forget()
|
||||||
else:
|
else:
|
||||||
ref_bw, ref_bh = ref_btn.pixel_width, ref_btn.pixel_height
|
ref_bw, ref_bh = ref_btn.pixel_width, ref_btn.pixel_height
|
||||||
|
if compact:
|
||||||
|
ref_x = cw - pad_x - ref_bw - 4
|
||||||
|
ref_y = max(player_zone_top - ref_bh - 4, zone_cy - box_h // 2 - ref_bh - 4)
|
||||||
|
else:
|
||||||
ref_x = box_cx + box_w // 2 + 16
|
ref_x = box_cx + box_w // 2 + 16
|
||||||
if ref_x + ref_bw > cw - pad_x - 6:
|
if ref_x + ref_bw > cw - pad_x - 6:
|
||||||
ref_x = max(pad_x + 6, box_cx - box_w // 2 - ref_bw - 16)
|
ref_x = max(pad_x + 6, box_cx - box_w // 2 - ref_bw - 16)
|
||||||
|
|
@ -277,20 +357,13 @@ class PokerArenaRenderer:
|
||||||
else t("pk_popup_player_won", hand_desc)
|
else t("pk_popup_player_won", hand_desc)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
headline = t(
|
headline = t("pk_popup_bot_won", ", ".join(payload["winner_names"]), hand_desc)
|
||||||
"pk_popup_bot_won", ", ".join(payload["winner_names"]), hand_desc
|
|
||||||
)
|
|
||||||
|
|
||||||
other_gains = [
|
other_gains = [t("pk_popup_bot_gain", b_n, b_g) for b_n, b_g in payload["bot_gains"] if b_g > 0]
|
||||||
t("pk_popup_bot_gain", b_n, b_g)
|
|
||||||
for b_n, b_g in payload["bot_gains"]
|
|
||||||
if b_g > 0
|
|
||||||
]
|
|
||||||
lvl_to = payload["leveled_to"]
|
lvl_to = payload["leveled_to"]
|
||||||
lvl_str = (
|
lvl_str = (
|
||||||
t("bj_popup_level_up", lvl_to, Progression.get_prestige_title(lvl_to))
|
t("bj_popup_level_up", lvl_to, Progression.get_prestige_title(lvl_to))
|
||||||
if lvl_to is not None
|
if lvl_to is not None else None
|
||||||
else None
|
|
||||||
)
|
)
|
||||||
|
|
||||||
seat_showdown = []
|
seat_showdown = []
|
||||||
|
|
@ -302,11 +375,7 @@ class PokerArenaRenderer:
|
||||||
"cards": s_rev["cards"],
|
"cards": s_rev["cards"],
|
||||||
"folded": s_rev["folded"],
|
"folded": s_rev["folded"],
|
||||||
"is_winner": s_rev["is_winner"],
|
"is_winner": s_rev["is_winner"],
|
||||||
"combo_text": (
|
"combo_text": f"{t('pk_bot_act_fold')} ({short_c})" if s_rev["folded"] else short_c,
|
||||||
f"{t('pk_bot_act_fold')} ({short_c})"
|
|
||||||
if s_rev["folded"]
|
|
||||||
else short_c
|
|
||||||
),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
cur_gold = Database.get_poker_account(view.pk_account["id"])["gold"]
|
cur_gold = Database.get_poker_account(view.pk_account["id"])["gold"]
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from resources.code_res.game_constants import (
|
||||||
SUIT_SYMBOLS,
|
SUIT_SYMBOLS,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
HAND_REFERENCE_EXAMPLES = (
|
HAND_REFERENCE_EXAMPLES = (
|
||||||
(1, 9, (("A", "S"), ("K", "S"), ("Q", "S"), ("J", "S"), ("10", "S"))),
|
(1, 9, (("A", "S"), ("K", "S"), ("Q", "S"), ("J", "S"), ("10", "S"))),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.poker.views.poker_table_view import PokerTableView
|
from games.poker.views.poker_table_view import PokerTableView
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
GOLD_MAX_ACCOUNTS,
|
GOLD_MAX_ACCOUNTS,
|
||||||
PK_MAX_BOTS,
|
PK_MAX_BOTS,
|
||||||
|
|
@ -12,7 +12,7 @@ from resources.code_res.game_constants import (
|
||||||
XP_TO_GOLD_AMOUNT,
|
XP_TO_GOLD_AMOUNT,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.luck_pouch_menu_base import LuckPouchMenuBase
|
from view.widgets.shared_bases.luck_pouch_menu_base import LuckPouchMenuBase
|
||||||
|
|
||||||
GAME_FOLDER_ID = "poker"
|
GAME_FOLDER_ID = "poker"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/poker/views/poker_result_dialog.py
|
# games/poker/views/poker_result_dialog.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from models.card import Card
|
from models.cards.card import Card
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
FONT_COLOR_BODY_DEFAULT,
|
FONT_COLOR_BODY_DEFAULT,
|
||||||
FONT_COLOR_BODY_MUTED,
|
FONT_COLOR_BODY_MUTED,
|
||||||
|
|
@ -13,7 +13,7 @@ from resources.code_res.game_constants import (
|
||||||
FONT_SIZE_SMALL_MIN,
|
FONT_SIZE_SMALL_MIN,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_result_dialog_base import CasinoResultDialogBase
|
from view.widgets.shared_bases.casino_result_dialog_base import CasinoResultDialogBase
|
||||||
|
|
||||||
POPUP_HOLE_CARD_SIZE = (46, 68)
|
POPUP_HOLE_CARD_SIZE = (46, 68)
|
||||||
POPUP_BOARD_CARD_SIZE = (44, 64)
|
POPUP_BOARD_CARD_SIZE = (44, 64)
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ from games.poker.views.poker_arena_renderer import PokerArenaRenderer
|
||||||
from games.poker.views.poker_hands_overlay import PokerHandsOverlay
|
from games.poker.views.poker_hands_overlay import PokerHandsOverlay
|
||||||
from games.poker.views.poker_result_dialog import PokerResultDialog
|
from games.poker.views.poker_result_dialog import PokerResultDialog
|
||||||
from games.poker.views.poker_turn_driver import PokerTurnDriver
|
from games.poker.views.poker_turn_driver import PokerTurnDriver
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import PK_STARTING_GOLD, PK_VARIANTS
|
from resources.code_res.game_constants import PK_STARTING_GOLD, PK_VARIANTS
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.casino_arena_base import CasinoArenaBase
|
from view.widgets.shared_bases.casino_arena_base import CasinoArenaBase
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
GAME_FOLDER_ID = "poker"
|
GAME_FOLDER_ID = "poker"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ import time
|
||||||
|
|
||||||
from games.poker.models.poker_seat import PokerSeat
|
from games.poker.models.poker_seat import PokerSeat
|
||||||
from games.poker.views.poker_arena_renderer import PokerArenaRenderer
|
from games.poker.views.poker_arena_renderer import PokerArenaRenderer
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from models.progression import Progression
|
from models.progression import Progression
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
PK_BOT_TURN_DELAY_MS,
|
PK_BOT_TURN_DELAY_MS,
|
||||||
PK_STREET_DELAY_MS,
|
PK_STREET_DELAY_MS,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
|
|
||||||
class PokerTurnDriver:
|
class PokerTurnDriver:
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/card_animator.py
|
# games/solitaire/base/cards/card_animator.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/card_hover_zoom.py
|
# games/solitaire/base/cards/card_hover_zoom.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_card import SolitaireCard
|
from games.solitaire.base.cards.solitaire_card import SolitaireCard
|
||||||
from resources.code_res.game_constants import ACCENT_GOLD, BORDER_COLOR
|
from resources.code_res.game_constants import ACCENT_GOLD, BORDER_COLOR
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_card.py
|
# games/solitaire/base/cards/solitaire_card.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_modal_dialog.py
|
# games/solitaire/base/session/solitaire_modal_dialog.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
@ -13,9 +13,9 @@ from resources.code_res.game_constants import (
|
||||||
FONT_SIZE_BODY,
|
FONT_SIZE_BODY,
|
||||||
FONT_SIZE_TITLE_LG,
|
FONT_SIZE_TITLE_LG,
|
||||||
)
|
)
|
||||||
from view.widgets.goth_dropdown import GothDropdown
|
from view.widgets.dropdown.goth_dropdown import GothDropdown
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
from view.widgets.modal_veil import ModalVeil
|
from view.widgets.overlays.modal_veil import ModalVeil
|
||||||
|
|
||||||
|
|
||||||
class SolitaireModalDialog(tk.Canvas):
|
class SolitaireModalDialog(tk.Canvas):
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_outcome_flow.py
|
# games/solitaire/base/session/solitaire_outcome_flow.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_modal_dialog import SolitaireModalDialog
|
from games.solitaire.base.session.solitaire_modal_dialog import SolitaireModalDialog
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from models.progression import Progression
|
from models.progression import Progression
|
||||||
from resources.code_res.game_constants import SOLO_FORFEIT_XP_RATIO
|
from resources.code_res.game_constants import SOLO_FORFEIT_XP_RATIO
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.endgame_fx_overlay import EndgameFxOverlay
|
from view.widgets.overlays.endgame_fx_overlay import EndgameFxOverlay
|
||||||
|
|
||||||
|
|
||||||
class SolitaireOutcomeFlow:
|
class SolitaireOutcomeFlow:
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_session_guard.py
|
# games/solitaire/base/session/solitaire_session_guard.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_canvas_input import SolitaireCanvasInput
|
from games.solitaire.base.table.solitaire_canvas_input import SolitaireCanvasInput
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_tap_prefs.py
|
# games/solitaire/base/session/solitaire_tap_prefs.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
|
|
||||||
TAP_TO_MOVE_SETTING_KEY = "sol_single_tap_to_move"
|
TAP_TO_MOVE_SETTING_KEY = "sol_single_tap_to_move"
|
||||||
SINGLE_TAP_MAX_HOLD_SEC = 0.28
|
SINGLE_TAP_MAX_HOLD_SEC = 0.28
|
||||||
|
|
@ -5,8 +5,8 @@ from __future__ import annotations
|
||||||
import json
|
import json
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_modal_dialog import SolitaireModalDialog
|
from games.solitaire.base.session.solitaire_modal_dialog import SolitaireModalDialog
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from models.progression import Progression
|
from models.progression import Progression
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
FONT_COLOR_BODY_DEFAULT,
|
FONT_COLOR_BODY_DEFAULT,
|
||||||
|
|
@ -23,17 +23,14 @@ from resources.code_res.game_constants import (
|
||||||
SOLO_FORFEIT_XP_RATIO,
|
SOLO_FORFEIT_XP_RATIO,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.goth_dropdown import GothDropdown
|
from view.layout_mode import LayoutMode
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
from view.widgets.menu_body_canvas import MenuBodyCanvas
|
from view.widgets.dropdown.goth_dropdown import GothDropdown
|
||||||
|
from view.widgets.shared_bases.menu_body_canvas import MenuBodyCanvas
|
||||||
|
|
||||||
|
|
||||||
class SolitaireMenuBase:
|
class SolitaireMenuBase:
|
||||||
"""
|
"""Gemeinsame Vorauswahl-Menü-Basisklasse für alle Solitaire-Spiele (Desktop & Kompakt/Mobile)."""
|
||||||
Gemeinsame Vorauswahl-Menü-Basisklasse für alle Solitaire-Spiele
|
|
||||||
(Klondike, FreeCell, Spider, Pyramid, TriPeaks):
|
|
||||||
Kapselt Fortsetzen-Banner, Aufgabe-Bestätigung, Varianten-Toggles & Schwierigkeits-Auswahl.
|
|
||||||
"""
|
|
||||||
|
|
||||||
GAME_FOLDER_ID: str = ""
|
GAME_FOLDER_ID: str = ""
|
||||||
GAME_TITLE_KEY: str = ""
|
GAME_TITLE_KEY: str = ""
|
||||||
|
|
@ -135,7 +132,7 @@ class SolitaireMenuBase:
|
||||||
resume_btn = ImageButton(
|
resume_btn = ImageButton(
|
||||||
cv, t("sol_resume_btn"), btn_fire, btn_fire,
|
cv, t("sol_resume_btn"), btn_fire, btn_fire,
|
||||||
lambda: self._resume_saved(saved, saved_meta["difficulty"]),
|
lambda: self._resume_saved(saved, saved_meta["difficulty"]),
|
||||||
sound_mgr=self.ctx.sounds, width=180, height=38, style="fire",
|
sound_mgr=self.ctx.sounds, width=174, height=36, style="fire",
|
||||||
)
|
)
|
||||||
|
|
||||||
def switch_variant(v_key: str):
|
def switch_variant(v_key: str):
|
||||||
|
|
@ -155,7 +152,7 @@ class SolitaireMenuBase:
|
||||||
btn_fire if is_sel else btn_purp,
|
btn_fire if is_sel else btn_purp,
|
||||||
lambda k=v_key: switch_variant(k),
|
lambda k=v_key: switch_variant(k),
|
||||||
sound_mgr=self.ctx.sounds,
|
sound_mgr=self.ctx.sounds,
|
||||||
width=self.TOGGLE_BTN_WIDTH, height=36,
|
width=min(self.TOGGLE_BTN_WIDTH, 152), height=34,
|
||||||
style="fire" if is_sel else "amethyst",
|
style="fire" if is_sel else "amethyst",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -168,7 +165,7 @@ class SolitaireMenuBase:
|
||||||
diff_dd = GothDropdown(
|
diff_dd = GothDropdown(
|
||||||
cv, self.ctx.assets, values=diff_labels, textvariable=diff_var,
|
cv, self.ctx.assets, values=diff_labels, textvariable=diff_var,
|
||||||
on_change=lambda val: Database.save_setting(diff_setting_key, str(diff_map.get(val, 1))),
|
on_change=lambda val: Database.save_setting(diff_setting_key, str(diff_map.get(val, 1))),
|
||||||
sound_mgr=self.ctx.sounds, width=420, height=40,
|
sound_mgr=self.ctx.sounds, width=380, height=38,
|
||||||
)
|
)
|
||||||
|
|
||||||
start_btn = ImageButton(
|
start_btn = ImageButton(
|
||||||
|
|
@ -184,13 +181,18 @@ class SolitaireMenuBase:
|
||||||
cv.delete("fg")
|
cv.delete("fg")
|
||||||
self._photo_refs.clear()
|
self._photo_refs.clear()
|
||||||
|
|
||||||
box_w = min(940, w - 120)
|
rw, rh = self.ctx.root.winfo_width(), self.ctx.root.winfo_height()
|
||||||
|
is_mobile = LayoutMode.is_compact(rw, rh) or (w < 780)
|
||||||
|
pad_x = LayoutMode.outer_pad_x(w, h, desktop_ratio=0.075, desktop_min=64)
|
||||||
|
|
||||||
|
box_w = min(940, w - 2 * pad_x)
|
||||||
cx = w // 2
|
cx = w // 2
|
||||||
x_left = cx - box_w // 2
|
x_left = cx - box_w // 2
|
||||||
cur_y = max(24, int(h * 0.055))
|
cur_y = 14 if is_mobile else max(24, int(h * 0.055))
|
||||||
|
|
||||||
title_ph = self.ctx.assets.get_goth_text_photo(
|
title_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t(self.GAME_TITLE_KEY), FONT_SIZE_TITLE_LG, FONT_COLOR_TITLE_MAIN, align="left"
|
t(self.GAME_TITLE_KEY), FONT_SIZE_TITLE_LG - (4 if is_mobile else 0),
|
||||||
|
FONT_COLOR_TITLE_MAIN, align="left",
|
||||||
)
|
)
|
||||||
sub_ph = self.ctx.assets.get_goth_text_photo(
|
sub_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t(self.SUBTITLE_KEY), FONT_SIZE_BODY, FONT_COLOR_BODY_MUTED, max_width=box_w, align="left"
|
t(self.SUBTITLE_KEY), FONT_SIZE_BODY, FONT_COLOR_BODY_MUTED, max_width=box_w, align="left"
|
||||||
|
|
@ -199,7 +201,7 @@ class SolitaireMenuBase:
|
||||||
cv.create_image(x_left, cur_y, image=title_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left, cur_y, image=title_ph, anchor="nw", tags="fg")
|
||||||
cur_y += title_ph.height() + 4
|
cur_y += title_ph.height() + 4
|
||||||
cv.create_image(x_left, cur_y, image=sub_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left, cur_y, image=sub_ph, anchor="nw", tags="fg")
|
||||||
cur_y += sub_ph.height() + 14
|
cur_y += sub_ph.height() + 12
|
||||||
|
|
||||||
if status_msg:
|
if status_msg:
|
||||||
st_ph = self.ctx.assets.get_goth_text_photo(
|
st_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
|
|
@ -209,10 +211,10 @@ class SolitaireMenuBase:
|
||||||
)
|
)
|
||||||
self._photo_refs.append(st_ph)
|
self._photo_refs.append(st_ph)
|
||||||
cv.create_image(x_left, cur_y, image=st_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left, cur_y, image=st_ph, anchor="nw", tags="fg")
|
||||||
cur_y += st_ph.height() + 12
|
cur_y += st_ph.height() + 10
|
||||||
|
|
||||||
if saved and saved_meta is not None and resume_btn is not None:
|
if saved and saved_meta is not None and resume_btn is not None:
|
||||||
res_h = 84
|
res_h = 98 if is_mobile else 84
|
||||||
res_cy = cur_y + res_h // 2
|
res_cy = cur_y + res_h // 2
|
||||||
r_box = self.ctx.assets.get_box_photo("box_gold_double", (box_w, res_h))
|
r_box = self.ctx.assets.get_box_photo("box_gold_double", (box_w, res_h))
|
||||||
if r_box:
|
if r_box:
|
||||||
|
|
@ -224,22 +226,79 @@ class SolitaireMenuBase:
|
||||||
)
|
)
|
||||||
ri_ph = self.ctx.assets.get_goth_text_photo(
|
ri_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
self._format_resume_info(saved, saved_meta),
|
self._format_resume_info(saved, saved_meta),
|
||||||
FONT_SIZE_BODY, FONT_COLOR_BODY_DEFAULT,
|
FONT_SIZE_SMALL_MIN if is_mobile else FONT_SIZE_BODY,
|
||||||
max_width=box_w - resume_btn.pixel_width - 70, align="left",
|
FONT_COLOR_BODY_DEFAULT,
|
||||||
|
max_width=max(160, box_w - resume_btn.pixel_width - 58), align="left",
|
||||||
)
|
)
|
||||||
self._photo_refs.extend([rt_ph, ri_ph])
|
self._photo_refs.extend([rt_ph, ri_ph])
|
||||||
cv.create_image(x_left + 26, res_cy - 17, image=rt_ph, anchor="w", tags="fg")
|
cv.create_image(x_left + 22, res_cy - 18, image=rt_ph, anchor="w", tags="fg")
|
||||||
cv.create_image(x_left + 26, res_cy + 15, image=ri_ph, anchor="w", tags="fg")
|
cv.create_image(x_left + 22, res_cy + 16, image=ri_ph, anchor="w", tags="fg")
|
||||||
cv.create_window(x_left + box_w - 26, res_cy, window=resume_btn, anchor="e", tags="fg")
|
cv.create_window(x_left + box_w - 20, res_cy, window=resume_btn, anchor="e", tags="fg")
|
||||||
cur_y += res_h + 18
|
cur_y += res_h + 16
|
||||||
|
|
||||||
sec_ph = self.ctx.assets.get_goth_text_photo(
|
sec_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t("sol_setup_sec_title"), FONT_SIZE_HEADING - 2, FONT_COLOR_HEADING_SUB, align="left"
|
t("sol_setup_sec_title"), FONT_SIZE_HEADING - 3, FONT_COLOR_HEADING_SUB,
|
||||||
|
max_width=box_w, align="left",
|
||||||
)
|
)
|
||||||
self._photo_refs.append(sec_ph)
|
self._photo_refs.append(sec_ph)
|
||||||
cv.create_image(x_left + 6, cur_y, image=sec_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left + 4, cur_y, image=sec_ph, anchor="nw", tags="fg")
|
||||||
cur_y += sec_ph.height() + 8
|
cur_y += sec_ph.height() + 8
|
||||||
|
|
||||||
|
dsc_txt = t(f"{self.DESC_KEY_PREFIX}{selected_variant}")
|
||||||
|
if is_mobile:
|
||||||
|
# Kompakte gestapelte Innenanordnung ohne Überhang rechts
|
||||||
|
setup_h = 278 if has_toggles else 248
|
||||||
|
setup_cy = cur_y + setup_h // 2
|
||||||
|
s_box = self.ctx.assets.get_box_photo("box_big", (box_w, setup_h))
|
||||||
|
if s_box:
|
||||||
|
self._photo_refs.append(s_box)
|
||||||
|
cv.create_image(cx, setup_cy, image=s_box, anchor="center", tags="fg")
|
||||||
|
|
||||||
|
in_x = x_left + 24
|
||||||
|
in_w = box_w - 48
|
||||||
|
iy = cur_y + 24
|
||||||
|
m_lbl = self.ctx.assets.get_goth_text_photo(
|
||||||
|
t(self.MODE_LABEL_KEY), FONT_SIZE_SMALL_MIN + 1, FONT_COLOR_HEADING_SUB, align="left"
|
||||||
|
)
|
||||||
|
self._photo_refs.append(m_lbl)
|
||||||
|
cv.create_image(in_x, iy, image=m_lbl, anchor="w", tags="fg")
|
||||||
|
|
||||||
|
if has_toggles:
|
||||||
|
iy += 32
|
||||||
|
bx_cur = in_x
|
||||||
|
for tb in toggle_btns:
|
||||||
|
cv.create_window(bx_cur, iy, window=tb, anchor="w", tags="fg")
|
||||||
|
bx_cur += tb.pixel_width + 8
|
||||||
|
iy += 28
|
||||||
|
else:
|
||||||
|
m_val = self.ctx.assets.get_goth_text_photo(
|
||||||
|
t(f"variant_{selected_variant}"), FONT_SIZE_BODY + 1, FONT_COLOR_TITLE_MAIN, align="left"
|
||||||
|
)
|
||||||
|
self._photo_refs.append(m_val)
|
||||||
|
cv.create_image(in_x + m_lbl.width() + 14, iy, image=m_val, anchor="w", tags="fg")
|
||||||
|
iy += 24
|
||||||
|
|
||||||
|
dsc_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
|
dsc_txt, FONT_SIZE_SMALL_MIN, FONT_COLOR_BODY_MUTED, max_width=in_w, align="left"
|
||||||
|
)
|
||||||
|
self._photo_refs.append(dsc_ph)
|
||||||
|
cv.create_image(in_x, iy, image=dsc_ph, anchor="nw", tags="fg")
|
||||||
|
iy += dsc_ph.height() + 16
|
||||||
|
|
||||||
|
d_lbl = self.ctx.assets.get_goth_text_photo(
|
||||||
|
t("sol_diff_lbl"), FONT_SIZE_SMALL_MIN + 1, FONT_COLOR_HEADING_SUB, align="left"
|
||||||
|
)
|
||||||
|
self._photo_refs.append(d_lbl)
|
||||||
|
cv.create_image(in_x, iy, image=d_lbl, anchor="w", tags="fg")
|
||||||
|
iy += 28
|
||||||
|
|
||||||
|
if diff_dd._width != in_w:
|
||||||
|
diff_dd._width = in_w
|
||||||
|
diff_dd.configure(width=in_w)
|
||||||
|
diff_dd._render_closed()
|
||||||
|
cv.create_window(in_x, iy, window=diff_dd, anchor="w", tags="fg")
|
||||||
|
cv.create_window(x_left + box_w - 24, cur_y + setup_h - 34, window=start_btn, anchor="e", tags="fg")
|
||||||
|
else:
|
||||||
setup_h = 238 if has_toggles else 208
|
setup_h = 238 if has_toggles else 208
|
||||||
setup_cy = cur_y + setup_h // 2
|
setup_cy = cur_y + setup_h // 2
|
||||||
s_box = self.ctx.assets.get_box_photo("box_big", (box_w, setup_h))
|
s_box = self.ctx.assets.get_box_photo("box_big", (box_w, setup_h))
|
||||||
|
|
@ -255,7 +314,6 @@ class SolitaireMenuBase:
|
||||||
self._photo_refs.append(m_lbl)
|
self._photo_refs.append(m_lbl)
|
||||||
cv.create_image(lbl_col, r1_y, image=m_lbl, anchor="w", tags="fg")
|
cv.create_image(lbl_col, r1_y, image=m_lbl, anchor="w", tags="fg")
|
||||||
|
|
||||||
dsc_txt = t(f"{self.DESC_KEY_PREFIX}{selected_variant}")
|
|
||||||
if has_toggles:
|
if has_toggles:
|
||||||
bx_cur = val_col
|
bx_cur = val_col
|
||||||
for tb in toggle_btns:
|
for tb in toggle_btns:
|
||||||
|
|
@ -292,18 +350,19 @@ class SolitaireMenuBase:
|
||||||
diff_dd.configure(width=dd_w)
|
diff_dd.configure(width=dd_w)
|
||||||
diff_dd._render_closed()
|
diff_dd._render_closed()
|
||||||
cv.create_window(val_col, r2_y, window=diff_dd, anchor="w", tags="fg")
|
cv.create_window(val_col, r2_y, window=diff_dd, anchor="w", tags="fg")
|
||||||
|
|
||||||
cv.create_window(x_left + box_w - 32, cur_y + setup_h - 38, window=start_btn, anchor="e", tags="fg")
|
cv.create_window(x_left + box_w - 32, cur_y + setup_h - 38, window=start_btn, anchor="e", tags="fg")
|
||||||
|
|
||||||
|
hint_y = cur_y + setup_h + 12
|
||||||
hint_ph = self.ctx.assets.get_goth_text_photo(
|
hint_ph = self.ctx.assets.get_goth_text_photo(
|
||||||
t(self.CONTROLS_HINT_KEY), FONT_SIZE_SMALL_MIN, FONT_COLOR_BODY_MUTED, max_width=box_w, align="left"
|
t(self.CONTROLS_HINT_KEY), FONT_SIZE_SMALL_MIN, FONT_COLOR_BODY_MUTED, max_width=box_w, align="left"
|
||||||
)
|
)
|
||||||
self._photo_refs.append(hint_ph)
|
self._photo_refs.append(hint_ph)
|
||||||
cv.create_image(x_left + 6, cur_y + setup_h + 14, image=hint_ph, anchor="nw", tags="fg")
|
cv.create_image(x_left + 4, hint_y, image=hint_ph, anchor="nw", tags="fg")
|
||||||
|
cv.set_scrollable_height(hint_y + hint_ph.height() + 20, h)
|
||||||
|
|
||||||
cv.bind("<Configure>", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None)
|
cv.bind("<Configure>", lambda e: draw_layout(e.width, e.height) if e.width >= 200 else None)
|
||||||
self.ctx.root.update_idletasks()
|
self.ctx.root.update_idletasks()
|
||||||
draw_layout(max(900, cv.winfo_width()), max(620, cv.winfo_height()))
|
draw_layout(max(460, cv.winfo_width()), max(560, cv.winfo_height()))
|
||||||
|
|
||||||
if ask_resume_popup and saved and saved_meta is not None:
|
if ask_resume_popup and saved and saved_meta is not None:
|
||||||
self._show_resume_prompt_modal(saved, saved_meta)
|
self._show_resume_prompt_modal(saved, saved_meta)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import tkinter as tk
|
||||||
import warnings
|
import warnings
|
||||||
from PIL import Image, ImageChops, ImageDraw, ImageTk
|
from PIL import Image, ImageChops, ImageDraw, ImageTk
|
||||||
|
|
||||||
|
from view.layout_mode import LayoutMode
|
||||||
|
|
||||||
_ICON_PIL_CACHE: dict[Path, Image.Image] = {}
|
_ICON_PIL_CACHE: dict[Path, Image.Image] = {}
|
||||||
_ICON_TK_CACHE: dict[tuple[Path, int], ImageTk.PhotoImage] = {}
|
_ICON_TK_CACHE: dict[tuple[Path, int], ImageTk.PhotoImage] = {}
|
||||||
|
|
||||||
|
|
@ -135,6 +137,8 @@ class SolitaireTableBgRenderer:
|
||||||
return self._raw_pil
|
return self._raw_pil
|
||||||
|
|
||||||
def get_frame_insets(self, canvas_w: int, canvas_h: int) -> tuple[int, int, int]:
|
def get_frame_insets(self, canvas_w: int, canvas_h: int) -> tuple[int, int, int]:
|
||||||
|
if LayoutMode.is_compact(canvas_w, canvas_h):
|
||||||
|
return max(8, int(canvas_w * 0.018)), 6, 8
|
||||||
if self._ensure_pil() is None:
|
if self._ensure_pil() is None:
|
||||||
return max(20, int(canvas_w * 0.04)), max(14, int(canvas_h * 0.022)), 16
|
return max(20, int(canvas_w * 0.04)), max(14, int(canvas_h * 0.022)), 16
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_canvas_input.py
|
# games/solitaire/base/table/solitaire_canvas_input.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
from games.solitaire.base.solitaire_tap_prefs import (
|
from games.solitaire.base.session.solitaire_tap_prefs import (
|
||||||
SINGLE_TAP_MAX_HOLD_SEC,
|
SINGLE_TAP_MAX_HOLD_SEC,
|
||||||
is_single_tap_to_move_enabled,
|
is_single_tap_to_move_enabled,
|
||||||
)
|
)
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_core.py
|
# games/solitaire/base/table/solitaire_core.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_card import (
|
from games.solitaire.base.cards.solitaire_card import (
|
||||||
RANK_VALUES,
|
RANK_VALUES,
|
||||||
SOLITAIRE_RANKS,
|
SOLITAIRE_RANKS,
|
||||||
SolitaireCard,
|
SolitaireCard,
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# games/solitaire/base/solitaire_table_controller.py
|
# games/solitaire/base/table/solitaire_table_controller.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
from games.solitaire.base.card_animator import CardFlightAnimator
|
from games.solitaire.base.cards.card_animator import CardFlightAnimator
|
||||||
from games.solitaire.base.card_hover_zoom import CardHoverZoom
|
from games.solitaire.base.cards.card_hover_zoom import CardHoverZoom
|
||||||
from games.solitaire.base.solitaire_bottom_bar import SolitaireBottomBar
|
from view.widgets.bars.goth_bottombar import GothBottombar
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
from games.solitaire.base.solitaire_outcome_flow import SolitaireOutcomeFlow
|
from games.solitaire.base.session.solitaire_outcome_flow import SolitaireOutcomeFlow
|
||||||
from games.solitaire.base.solitaire_session_guard import SolitaireSessionGuard
|
from games.solitaire.base.session.solitaire_session_guard import SolitaireSessionGuard
|
||||||
from games.solitaire.base.solitaire_theme import SolitaireTableBgRenderer
|
from games.solitaire.base.solitaire_theme import SolitaireTableBgRenderer
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
PLAYING_CARD_SIZE,
|
PLAYING_CARD_SIZE,
|
||||||
|
|
@ -17,8 +17,8 @@ from resources.code_res.game_constants import (
|
||||||
TABLE_BG,
|
TABLE_BG,
|
||||||
)
|
)
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.endgame_fx_overlay import EndgameFxOverlay
|
from view.widgets.overlays.endgame_fx_overlay import EndgameFxOverlay
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
|
|
||||||
class SolitaireTableController(SolitaireSessionGuard):
|
class SolitaireTableController(SolitaireSessionGuard):
|
||||||
|
|
@ -104,7 +104,7 @@ class SolitaireTableController(SolitaireSessionGuard):
|
||||||
self.hud_var = tk.StringVar(value="")
|
self.hud_var = tk.StringVar(value="")
|
||||||
self.status_var = tk.StringVar(value="")
|
self.status_var = tk.StringVar(value="")
|
||||||
|
|
||||||
self.bottom_bar = SolitaireBottomBar(
|
self.bottom_bar = GothBottombar(
|
||||||
self.ctx.root, self.ctx, self.hud_var, self.status_var
|
self.ctx.root, self.ctx, self.hud_var, self.status_var
|
||||||
)
|
)
|
||||||
self.bottom_bar.pack(fill="x", side="bottom", padx=14, pady=(4, 10))
|
self.bottom_bar.pack(fill="x", side="bottom", padx=14, pady=(4, 10))
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
||||||
# games/solitaire/freecell/models/freecell_engine.py
|
# games/solitaire/freecell/models/freecell_engine.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import (
|
from games.solitaire.base.table.solitaire_core import (
|
||||||
SolitaireBaseEngine,
|
SolitaireBaseEngine,
|
||||||
SolitaireCard,
|
SolitaireCard,
|
||||||
is_alternating_descending,
|
is_alternating_descending,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import heapq
|
||||||
import random
|
import random
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
||||||
from resources.code_res.game_constants import SUITS
|
from resources.code_res.game_constants import SUITS
|
||||||
|
|
||||||
_IS_RED = tuple((c // 13) in (1, 2) for c in range(52))
|
_IS_RED = tuple((c // 13) in (1, 2) for c in range(52))
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -2,8 +2,8 @@
|
||||||
# games/solitaire/freecell/views/freecell_table_view.py
|
# games/solitaire/freecell/views/freecell_table_view.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
from games.solitaire.base.solitaire_table_controller import SolitaireTableController
|
from games.solitaire.base.table.solitaire_table_controller import SolitaireTableController
|
||||||
from games.solitaire.freecell.models.freecell_engine import FreeCellEngine
|
from games.solitaire.freecell.models.freecell_engine import FreeCellEngine
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACCENT_GOLD,
|
ACCENT_GOLD,
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
||||||
# games/solitaire/klondike/models/klondike_engine.py
|
# games/solitaire/klondike/models/klondike_engine.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import (
|
from games.solitaire.base.table.solitaire_core import (
|
||||||
SolitaireBaseEngine,
|
SolitaireBaseEngine,
|
||||||
SolitaireCard,
|
SolitaireCard,
|
||||||
is_alternating_descending,
|
is_alternating_descending,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/solitaire/klondike/models/klondike_hint_analyzer.py
|
# games/solitaire/klondike/models/klondike_hint_analyzer.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
|
|
||||||
|
|
||||||
class KlondikeHintAnalyzer:
|
class KlondikeHintAnalyzer:
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import heapq
|
||||||
import random
|
import random
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
||||||
from resources.code_res.game_constants import SUITS
|
from resources.code_res.game_constants import SUITS
|
||||||
|
|
||||||
# Kompakte Karten-Codierung 0..51: card_id = suit_idx * 13 + (value - 1)
|
# Kompakte Karten-Codierung 0..51: card_id = suit_idx * 13 + (value - 1)
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -2,8 +2,8 @@
|
||||||
# games/solitaire/klondike/views/klondike_table_view.py
|
# games/solitaire/klondike/views/klondike_table_view.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
from games.solitaire.base.solitaire_table_controller import SolitaireTableController
|
from games.solitaire.base.table.solitaire_table_controller import SolitaireTableController
|
||||||
from games.solitaire.klondike.models.klondike_engine import KlondikeEngine
|
from games.solitaire.klondike.models.klondike_engine import KlondikeEngine
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACCENT_GOLD,
|
ACCENT_GOLD,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/solitaire/pyramid/models/pyramid_engine.py
|
# games/solitaire/pyramid/models/pyramid_engine.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireBaseEngine, SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireBaseEngine, SolitaireCard
|
||||||
from games.solitaire.pyramid.models.pyramid_solver import generate_solvable_pyramid_deal
|
from games.solitaire.pyramid.models.pyramid_solver import generate_solvable_pyramid_deal
|
||||||
from resources.code_res.game_constants import PYRAMID_REDEALS_BY_DIFF
|
from resources.code_res.game_constants import PYRAMID_REDEALS_BY_DIFF
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import heapq
|
||||||
import random
|
import random
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
||||||
from resources.code_res.game_constants import PYRAMID_REDEALS_BY_DIFF, SUITS
|
from resources.code_res.game_constants import PYRAMID_REDEALS_BY_DIFF, SUITS
|
||||||
|
|
||||||
_SUIT = tuple(c // 13 for c in range(52))
|
_SUIT = tuple(c // 13 for c in range(52))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,286 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# games/solitaire/pyramid/views/pyramid_board_renderer.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from resources.code_res.game_constants import (
|
||||||
|
ACCENT_GOLD,
|
||||||
|
BORDER_COLOR,
|
||||||
|
CELL_BG,
|
||||||
|
ERROR_FG,
|
||||||
|
FONT_COLOR_BODY_MUTED,
|
||||||
|
FONT_SIZE_SMALL_MIN,
|
||||||
|
SUBTLE_BORDER,
|
||||||
|
)
|
||||||
|
from resources.code_res.i18n import t
|
||||||
|
from view.layout_mode import LayoutMode
|
||||||
|
|
||||||
|
|
||||||
|
class PyramidBoardRenderer:
|
||||||
|
"""Berechnet die Pyramid-Geometrie (Desktop: Stapel rechts | Kompakt/Mobile: Stapel unten) und rendert das Board."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def compute_layout(cls, view) -> None:
|
||||||
|
rw = max(480, view.ctx.root.winfo_width())
|
||||||
|
rh = max(620, view.ctx.root.winfo_height())
|
||||||
|
is_compact = LayoutMode.is_compact(rw, rh)
|
||||||
|
|
||||||
|
min_cw = 440 if is_compact else 680
|
||||||
|
min_ch = 360 if is_compact else 420
|
||||||
|
cw = max(min_cw, view.canvas.winfo_width())
|
||||||
|
ch = max(min_ch, view.canvas.winfo_height())
|
||||||
|
aspect = view._get_card_aspect()
|
||||||
|
|
||||||
|
if is_compact or cw < 860:
|
||||||
|
cls._compute_bottom_deck_layout(view, cw, ch, aspect)
|
||||||
|
else:
|
||||||
|
cls._compute_side_deck_layout(view, cw, ch, aspect)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _compute_side_deck_layout(view, cw: int, ch: int, aspect: float) -> None:
|
||||||
|
margin_x, top_pad, bot_pad = view._bg_renderer.get_frame_insets(cw, ch)
|
||||||
|
v_top = max(16, int(top_pad * 0.36))
|
||||||
|
v_bot = max(14, int(bot_pad * 0.34))
|
||||||
|
view._frame_bot_pad = v_bot
|
||||||
|
|
||||||
|
usable_w = max(560, cw - 2 * margin_x)
|
||||||
|
usable_h = max(260, ch - v_top - v_bot)
|
||||||
|
|
||||||
|
card_w_by_h = int(round((usable_h / (1.0 + 6 * 0.39)) / aspect))
|
||||||
|
card_w_by_w = int(usable_w / 10.35)
|
||||||
|
card_w = max(64, min(138, card_w_by_w, card_w_by_h))
|
||||||
|
card_h = int(round(card_w * aspect))
|
||||||
|
view.card_size = (card_w, card_h)
|
||||||
|
|
||||||
|
col_gap = max(8, int(card_w * 0.10))
|
||||||
|
step_x = card_w + col_gap
|
||||||
|
row_dy = max(28, min(int(card_h * 0.40), (usable_h - card_h) // 6))
|
||||||
|
|
||||||
|
pyr_total_w = 6 * step_x + card_w
|
||||||
|
pyr_total_h = 6 * row_dy + card_h
|
||||||
|
|
||||||
|
side_gap = max(34, int(card_w * 0.50))
|
||||||
|
pair_gap = max(22, int(card_w * 0.28))
|
||||||
|
side_total_w = 2 * card_w + pair_gap
|
||||||
|
|
||||||
|
full_w = pyr_total_w + side_gap + side_total_w
|
||||||
|
start_x = max(margin_x, (cw - full_w) // 2)
|
||||||
|
pyr_apex_x = start_x + (pyr_total_w - card_w) // 2
|
||||||
|
pyr_top_y = v_top + max(0, (usable_h - pyr_total_h) // 2)
|
||||||
|
|
||||||
|
for r in range(7):
|
||||||
|
row_x0 = int(round(pyr_apex_x - r * (step_x / 2.0)))
|
||||||
|
ry = pyr_top_y + r * row_dy
|
||||||
|
for c in range(r + 1):
|
||||||
|
view._pyr_coords[r][c] = (row_x0 + c * step_x, ry)
|
||||||
|
|
||||||
|
side_block_h = card_h + 62
|
||||||
|
deck_y = pyr_top_y + max(22, (pyr_total_h - side_block_h) // 2)
|
||||||
|
stock_x = start_x + pyr_total_w + side_gap
|
||||||
|
waste_x = stock_x + card_w + pair_gap
|
||||||
|
|
||||||
|
view._stock_xy = (stock_x, deck_y)
|
||||||
|
view._waste_xy = (waste_x, deck_y)
|
||||||
|
view._next_btn_center = (
|
||||||
|
stock_x + side_total_w // 2,
|
||||||
|
deck_y + card_h + view.SOCKET_PAD_PX + 28,
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _compute_bottom_deck_layout(view, cw: int, ch: int, aspect: float) -> None:
|
||||||
|
"""Kompakt-/Mobile-Layout: 7er-Pyramide oben über volle Breite, Stapel + Button darunter."""
|
||||||
|
margin_x = max(10, int(cw * 0.022))
|
||||||
|
v_top = 8
|
||||||
|
v_bot = 8
|
||||||
|
view._frame_bot_pad = v_bot
|
||||||
|
|
||||||
|
usable_w = max(360, cw - 2 * margin_x)
|
||||||
|
usable_h = max(320, ch - v_top - v_bot)
|
||||||
|
|
||||||
|
btn_w = view.next_card_btn.pixel_width if view.next_card_btn else 186
|
||||||
|
inline_btn = cw >= (btn_w + 220)
|
||||||
|
extra_btn_row_h = 0 if inline_btn else 44
|
||||||
|
|
||||||
|
# Gesamthöhe = Pyramide (1 + 6*0.36 Kartenhöhen) + Caption/Lücke (34px) + Stapel (1 Kartenhöhe) + ggf. Button-Zeile
|
||||||
|
avail_card_px_h = max(180, usable_h - 36 - extra_btn_row_h)
|
||||||
|
card_w_by_h = int(round((avail_card_px_h / (2.0 + 6 * 0.36)) / aspect))
|
||||||
|
card_w_by_w = int(usable_w / 7.55)
|
||||||
|
card_w = max(50, min(102, card_w_by_w, card_w_by_h))
|
||||||
|
card_h = int(round(card_w * aspect))
|
||||||
|
view.card_size = (card_w, card_h)
|
||||||
|
|
||||||
|
col_gap = max(5, int(card_w * 0.08))
|
||||||
|
step_x = card_w + col_gap
|
||||||
|
max_pyr_h = max(card_h + 120, usable_h - card_h - 36 - extra_btn_row_h)
|
||||||
|
row_dy = max(22, min(int(card_h * 0.38), (max_pyr_h - card_h) // 6))
|
||||||
|
|
||||||
|
pyr_total_h = 6 * row_dy + card_h
|
||||||
|
bottom_zone_h = 28 + card_h + extra_btn_row_h
|
||||||
|
total_used_h = pyr_total_h + 12 + bottom_zone_h
|
||||||
|
|
||||||
|
pyr_top_y = v_top + max(0, (usable_h - total_used_h) // 2)
|
||||||
|
pyr_apex_x = (cw - card_w) // 2
|
||||||
|
|
||||||
|
for r in range(7):
|
||||||
|
row_x0 = int(round(pyr_apex_x - r * (step_x / 2.0)))
|
||||||
|
ry = pyr_top_y + r * row_dy
|
||||||
|
for c in range(r + 1):
|
||||||
|
view._pyr_coords[r][c] = (row_x0 + c * step_x, ry)
|
||||||
|
|
||||||
|
deck_y = pyr_top_y + pyr_total_h + 28
|
||||||
|
if inline_btn:
|
||||||
|
mid_gap = btn_w + 28
|
||||||
|
total_bot_w = 2 * card_w + mid_gap
|
||||||
|
sx = (cw - total_bot_w) // 2
|
||||||
|
wx = sx + card_w + mid_gap
|
||||||
|
view._stock_xy = (sx, deck_y)
|
||||||
|
view._waste_xy = (wx, deck_y)
|
||||||
|
view._next_btn_center = (cw // 2, deck_y + card_h // 2)
|
||||||
|
else:
|
||||||
|
pair_gap = max(20, int(card_w * 0.32))
|
||||||
|
sx = (cw - (2 * card_w + pair_gap)) // 2
|
||||||
|
wx = sx + card_w + pair_gap
|
||||||
|
view._stock_xy = (sx, deck_y)
|
||||||
|
view._waste_xy = (wx, deck_y)
|
||||||
|
view._next_btn_center = (cw // 2, deck_y + card_h + view.SOCKET_PAD_PX + 24)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def draw_deck_socket(view, x: int, y: int, highlight_color: str | None = None) -> None:
|
||||||
|
cw, ch = view.card_size
|
||||||
|
pad = view.SOCKET_PAD_PX
|
||||||
|
outer_col = highlight_color if highlight_color else BORDER_COLOR
|
||||||
|
outer_w = 2 if highlight_color else 1
|
||||||
|
view.canvas.create_rectangle(
|
||||||
|
x - pad, y - pad, x + cw + pad, y + ch + pad,
|
||||||
|
fill=CELL_BG, outline=outer_col, width=outer_w,
|
||||||
|
)
|
||||||
|
view.canvas.create_rectangle(
|
||||||
|
x - 2, y - 2, x + cw + 2, y + ch + 2,
|
||||||
|
fill="", outline=SUBTLE_BORDER, width=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def draw_pile_caption(view, cx: int, y: int, txt: str, color: str = FONT_COLOR_BODY_MUTED) -> None:
|
||||||
|
ph = view.ctx.assets.get_goth_text_photo(txt, FONT_SIZE_SMALL_MIN, color)
|
||||||
|
view._canvas_ui_refs.append(ph)
|
||||||
|
view.canvas.create_image(cx, y, image=ph, anchor="center")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def render_board(
|
||||||
|
cls,
|
||||||
|
view,
|
||||||
|
exclude_source: dict | None = None,
|
||||||
|
hidden_card_keys: set[tuple[str, str, int]] | None = None,
|
||||||
|
) -> None:
|
||||||
|
rw = max(480, view.ctx.root.winfo_width())
|
||||||
|
rh = max(620, view.ctx.root.winfo_height())
|
||||||
|
min_cw = 440 if LayoutMode.is_compact(rw, rh) else 680
|
||||||
|
min_ch = 360 if LayoutMode.is_compact(rw, rh) else 420
|
||||||
|
|
||||||
|
canvas_w, canvas_h = view._prepare_canvas_frame(min_cw, min_ch)
|
||||||
|
cw, _ch = view.card_size
|
||||||
|
hidden = hidden_card_keys or set()
|
||||||
|
|
||||||
|
if view._selected_ref is not None and view.engine.get_card_at_ref(view._selected_ref) is None:
|
||||||
|
view._selected_ref = None
|
||||||
|
|
||||||
|
hint_refs = set(view._active_hint.get("refs", [])) if view._active_hint else set()
|
||||||
|
|
||||||
|
# 1. 7-stufige Pyramide
|
||||||
|
for r in range(7):
|
||||||
|
for c in range(r + 1):
|
||||||
|
px, py = view._pyr_coords[r][c]
|
||||||
|
card = view.engine.pyramid[r][c]
|
||||||
|
ref = ("pyramid", r, c)
|
||||||
|
if exclude_source and exclude_source.get("ref") == ref:
|
||||||
|
card = None
|
||||||
|
if card is None or view._card_key(card) in hidden:
|
||||||
|
if r == 0 and view.engine.pyramid[0][0] is None:
|
||||||
|
view._draw_slot(px, py, symbol="13", symbol_color=ACCENT_GOLD)
|
||||||
|
continue
|
||||||
|
|
||||||
|
exposed = view.engine.is_pyramid_exposed(r, c)
|
||||||
|
is_shaking, s_dx = view.animator.shake_state_for(ref) if view.animator else (False, 0)
|
||||||
|
hl = (
|
||||||
|
ERROR_FG
|
||||||
|
if is_shaking
|
||||||
|
else (ACCENT_GOLD if (ref == view._selected_ref or ref in hint_refs) else None)
|
||||||
|
)
|
||||||
|
view._draw_card_at(
|
||||||
|
card, px + s_dx, py, tags=(f"pyr_{r}_{c}",),
|
||||||
|
highlight_color=hl, dim_non_movable=not exposed,
|
||||||
|
)
|
||||||
|
|
||||||
|
# 2. Linker Zugstapel
|
||||||
|
sx, sy = view._stock_xy
|
||||||
|
stock_ref = ("stock",)
|
||||||
|
st_shaking, st_dx = view.animator.shake_state_for(stock_ref) if view.animator else (False, 0)
|
||||||
|
st_hl = (
|
||||||
|
ERROR_FG
|
||||||
|
if st_shaking
|
||||||
|
else (ACCENT_GOLD if (stock_ref == view._selected_ref or stock_ref in hint_refs) else None)
|
||||||
|
)
|
||||||
|
cls.draw_deck_socket(view, sx, sy, highlight_color=None if st_shaking else st_hl)
|
||||||
|
|
||||||
|
s_pile = list(view.engine.stock)
|
||||||
|
if exclude_source and exclude_source.get("ref") == stock_ref and s_pile:
|
||||||
|
s_pile = s_pile[:-1]
|
||||||
|
s_pile = [c for c in s_pile if view._card_key(c) not in hidden]
|
||||||
|
if s_pile:
|
||||||
|
if st_shaking and len(s_pile) >= 2:
|
||||||
|
view._draw_card_at(s_pile[-2], sx, sy, tags=("pyr_stock_under",))
|
||||||
|
elif len(s_pile) >= 4:
|
||||||
|
view._draw_card_at(s_pile[-2], sx - 2, sy - 2)
|
||||||
|
view._draw_card_at(s_pile[-1], sx + st_dx, sy, tags=("pyr_stock_top",), highlight_color=st_hl)
|
||||||
|
else:
|
||||||
|
locked = view.engine.is_stock_locked
|
||||||
|
sym = "" if locked else ("↻" if view.engine.waste else "—")
|
||||||
|
view._draw_slot(
|
||||||
|
sx, sy, symbol=sym,
|
||||||
|
symbol_color=ACCENT_GOLD if sym == "↻" else SUBTLE_BORDER,
|
||||||
|
draw_red_cross=bool(locked and view.engine.waste),
|
||||||
|
)
|
||||||
|
cls.draw_pile_caption(
|
||||||
|
view, sx + cw // 2, sy - view.SOCKET_PAD_PX - 13, t("py_lbl_stock", len(view.engine.stock))
|
||||||
|
)
|
||||||
|
|
||||||
|
# 3. Rechter Ablagestapel
|
||||||
|
wx, wy = view._waste_xy
|
||||||
|
waste_ref = ("waste",)
|
||||||
|
w_shaking, w_dx = view.animator.shake_state_for(waste_ref) if view.animator else (False, 0)
|
||||||
|
w_hl = (
|
||||||
|
ERROR_FG
|
||||||
|
if w_shaking
|
||||||
|
else (ACCENT_GOLD if (waste_ref == view._selected_ref or waste_ref in hint_refs) else None)
|
||||||
|
)
|
||||||
|
cls.draw_deck_socket(view, wx, wy, highlight_color=None if w_shaking else w_hl)
|
||||||
|
|
||||||
|
w_pile = list(view.engine.waste)
|
||||||
|
if exclude_source and exclude_source.get("ref") == waste_ref and w_pile:
|
||||||
|
w_pile = w_pile[:-1]
|
||||||
|
w_pile = [c for c in w_pile if view._card_key(c) not in hidden]
|
||||||
|
if w_pile:
|
||||||
|
if w_shaking and len(w_pile) >= 2:
|
||||||
|
view._draw_card_at(w_pile[-2], wx, wy, tags=("pyr_waste_under",))
|
||||||
|
view._draw_card_at(w_pile[-1], wx + w_dx, wy, tags=("pyr_waste_top",), highlight_color=w_hl)
|
||||||
|
else:
|
||||||
|
view._draw_slot(wx, wy, symbol="◇", symbol_color=SUBTLE_BORDER)
|
||||||
|
cls.draw_pile_caption(
|
||||||
|
view, wx + cw // 2, sy - view.SOCKET_PAD_PX - 13, t("py_lbl_waste", len(view.engine.waste))
|
||||||
|
)
|
||||||
|
|
||||||
|
# 4. Button "Nächste Karte"
|
||||||
|
if view.next_card_btn is not None and view.next_card_btn.winfo_exists():
|
||||||
|
bx, by = view._next_btn_center
|
||||||
|
if ("next_btn",) in hint_refs:
|
||||||
|
bw, bh = view.next_card_btn.pixel_width, view.next_card_btn.pixel_height
|
||||||
|
view.canvas.create_rectangle(
|
||||||
|
bx - bw // 2 - 4, by - bh // 2 - 4,
|
||||||
|
bx + bw // 2 + 4, by + bh // 2 + 4,
|
||||||
|
outline=ACCENT_GOLD, width=2,
|
||||||
|
)
|
||||||
|
view.canvas.create_window(bx, by, window=view.next_card_btn, anchor="center")
|
||||||
|
|
||||||
|
if view.animator is not None:
|
||||||
|
view.animator.redraw_falling_layer()
|
||||||
|
|
||||||
|
view._finish_canvas_frame(canvas_w, canvas_h, exclude_source, hidden)
|
||||||
|
|
@ -2,21 +2,13 @@
|
||||||
# games/solitaire/pyramid/views/pyramid_table_view.py
|
# games/solitaire/pyramid/views/pyramid_table_view.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
from games.solitaire.base.solitaire_table_controller import SolitaireTableController
|
from games.solitaire.base.table.solitaire_table_controller import SolitaireTableController
|
||||||
from games.solitaire.pyramid.models.pyramid_engine import PyramidEngine
|
from games.solitaire.pyramid.models.pyramid_engine import PyramidEngine
|
||||||
from resources.code_res.game_constants import (
|
from games.solitaire.pyramid.views.pyramid_board_renderer import PyramidBoardRenderer
|
||||||
ACCENT_GOLD,
|
from resources.code_res.game_constants import PYRAMID_VARIANTS
|
||||||
BORDER_COLOR,
|
|
||||||
CELL_BG,
|
|
||||||
ERROR_FG,
|
|
||||||
FONT_COLOR_BODY_MUTED,
|
|
||||||
FONT_SIZE_SMALL_MIN,
|
|
||||||
PYRAMID_VARIANTS,
|
|
||||||
SUBTLE_BORDER,
|
|
||||||
)
|
|
||||||
from resources.code_res.i18n import t
|
from resources.code_res.i18n import t
|
||||||
from view.widgets.image_button import ImageButton
|
from view.widgets.buttons.image_button import ImageButton
|
||||||
|
|
||||||
GAME_FOLDER_ID = "solitaire/pyramid"
|
GAME_FOLDER_ID = "solitaire/pyramid"
|
||||||
GAME_TITLE_KEY = "game_title_pyramid"
|
GAME_TITLE_KEY = "game_title_pyramid"
|
||||||
|
|
@ -26,7 +18,6 @@ class PyramidTableView(SolitaireTableController):
|
||||||
GAME_FOLDER_ID = GAME_FOLDER_ID
|
GAME_FOLDER_ID = GAME_FOLDER_ID
|
||||||
HAS_AUTOCOMPLETE_BTN = False
|
HAS_AUTOCOMPLETE_BTN = False
|
||||||
SPEED_THRESHOLDS_SEC = (120, 220)
|
SPEED_THRESHOLDS_SEC = (120, 220)
|
||||||
|
|
||||||
SOCKET_PAD_PX = 6
|
SOCKET_PAD_PX = 6
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -85,8 +76,8 @@ class PyramidTableView(SolitaireTableController):
|
||||||
btn_purp,
|
btn_purp,
|
||||||
self._on_next_card_clicked,
|
self._on_next_card_clicked,
|
||||||
sound_mgr=self.ctx.sounds,
|
sound_mgr=self.ctx.sounds,
|
||||||
width=196,
|
width=186,
|
||||||
height=36,
|
height=34,
|
||||||
style="amethyst",
|
style="amethyst",
|
||||||
)
|
)
|
||||||
self._bind_root("<space>", lambda _e: self._on_next_card_shortcut())
|
self._bind_root("<space>", lambda _e: self._on_next_card_shortcut())
|
||||||
|
|
@ -203,84 +194,9 @@ class PyramidTableView(SolitaireTableController):
|
||||||
self._resize_job = None
|
self._resize_job = None
|
||||||
if not self._canvas_alive() or self._fx_overlay is not None:
|
if not self._canvas_alive() or self._fx_overlay is not None:
|
||||||
return
|
return
|
||||||
cw, ch = max(680, self.canvas.winfo_width()), max(420, self.canvas.winfo_height())
|
PyramidBoardRenderer.compute_layout(self)
|
||||||
aspect = self._get_card_aspect()
|
|
||||||
margin_x, top_pad, bot_pad = self._bg_renderer.get_frame_insets(cw, ch)
|
|
||||||
|
|
||||||
v_top = max(16, int(top_pad * 0.36))
|
|
||||||
v_bot = max(14, int(bot_pad * 0.34))
|
|
||||||
self._frame_bot_pad = v_bot
|
|
||||||
|
|
||||||
usable_w = max(560, cw - 2 * margin_x)
|
|
||||||
usable_h = max(260, ch - v_top - v_bot)
|
|
||||||
|
|
||||||
card_w_by_h = int(round((usable_h / (1.0 + 6 * 0.39)) / aspect))
|
|
||||||
card_w_by_w = int(usable_w / 10.35)
|
|
||||||
card_w = max(64, min(138, card_w_by_w, card_w_by_h))
|
|
||||||
card_h = int(round(card_w * aspect))
|
|
||||||
self.card_size = (card_w, card_h)
|
|
||||||
|
|
||||||
col_gap = max(8, int(card_w * 0.10))
|
|
||||||
step_x = card_w + col_gap
|
|
||||||
row_dy = max(28, min(int(card_h * 0.40), (usable_h - card_h) // 6))
|
|
||||||
|
|
||||||
pyr_total_w = 6 * step_x + card_w
|
|
||||||
pyr_total_h = 6 * row_dy + card_h
|
|
||||||
|
|
||||||
side_gap = max(34, int(card_w * 0.50))
|
|
||||||
pair_gap = max(22, int(card_w * 0.28))
|
|
||||||
side_total_w = 2 * card_w + pair_gap
|
|
||||||
|
|
||||||
full_w = pyr_total_w + side_gap + side_total_w
|
|
||||||
start_x = max(margin_x, (cw - full_w) // 2)
|
|
||||||
pyr_apex_x = start_x + (pyr_total_w - card_w) // 2
|
|
||||||
pyr_top_y = v_top + max(0, (usable_h - pyr_total_h) // 2)
|
|
||||||
|
|
||||||
for r in range(7):
|
|
||||||
row_x0 = int(round(pyr_apex_x - r * (step_x / 2.0)))
|
|
||||||
ry = pyr_top_y + r * row_dy
|
|
||||||
for c in range(r + 1):
|
|
||||||
self._pyr_coords[r][c] = (row_x0 + c * step_x, ry)
|
|
||||||
|
|
||||||
# Beide offenen Stapel + Button "Nächste Karte" sauber vertikal zentrieren
|
|
||||||
side_block_h = card_h + 62
|
|
||||||
deck_y = pyr_top_y + max(22, (pyr_total_h - side_block_h) // 2)
|
|
||||||
stock_x = start_x + pyr_total_w + side_gap
|
|
||||||
waste_x = stock_x + card_w + pair_gap
|
|
||||||
|
|
||||||
self._stock_xy = (stock_x, deck_y)
|
|
||||||
self._waste_xy = (waste_x, deck_y)
|
|
||||||
self._next_btn_center = (
|
|
||||||
stock_x + side_total_w // 2,
|
|
||||||
deck_y + card_h + self.SOCKET_PAD_PX + 28,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.redraw()
|
self.redraw()
|
||||||
|
|
||||||
def _draw_deck_socket(self, x: int, y: int, highlight_color: str | None = None):
|
|
||||||
cw, ch = self.card_size
|
|
||||||
pad = self.SOCKET_PAD_PX
|
|
||||||
outer_col = highlight_color if highlight_color else BORDER_COLOR
|
|
||||||
outer_w = 2 if highlight_color else 1
|
|
||||||
self.canvas.create_rectangle(
|
|
||||||
x - pad,
|
|
||||||
y - pad,
|
|
||||||
x + cw + pad,
|
|
||||||
y + ch + pad,
|
|
||||||
fill=CELL_BG,
|
|
||||||
outline=outer_col,
|
|
||||||
width=outer_w,
|
|
||||||
)
|
|
||||||
self.canvas.create_rectangle(
|
|
||||||
x - 2, y - 2, x + cw + 2, y + ch + 2,
|
|
||||||
fill="", outline=SUBTLE_BORDER, width=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
def _draw_pile_caption(self, cx: int, y: int, txt: str, color: str = FONT_COLOR_BODY_MUTED):
|
|
||||||
ph = self.ctx.assets.get_goth_text_photo(txt, FONT_SIZE_SMALL_MIN, color)
|
|
||||||
self._canvas_ui_refs.append(ph)
|
|
||||||
self.canvas.create_image(cx, y, image=ph, anchor="center")
|
|
||||||
|
|
||||||
def redraw(
|
def redraw(
|
||||||
self,
|
self,
|
||||||
exclude_source: dict | None = None,
|
exclude_source: dict | None = None,
|
||||||
|
|
@ -288,133 +204,9 @@ class PyramidTableView(SolitaireTableController):
|
||||||
):
|
):
|
||||||
if not self._canvas_alive():
|
if not self._canvas_alive():
|
||||||
return
|
return
|
||||||
canvas_w, canvas_h = self._prepare_canvas_frame(680, 420)
|
PyramidBoardRenderer.render_board(
|
||||||
cw, _ch = self.card_size
|
self, exclude_source=exclude_source, hidden_card_keys=hidden_card_keys
|
||||||
hidden = hidden_card_keys or set()
|
|
||||||
|
|
||||||
if self._selected_ref is not None and self.engine.get_card_at_ref(self._selected_ref) is None:
|
|
||||||
self._selected_ref = None
|
|
||||||
|
|
||||||
hint_refs = set(self._active_hint.get("refs", [])) if self._active_hint else set()
|
|
||||||
|
|
||||||
# 1. 7-stufige Pyramide zeichnen
|
|
||||||
for r in range(7):
|
|
||||||
for c in range(r + 1):
|
|
||||||
px, py = self._pyr_coords[r][c]
|
|
||||||
card = self.engine.pyramid[r][c]
|
|
||||||
ref = ("pyramid", r, c)
|
|
||||||
if exclude_source and exclude_source.get("ref") == ref:
|
|
||||||
card = None
|
|
||||||
if card is None or self._card_key(card) in hidden:
|
|
||||||
if r == 0 and self.engine.pyramid[0][0] is None:
|
|
||||||
self._draw_slot(px, py, symbol="13", symbol_color=ACCENT_GOLD)
|
|
||||||
continue
|
|
||||||
|
|
||||||
exposed = self.engine.is_pyramid_exposed(r, c)
|
|
||||||
is_shaking, s_dx = (
|
|
||||||
self.animator.shake_state_for(ref) if self.animator else (False, 0)
|
|
||||||
)
|
)
|
||||||
hl = (
|
|
||||||
ERROR_FG
|
|
||||||
if is_shaking
|
|
||||||
else (ACCENT_GOLD if (ref == self._selected_ref or ref in hint_refs) else None)
|
|
||||||
)
|
|
||||||
self._draw_card_at(
|
|
||||||
card,
|
|
||||||
px + s_dx,
|
|
||||||
py,
|
|
||||||
tags=(f"pyr_{r}_{c}",),
|
|
||||||
highlight_color=hl,
|
|
||||||
dim_non_movable=not exposed,
|
|
||||||
)
|
|
||||||
|
|
||||||
# 2. Linker Stapel (OFFEN aufgedeckt & direkt auswählbar!)
|
|
||||||
sx, sy = self._stock_xy
|
|
||||||
stock_ref = ("stock",)
|
|
||||||
st_shaking, st_dx = (
|
|
||||||
self.animator.shake_state_for(stock_ref) if self.animator else (False, 0)
|
|
||||||
)
|
|
||||||
st_hl = (
|
|
||||||
ERROR_FG
|
|
||||||
if st_shaking
|
|
||||||
else (ACCENT_GOLD if (stock_ref == self._selected_ref or stock_ref in hint_refs) else None)
|
|
||||||
)
|
|
||||||
self._draw_deck_socket(sx, sy, highlight_color=None if st_shaking else st_hl)
|
|
||||||
|
|
||||||
s_pile = list(self.engine.stock)
|
|
||||||
if exclude_source and exclude_source.get("ref") == stock_ref and s_pile:
|
|
||||||
s_pile = s_pile[:-1]
|
|
||||||
s_pile = [c for c in s_pile if self._card_key(c) not in hidden]
|
|
||||||
if s_pile:
|
|
||||||
if st_shaking and len(s_pile) >= 2:
|
|
||||||
self._draw_card_at(s_pile[-2], sx, sy, tags=("pyr_stock_under",))
|
|
||||||
elif len(s_pile) >= 4:
|
|
||||||
self._draw_card_at(s_pile[-2], sx - 2, sy - 2)
|
|
||||||
self._draw_card_at(
|
|
||||||
s_pile[-1], sx + st_dx, sy, tags=("pyr_stock_top",), highlight_color=st_hl
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
locked = self.engine.is_stock_locked
|
|
||||||
sym = "" if locked else ("↻" if self.engine.waste else "—")
|
|
||||||
self._draw_slot(
|
|
||||||
sx,
|
|
||||||
sy,
|
|
||||||
symbol=sym,
|
|
||||||
symbol_color=ACCENT_GOLD if sym == "↻" else SUBTLE_BORDER,
|
|
||||||
draw_red_cross=bool(locked and self.engine.waste),
|
|
||||||
)
|
|
||||||
self._draw_pile_caption(
|
|
||||||
sx + cw // 2, sy - self.SOCKET_PAD_PX - 14, t("py_lbl_stock", len(self.engine.stock))
|
|
||||||
)
|
|
||||||
|
|
||||||
# 3. Rechter Ablagestapel (OFFEN aufgedeckt & mit Links oder Pyramide kombinierbar!)
|
|
||||||
wx, wy = self._waste_xy
|
|
||||||
waste_ref = ("waste",)
|
|
||||||
w_shaking, w_dx = (
|
|
||||||
self.animator.shake_state_for(waste_ref) if self.animator else (False, 0)
|
|
||||||
)
|
|
||||||
w_hl = (
|
|
||||||
ERROR_FG
|
|
||||||
if w_shaking
|
|
||||||
else (ACCENT_GOLD if (waste_ref == self._selected_ref or waste_ref in hint_refs) else None)
|
|
||||||
)
|
|
||||||
self._draw_deck_socket(wx, wy, highlight_color=None if w_shaking else w_hl)
|
|
||||||
|
|
||||||
w_pile = list(self.engine.waste)
|
|
||||||
if exclude_source and exclude_source.get("ref") == waste_ref and w_pile:
|
|
||||||
w_pile = w_pile[:-1]
|
|
||||||
w_pile = [c for c in w_pile if self._card_key(c) not in hidden]
|
|
||||||
if w_pile:
|
|
||||||
if w_shaking and len(w_pile) >= 2:
|
|
||||||
self._draw_card_at(w_pile[-2], wx, wy, tags=("pyr_waste_under",))
|
|
||||||
self._draw_card_at(
|
|
||||||
w_pile[-1], wx + w_dx, wy, tags=("pyr_waste_top",), highlight_color=w_hl
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self._draw_slot(wx, wy, symbol="◇", symbol_color=SUBTLE_BORDER)
|
|
||||||
self._draw_pile_caption(
|
|
||||||
wx + cw // 2, wy - self.SOCKET_PAD_PX - 14, t("py_lbl_waste", len(self.engine.waste))
|
|
||||||
)
|
|
||||||
|
|
||||||
# 4. Button "Nächste Karte" mittig unter den beiden Stapeln platzieren
|
|
||||||
if self.next_card_btn is not None and self.next_card_btn.winfo_exists():
|
|
||||||
bx, by = self._next_btn_center
|
|
||||||
if ("next_btn",) in hint_refs:
|
|
||||||
bw, bh = self.next_card_btn.pixel_width, self.next_card_btn.pixel_height
|
|
||||||
self.canvas.create_rectangle(
|
|
||||||
bx - bw // 2 - 4,
|
|
||||||
by - bh // 2 - 4,
|
|
||||||
bx + bw // 2 + 4,
|
|
||||||
by + bh // 2 + 4,
|
|
||||||
outline=ACCENT_GOLD,
|
|
||||||
width=2,
|
|
||||||
)
|
|
||||||
self.canvas.create_window(bx, by, window=self.next_card_btn, anchor="center")
|
|
||||||
|
|
||||||
if self.animator is not None:
|
|
||||||
self.animator.redraw_falling_layer()
|
|
||||||
|
|
||||||
self._finish_canvas_frame(canvas_w, canvas_h, exclude_source, hidden)
|
|
||||||
|
|
||||||
def _find_first_overlapping_tag(self, row: int, col: int) -> str | None:
|
def _find_first_overlapping_tag(self, row: int, col: int) -> str | None:
|
||||||
for nr in range(row + 1, 7):
|
for nr in range(row + 1, 7):
|
||||||
|
|
@ -442,11 +234,8 @@ class PyramidTableView(SolitaireTableController):
|
||||||
else self._find_first_overlapping_tag(r, c)
|
else self._find_first_overlapping_tag(r, c)
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"card": card,
|
"card": card, "x": px, "y": py,
|
||||||
"x": px,
|
"size": self.card_size, "under_tag": under_tag,
|
||||||
"y": py,
|
|
||||||
"size": self.card_size,
|
|
||||||
"under_tag": under_tag,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sx, sy = self._stock_xy
|
sx, sy = self._stock_xy
|
||||||
|
|
@ -469,25 +258,18 @@ class PyramidTableView(SolitaireTableController):
|
||||||
if px <= x <= px + cw and py <= y <= py + ch:
|
if px <= x <= px + cw and py <= y <= py + ch:
|
||||||
if not self.engine.is_pyramid_exposed(r, c):
|
if not self.engine.is_pyramid_exposed(r, c):
|
||||||
return None
|
return None
|
||||||
ref = ("pyramid", r, c)
|
return {"zone": "pyramid", "ref": ("pyramid", r, c), "cards": [card], "origin": (px, py)}
|
||||||
return {"zone": "pyramid", "ref": ref, "cards": [card], "origin": (px, py)}
|
|
||||||
|
|
||||||
# Klick auf den linken Stapel wählt IMMER die offene Karte aus (oder bei leerem Stapel Redeal)
|
|
||||||
sx, sy = self._stock_xy
|
sx, sy = self._stock_xy
|
||||||
if sx <= x <= sx + cw and sy <= y <= sy + ch:
|
if sx <= x <= sx + cw and sy <= y <= sy + ch and self.engine.stock:
|
||||||
if self.engine.stock:
|
return {"zone": "stock", "ref": ("stock",), "cards": [self.engine.stock[-1]], "origin": (sx, sy)}
|
||||||
ref = ("stock",)
|
|
||||||
return {"zone": "stock", "ref": ref, "cards": [self.engine.stock[-1]], "origin": (sx, sy)}
|
|
||||||
return None
|
|
||||||
|
|
||||||
wx, wy = self._waste_xy
|
wx, wy = self._waste_xy
|
||||||
if self.engine.waste and wx <= x <= wx + cw and wy <= y <= wy + ch:
|
if self.engine.waste and wx <= x <= wx + cw and wy <= y <= wy + ch:
|
||||||
ref = ("waste",)
|
return {"zone": "waste", "ref": ("waste",), "cards": [self.engine.waste[-1]], "origin": (wx, wy)}
|
||||||
return {"zone": "waste", "ref": ref, "cards": [self.engine.waste[-1]], "origin": (wx, wy)}
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _on_next_card_clicked(self):
|
def _on_next_card_clicked(self):
|
||||||
"""Schiebt per Button 'Nächste Karte' die linke Karte nach rechts (oder Redeal)."""
|
|
||||||
if self._is_ui_locked():
|
if self._is_ui_locked():
|
||||||
return
|
return
|
||||||
if self.hover_zoom is not None:
|
if self.hover_zoom is not None:
|
||||||
|
|
@ -522,12 +304,10 @@ class PyramidTableView(SolitaireTableController):
|
||||||
if card is None:
|
if card is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# König (13) ohne aktive Vorwahl -> sofort drehend herausfallen lassen
|
|
||||||
if card.value == 13 and self._selected_ref is None:
|
if card.value == 13 and self._selected_ref is None:
|
||||||
self._execute_clear_with_fall([ref], lambda: self.engine.remove_king(ref))
|
self._execute_clear_with_fall([ref], lambda: self.engine.remove_king(ref))
|
||||||
return
|
return
|
||||||
|
|
||||||
# Zweite Karte angeklickt -> Paar (inkl. Links + Rechts!) prüfen
|
|
||||||
if self._selected_ref is not None:
|
if self._selected_ref is not None:
|
||||||
if self._selected_ref == ref:
|
if self._selected_ref == ref:
|
||||||
self._selected_ref = None
|
self._selected_ref = None
|
||||||
|
|
@ -553,7 +333,6 @@ class PyramidTableView(SolitaireTableController):
|
||||||
self._trigger_mismatch_shake([prev_ref, ref])
|
self._trigger_mismatch_shake([prev_ref, ref])
|
||||||
return
|
return
|
||||||
|
|
||||||
# Erste Karte angeklickt (auch links auf dem Stapel!) -> immer erst auswählen!
|
|
||||||
self._selected_ref = ref
|
self._selected_ref = ref
|
||||||
self.status_var.set("")
|
self.status_var.set("")
|
||||||
self.ctx.sounds.play("click")
|
self.ctx.sounds.play("click")
|
||||||
|
|
@ -581,8 +360,7 @@ class PyramidTableView(SolitaireTableController):
|
||||||
|
|
||||||
cards: list[SolitaireCard] = info.get("cards", [])
|
cards: list[SolitaireCard] = info.get("cards", [])
|
||||||
if cards and self.animator:
|
if cards and self.animator:
|
||||||
hidden_keys = {self._card_key(cards[0])}
|
self.redraw(hidden_card_keys={self._card_key(cards[0])})
|
||||||
self.redraw(hidden_card_keys=hidden_keys)
|
|
||||||
self.animator.start(
|
self.animator.start(
|
||||||
[{"card": cards[0], "start": (drop_x, drop_y), "end": (ox, oy)}],
|
[{"card": cards[0], "start": (drop_x, drop_y), "end": (ox, oy)}],
|
||||||
self._draw_card_at,
|
self._draw_card_at,
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
||||||
# games/solitaire/spider_solitaire/models/spider_engine.py
|
# games/solitaire/spider_solitaire/models/spider_engine.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import (
|
from games.solitaire.base.table.solitaire_core import (
|
||||||
SolitaireBaseEngine,
|
SolitaireBaseEngine,
|
||||||
SolitaireCard,
|
SolitaireCard,
|
||||||
is_same_suit_descending,
|
is_same_suit_descending,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
||||||
|
|
||||||
|
|
||||||
def _evaluate_spider_deal_hardness(
|
def _evaluate_spider_deal_hardness(
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -2,8 +2,8 @@
|
||||||
# games/solitaire/spider_solitaire/views/spider_table_view.py
|
# games/solitaire/spider_solitaire/views/spider_table_view.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
from games.solitaire.base.solitaire_table_controller import SolitaireTableController
|
from games.solitaire.base.table.solitaire_table_controller import SolitaireTableController
|
||||||
from games.solitaire.spider_solitaire.models.spider_engine import SpiderEngine
|
from games.solitaire.spider_solitaire.models.spider_engine import SpiderEngine
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
ACCENT_GOLD,
|
ACCENT_GOLD,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# games/solitaire/tripeaks/models/tripeaks_engine.py
|
# games/solitaire/tripeaks/models/tripeaks_engine.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireBaseEngine, SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireBaseEngine, SolitaireCard
|
||||||
from games.solitaire.tripeaks.models.tripeaks_solver import (
|
from games.solitaire.tripeaks.models.tripeaks_solver import (
|
||||||
TRIPEAKS_CHILDREN,
|
TRIPEAKS_CHILDREN,
|
||||||
generate_solvable_tripeaks_deal,
|
generate_solvable_tripeaks_deal,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import heapq
|
||||||
import random
|
import random
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SOLITAIRE_RANKS, SolitaireCard
|
||||||
from resources.code_res.game_constants import SUITS, TRIPEAKS_REDEALS_BY_DIFF
|
from resources.code_res.game_constants import SUITS, TRIPEAKS_REDEALS_BY_DIFF
|
||||||
|
|
||||||
_SUIT = tuple(c // 13 for c in range(52))
|
_SUIT = tuple(c // 13 for c in range(52))
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
# games/solitaire/tripeaks/views/tripeaks_table_view.py
|
# games/solitaire/tripeaks/views/tripeaks_table_view.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from games.solitaire.base.solitaire_core import SolitaireCard
|
from games.solitaire.base.table.solitaire_core import SolitaireCard
|
||||||
from games.solitaire.base.solitaire_table_controller import SolitaireTableController
|
from games.solitaire.base.table.solitaire_table_controller import SolitaireTableController
|
||||||
from games.solitaire.tripeaks.models.tripeaks_engine import TriPeaksEngine
|
from games.solitaire.tripeaks.models.tripeaks_engine import TriPeaksEngine
|
||||||
from games.solitaire.tripeaks.models.tripeaks_solver import TRIPEAKS_LAYOUT
|
from games.solitaire.tripeaks.models.tripeaks_solver import TRIPEAKS_LAYOUT
|
||||||
from resources.code_res.game_constants import (
|
from resources.code_res.game_constants import (
|
||||||
|
|
|
||||||
6
main.py
6
main.py
|
|
@ -18,11 +18,11 @@ if sys.platform.startswith("linux"):
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
from controller.app_controller import AppController
|
from controller.app_controller import AppController
|
||||||
from models.database import Database
|
from models.db.database import Database
|
||||||
from resources.code_res.game_constants import APP_ICON_REL_PATH
|
from resources.code_res.game_constants import APP_ICON_REL_PATH
|
||||||
from view.font_loader import FontLoader
|
from view.typography.font_loader import FontLoader
|
||||||
from view.main_window import GothCardCollectionView
|
from view.main_window import GothCardCollectionView
|
||||||
from view.widgets.error_report_overlay import ErrorReportOverlay
|
from view.widgets.overlays.error_report_overlay import ErrorReportOverlay
|
||||||
from games.solitaire.base.solitaire_theme import extract_best_ico_pil
|
from games.solitaire.base.solitaire_theme import extract_best_ico_pil
|
||||||
|
|
||||||
# Oben in view/main_window.py:
|
# Oben in view/main_window.py:
|
||||||
|
|
|
||||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue