Numerous WebUI animations, improvements, AI fixes, opporitunity cost-based decision logic, etc.

This commit is contained in:
Aaron D. Lee
2026-01-25 17:37:01 -05:00
parent d9073f862c
commit f80bab3b4b
35 changed files with 5772 additions and 403 deletions

View File

@@ -4,6 +4,9 @@ Card value constants for 6-Card Golf.
This module is the single source of truth for all card point values.
House rule modifications are defined here and applied in game.py.
Configuration can be customized via environment variables.
See config.py and .env.example for details.
Standard Golf Scoring:
- Ace: 1 point
- Two: -2 points (special - only negative non-joker)
@@ -15,29 +18,72 @@ Standard Golf Scoring:
from typing import Optional
# Base card values (no house rules applied)
DEFAULT_CARD_VALUES: dict[str, int] = {
'A': 1,
'2': -2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8': 8,
'9': 9,
'10': 10,
'J': 10,
'Q': 10,
'K': 0,
'': -2, # Joker (standard mode)
}
# Try to load from config (which reads env vars), fall back to hardcoded defaults
try:
from config import config
_use_config = True
except ImportError:
_use_config = False
# --- House Rule Value Overrides ---
SUPER_KINGS_VALUE: int = -2 # Kings worth -2 instead of 0
TEN_PENNY_VALUE: int = 1 # 10s worth 1 instead of 10
LUCKY_SWING_JOKER_VALUE: int = -5 # Single joker worth -5
# =============================================================================
# Card Values - Single Source of Truth
# =============================================================================
if _use_config:
# Load from environment-aware config
DEFAULT_CARD_VALUES: dict[str, int] = config.card_values.to_dict()
SUPER_KINGS_VALUE: int = config.card_values.SUPER_KINGS
TEN_PENNY_VALUE: int = config.card_values.TEN_PENNY
LUCKY_SWING_JOKER_VALUE: int = config.card_values.LUCKY_SWING_JOKER
else:
# Hardcoded defaults (fallback)
DEFAULT_CARD_VALUES: dict[str, int] = {
'A': 1,
'2': -2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8': 8,
'9': 9,
'10': 10,
'J': 10,
'Q': 10,
'K': 0,
'': -2, # Joker (standard mode)
}
SUPER_KINGS_VALUE: int = -2 # Kings worth -2 instead of 0
TEN_PENNY_VALUE: int = 1 # 10s worth 1 instead of 10
LUCKY_SWING_JOKER_VALUE: int = -5 # Single joker worth -5
# =============================================================================
# Game Constants
# =============================================================================
if _use_config:
MAX_PLAYERS = config.MAX_PLAYERS_PER_ROOM
ROOM_CODE_LENGTH = config.ROOM_CODE_LENGTH
ROOM_TIMEOUT_MINUTES = config.ROOM_TIMEOUT_MINUTES
DEFAULT_ROUNDS = config.game_defaults.rounds
DEFAULT_INITIAL_FLIPS = config.game_defaults.initial_flips
DEFAULT_USE_JOKERS = config.game_defaults.use_jokers
DEFAULT_FLIP_ON_DISCARD = config.game_defaults.flip_on_discard
else:
MAX_PLAYERS = 6
ROOM_CODE_LENGTH = 4
ROOM_TIMEOUT_MINUTES = 60
DEFAULT_ROUNDS = 9
DEFAULT_INITIAL_FLIPS = 2
DEFAULT_USE_JOKERS = False
DEFAULT_FLIP_ON_DISCARD = False
# =============================================================================
# Helper Functions
# =============================================================================
def get_card_value_for_rank(
rank_str: str,