# † Blackjack – Devil's Gambit †
[**Deutsch**](#deutsch) **| [English](#english)**
---
## 🇩🇪 Deutsch
### Überblick
**Blackjack – Devil's Gambit** kombiniert klassische Vegas-Kartenregeln mit einem gnadenlosen Multi-Player-Goldpot, spiellevel-skalierten Erhöhungen, **Divine Punishment** auf Gottheit-Rang und dem unausweichlichen **Devil's Deal**.
### 1. Kontoverwaltung, UI-Logik & Grundregeln
* **Bewusstes Goldbeutel-System (0–5 Konten):**
* Neue Seelen starten ohne automatisch aufgezwungenes Startkonto. Erst nach dem bewussten Anlegen eines Goldbeutels (bis zu **5 separate Konten**, Startkapital je **1.000 Gold**) werden Gegner-Setup, XP-Umtausch, Tischauswahl und Konto-Statistiken freigeschaltet.
* Nicht klickbare Elemente (fehlendes Konto, zu wenig Gold für den Tisch oder nicht genügend XP für den Tausch) werden visuell über einen **automatischen Graustufen-Filter** gesperrt.
* **Permanente Gold-Transparenz & Eigene Statistik-Ansicht:**
* Sobald ein Goldbeutel ausgewählt ist, wird das aktuelle Guthaben dauerhaft **sowohl oben rechts in der Topbar als auch prominent im Gold-Banner** des Kontomenüs angezeigt.
* Über den eigenen Button **`Statistiken`** in der Topbar öffnet sich `BlackjackStatsView` als dedizierte Ansicht zur Auswertung jedes einzelnen Goldbeutels (inkl. Tischfilter).
* **Fester Grundeinsatz (Ante):** Zu Beginn jeder Runde legt jeder Teilnehmer (Spieler & aktive Bots) exakt **10 Gold** Grundeinsatz in den gemeinsamen Pot.
* **Kartenverteilung:**
* Du erhältst 2 eigene Karten (für dich sichtbar, für Gegner verdeckt).
* Bis zu 3 KI-Gegner erhalten jeweils 2 verdeckte Karten.
* Der **Haus-Dealer** erhält 1 offene Karte (*Upcard*) und 1 verdeckte Karte (*Hole Card*).
* **Dealer-Regel:** Der Haus-Dealer muss bei **16 oder weniger** weitere Karten ziehen (*Hit*) und bleibt ab **17 bis 21** stehen (*Stand*).
* **No Surrender:** Ein vorzeitiges Aufgeben gegen halben Einsatz existiert nicht. Wer aussteigt, lässt sein gesamtes bisher gesetztes Gold im Pot zurück.
* **Sofortsieg `7-7-7`:** Hält ein Spieler oder Bot drei Siebenen (`7-7-7`), endet die Runde augenblicklich und der gesamte Pot geht sofort an diese Hand.
* **Tischvarianten:**
* **Klassisch (`bj_classic`):** 2 Decks, einfacher Level-Einsatzmultiplikator (`1x`), `1.0x` XP.
* **Hoher Einsatz (`bj_highstakes`):** 6 Decks, doppelter Level-Einsatzmultiplikator (`2x`), `1.45x` XP.
### 2. Devil's Gambit: Der 3-Stufen-Ablaufbaum & Auto-Showdown
Jeder Tisch-Umlauf merkt sich über `cycle_card_drawn`, ob mindestens ein aktiver Teilnehmer eine Karte genommen hat. Dadurch gibt es kein Endlos-Bieten: **Zieht in einem gesamten Tisch-Umlauf niemand eine neue Karte, wird automatisch aufgedeckt!** (Etwaige letzte offene Erhöhungen aus diesem Umlauf werden vorher nur noch über `SETTLE_BETS` per *Mitgehen* oder *Austreten* beglichen – ohne weiteres Ziehen oder Erhöhen.)
```text
+------------------+
| Tisch-Umlauf | (cycle_card_drawn = False zu Beginn jedes Umlaufs)
+---------+--------+
|
+---------v--------+
| Offene Erhöhung? +-- Nein -----------------------+
+---------+--------+ |
Ja |
| |
+---------v--------+ +----------v---------------+
| 1. Mitgehen? +--- Nein ---------->| AUSGETRETEN (Verloren! |
+---------+--------+ | Gold im Pot bleibt drin) |
Ja +----------+---------------+
| |
+---------v--------+ |
| 2. Ziehen? |<------------------------------+ (wenn kein Raise offen)
| (Hit/Double/Split|
| oder Keine K.) +-- Keine Karte -----+
+---------+--------+ |
Karte gezogen! |
(cycle_card_drawn = True) |
| |
+---------v--------+ | +------------------+
| Über 21? +--- Ja -------------+--------->| OUT! Überkauft |
+---------+--------+ | +--------+---------+
Nein | |
| | |
+---------v-----------------------------v-+ |
| 3. Erhöhen? +-- Ja -> Pot +! |
| (Chips skalieren mit Level) | | |
+---------+-------------------------------+ | |
Nein | |
| | |
+---------v-----------------------------------------v-------v-+
| Nächster Sitz am Tisch |
+-----------------------------+-------------------------------+
|
(Alle Sitze im Umlauf einmal durch?)
|
+----------------------+----------------------+
| |
[cycle_card_drawn == True] [cycle_card_drawn == False]
| (Keiner hat Karte gezogen!)
v |
Neuer Tisch-Umlauf Offene Raises begleichen
(SETTLE_BETS: Call / Fold)
|
v
AUTOMATISCHER SHOWDOWN
(Dealer zieht bis 16 / Stand 17)
```
#### Besondere Aktionen im Umlauf
* **Hit (Karte ziehen):** Zieht 1 Karte (`cycle_card_drawn = True`). Unter/gleich 21 geht es weiter zu Schritt 3 (*Erhöhen?*), über 21 ist die Hand sofort raus (*Bust*).
* **Double Down (Verdoppeln):** Nur bei genau 2 Startkarten möglich. Verdoppelt deinen Einsatz auf das Doppelte des aktuellen Tisch-Höchsteinsatzes, zieht **genau eine** Karte und sperrt die Hand für weitere Karten.
* **Split (Teilen):** Haben deine ersten beiden Karten denselben Blackjack-Wert, kannst du gegen einen zweiten Einsatz zwei getrennte Hände parallel weiterspielen.
* **Solo-Direktabschluss:** Spielst du allein ohne Bots und wählst *Keine neue Karte*, deckt der Tisch ohne unnötige Erhöhungs-Abfrage augenblicklich auf.
* **Level-skalierte Erhöhungen:** Während der Grundeinsatz beim Geben immer bei 10 Gold bleibt, wachsen deine vier Erhöhungs-Chips in Schritt 3 automatisch alle 5 Blackjack-Level (mit jedem neuen Prestige-Rang) mit.
### 3. KI-Gegner (Stufe 0 bis Gottheit)
Du kannst bis zu **3 Bots** gleichzeitig an den Tisch setzen:
* **Stufe 0 – Verwirrte Seele:** Unberechenbare Zufallszüge.
* **Stufe 1 – Akolyth:** Vorsichtiges Spiel, hält früh.
* **Stufe 2 – Nachtwanderer:** Solide Grundwerte, jagt bei zwei 7ern aktiv die `7-7-7`.
* **Stufe 3 – Schatten-Zocker:** Bezieht die offene Karte des Haus-Dealers ein.
* **Stufe 4 – Experte:** Spielt mathematische Basisstrategie (Dealer Stands on 17).
* **Stufe 5 – Großmeister:** Zählt alle offenen Karten per Hi-Lo-System (*Running & True Count*) über den gesamten Kartenschuh mit.
* **Stufe 6 – Gottheit (Gnadenlos / Online-Standard):** Nutzt vollständige *Illustrious-18*-Indexabweichungen, erhöht bei positivem True Count kompromisslos mit Maximal-Chips, nutzt aggressives Double-Down-Timing und steigt bei negativer Erwartung gegen teure Raises eiskalt aus.
### 4. Gold-Umtausch, Divine Punishment & The Devil's Deal
Sinkt ein Goldbeutel unter das Tischminimum von **10 Gold**, greift ein mehrstufiges System, das ausschließlich an dein **Blackjack-Level** gekoppelt ist:
1. **Regulärer Umtausch (bis einschl. `Schöpfergeist V`, bevor jemals `Gottheit` erreicht wurde):**
* Fester Kurs: **10.000 Blackjack-XP → +10 Gold**.
2. **Divine Punishment Mode (ab erstmaligem Erreichen von `Gottheit 1` / Level 1.296):**
* Ab sofort wird für jedes Level ab `Schöpfergeist V` dein realer XP-Durchschnitt pro Partie aufgezeichnet.
* **Strafkurs:** +10 Gold kosten das **10-Fache deines durchschnittlichen XP-Gewinns aus dem vorherigen Level** (z. B. Ø 34 Mio. XP auf `Schöpfergeist V` → **340 Mio. XP** für +10 Gold).
* **Harter Boden (Floor):** Du kannst durch *Divine Punishment* niemals auf Level 0 abstürzen, sondern fällst **maximal bis auf die exakte Unterkante von `Schöpfergeist V`** zurück.
3. **The Devil's Deal (Am Abgrund von `Schöpfergeist V`):**
* Stehst du ohne verbleibenden XP-Puffer auf der Untergrenze von `Schöpfergeist V`, sperrt sich der XP-Tausch und **The Devil's Deal** öffnet sich.
* **Seelen-Opfer:** Du kannst ein **anderes Seelen-Profil** aus der Datenbank opfern (unwiderruflich löschen!), sofern dieses andere Profil **in Blackjack mindestens Rang `Stütze I` (Level 421+)** erreicht hat. Dafür erhältst du **+10 Teufelsmünzen**.
* **Unausweichlicher Lock & Auto-Save:** Sobald die 10 Teufelsmünzen angenommen wurden, startet das Spiel sofort am gesperrten Tisch (`devils_deal_active = 1`). Alle Zurück-Buttons und anderen Spiele im Hauptmenü verschwinden. Nach **jedem einzelnen Klick** speichert das Spiel den kompletten Tischzustand in der Datenbank. Schließt du das Fenster, existiert beim nächsten Login ausschließlich **„Pakt fortsetzen (Resume)“**, bis der Pakt durch Sieg oder Bankrott entschieden ist!
### Modulstruktur (`games/blackjack/`)
```text
games/blackjack/
├── start.py # Einstiegspunkt & Devil's-Deal-Lock-Routing
├── README.md # Spielspezifische Dokumentation (DE/EN)
├── models/
│ ├── blackjack_engine.py # Spiel-Logik, Umlauf-Tracking, Split/Double & JSON-Serialisierung
│ ├── hand_evaluator.py # Punktberechnung, Soft-Hands, Blackjack & 7-7-7 Prüfung
│ ├── player_hand.py # Datenmodell für Spielerhände (inkl. Split-Status)
│ ├── bot_seat.py # Sitz- & Statusmodell für KI-Gegner
│ └── bot_ai.py # 3-Stufen-KI von Stufe 0 bis Stufe 6 (Gottheit / Hi-Lo Counter)
└── views/
├── blackjack_menu_view.py # Kontoverwaltung, Gold-Banner, Gegner-Setup & Tischwahl
├── blackjack_stats_view.py # Dedizierte Konto-Statistik-Ansicht pro Goldbeutel
├── blackjack_table_view.py # Spieltisch, 3-Knoten-Ablaufbaum, Auto-Showdown & Auto-Save
└── round_result_dialog.py # Runden-Auswertung mit Gewinn/Verlust-GIFs & Level-Up-Anzeige
```
---
## 🇬🇧 English
### Overview
**Blackjack – Devil's Gambit** fuses classic Vegas card rules with a ruthless multi-player gold pot, level-scaled bet raises, **Divine Punishment** at Deity rank, and the inescapable **Devil's Deal**.
### 1. Account Management, UI Logic & Core Rules
* **Deliberate Gold Pouch System (0–5 Accounts):**
* New Souls start cleanly with zero pre-created accounts. Only after explicitly creating a Gold Pouch (up to **5 independent pouches**, **1,000 Gold** starting balance each) do opponent setup, XP exchange, table entry, and account statistics unlock.
* Unavailable actions (no account created yet, insufficient gold for table entry, or insufficient XP for exchange) are visually locked using an **automatic grayscale dimming filter**.
* **Persistent Gold Visibility & Dedicated Stats View:**
* Once a pouch is active, your current Gold balance is permanently displayed **both in the topbar and inside a prominent Gold banner** within the account panel.
* Clicking **`Statistics`** in the topbar opens `BlackjackStatsView`, a dedicated full-screen statistics breakdown for each individual Gold Pouch (filterable by table variant).
* **Fixed Initial Ante:** Every participant (player & active bots) places a mandatory **10 Gold** entry ante into the shared pot when cards are dealt.
* **Dealing & Visibility:**
* You receive 2 cards (visible to you, hidden from opponents).
* Up to 3 AI opponents receive 2 hidden cards each.
* The **House Dealer** receives 1 face-up card (*Upcard*) and 1 face-down card (*Hole Card*).
* **Dealer Rule:** The House Dealer hits on **16 or less** and stands on **17 through 21**.
* **No Surrender:** Leaving a hand forfeits every coin you have already committed to the pot.
* **Instant `7-7-7` Victory:** Holding three Sevens (`7-7-7`) immediately ends the round and awards the entire pot to that hand.
* **Variants:**
* **Classic (`bj_classic`):** 2 decks, `1x` level chip scale, `1.0x` XP multiplier.
* **High Stakes (`bj_highstakes`):** 6 decks, `2x` level chip scale, `1.45x` XP multiplier.
### 2. Devil's Gambit: 3-Step Turn Flowchart & Auto-Showdown
Every table pass tracks `cycle_card_drawn` to prevent infinite raising loops: **if an entire pass around the table completes without anyone drawing a new card, the hand automatically proceeds to Showdown!** (If a final raise was made during that cardless pass, a quick `SETTLE_BETS` pass lets remaining contenders strictly *Match* or *Leave*—with no further drawing or re-raising—before revealing all hands.)
1. **Step 1 – Match Bet?** *(Only shown if an opponent raised)*
* Pay the deficit (`+{X} Gold`) to stay in the pot, or choose **No — Leave (Lost)** to forfeit your hand immediately.
* During a final `SETTLE_BETS` pass after a cardless cycle, matching immediately completes your action.
2. **Step 2 – Draw Card or No Card?** *(Skipped if at 21 or already Doubled)*
* Choose **Draw Card (Hit)**, **Double Down** (on 2 initial cards: doubles table bet, draws 1 card, locks hand), **Split** (on equal-value pair: places second bet to play two hands side-by-side), **No Card**, or **Leave**.
* Taking any card sets `cycle_card_drawn = True`. Exceeding 21 results in an immediate **Bust** and passes the turn.
* In solo play (0 bots), choosing **No Card** triggers the Showdown immediately without prompting for a raise.
3. **Step 3 – Raise Bet?**
* Pick one of your 4 **level-scaled raise chips** (scaling up every 5 Blackjack levels) to grow the pot and force opponents to match, or choose **No Raise** to pass to the next seat.
### 3. AI Personalities (Level 0 to Deity)
* **Level 0 – Lost Soul:** Unpredictable random decisions.
* **Level 1 – Acolyte:** Cautious play, stands early.
* **Level 2 – Nightwalker:** Solid fundamentals, actively chases `7-7-7` on paired Sevens.
* **Level 3 – Shadow Gambler:** Evaluates the House Dealer's upcard.
* **Level 4 – Expert:** Executes optimal Dealer-Stands-on-17 Basic Strategy.
* **Level 5 – Grandmaster:** Tracks the shoe using Hi-Lo card counting (*Running & True Count*).
* **Level 6 – Deity (Merciless / Online Standard):** Full *Illustrious-18* count index deviations, maximum value-raising pressure on strong hands/counts, optimal soft & hard Double Downs, and disciplined folds against unfavorable pot odds.
### 4. Gold Exchange, Divine Punishment & The Devil's Deal
When a pouch drops below the **10 Gold** table minimum, progression rules bound strictly to your **Blackjack level** apply:
1. **Standard Exchange (Before ever reaching `Deity 1`):**
* Fixed rate: **10,000 Blackjack XP → +10 Gold**.
2. **Divine Punishment Mode (Upon reaching `Deity 1` / Level 1,296+):**
* The game records your real average XP earned per match for every level starting at `Creator Spirit V`.
* **Punishment Rate:** +10 Gold costs **10x your average match XP from the previous level**.
* **Hard Floor:** Divine Punishment can never drop you to zero—your fall is strictly capped at the exact floor of **`Creator Spirit V`**.
3. **The Devil's Deal (At the floor of `Creator Spirit V`):**
* Once stranded at the bottom of `Creator Spirit V`, XP exchange locks and **The Devil's Deal** awakens.
* **Soul Sacrifice:** Permanently erase **another Soul profile** that has reached at least **`Support I` (Level 421+) in Blackjack** to receive **+10 Devil's Coins**.
* **No Escape & Per-Click Auto-Save:** Accepting the pact immediately locks you at the Blackjack table (`devils_deal_active = 1`). All exit buttons and other games are disabled, and every single button click auto-saves the entire table, shoe, and pot state to SQLite. Closing and reopening the app presents **Resume Pact** as your sole option until you either win your way free or lose the last coin!
### Module Structure (`games/blackjack/`)
```text
games/blackjack/
├── start.py # Module entry point & Devil's Deal lock routing
├── README.md # Game-specific manual (DE/EN)
├── models/
│ ├── blackjack_engine.py # Core rules, cycle tracking, Split/Double & JSON serialization
│ ├── hand_evaluator.py # Hand scoring, soft totals, natural Blackjack & 7-7-7 detection
│ ├── player_hand.py # Data model for player hands (incl. split tracking)
│ ├── bot_seat.py # Seat & status model for AI opponents
│ └── bot_ai.py # 3-step flowchart AI from Level 0 up to Level 6 (Deity counter)
└── views/
├── blackjack_menu_view.py # Account management, Gold banner, bot setup & variant cards
├── blackjack_stats_view.py # Dedicated per-pouch statistics screen
├── blackjack_table_view.py # Game table UI, 3-node turn state machine, auto-showdown & auto-save
└── round_result_dialog.py # Showdown modal with win/loss GIFs & level-up banner
```