From a7f1ec667ce685191b5cc908dbf984101bb00972 Mon Sep 17 00:00:00 2001 From: cerberus Date: Mon, 27 Oct 2025 18:25:57 +0100 Subject: [PATCH] added charts --- docs/game_flowchart.md | 91 +++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 18 deletions(-) diff --git a/docs/game_flowchart.md b/docs/game_flowchart.md index 3182a01..1cb885a 100644 --- a/docs/game_flowchart.md +++ b/docs/game_flowchart.md @@ -1,37 +1,92 @@ -# Game flowchart +# Game flow + +## Flowchart ```mermaid flowchart TD - A[Start] --> B[Shuffle and deal cards] + A[Start] --> B[Shuffle deck and deal cards] B --> C[Player gets 2 cards, Dealer gets 1 face-up, 1 face-down] - C --> D{Dealer shows Ace or 10?} - D -- Yes --> E{Dealer has Blackjack?} + C --> D{Dealer shows Ace or 10} + D -- Yes --> E{Dealer has Blackjack} E -- Yes --> F[Dealer reveals face-down card] - F --> G{Player also has Blackjack?} + F --> G{Player also has Blackjack} G -- Yes --> P[Tie] G -- No --> L[Player loses] - D -- No --> H[Player turn] + D -- No --> H[Player turn begins] E -- No --> H - H --> I{Hit or Stand?} + H --> I{Hit or Stand} I -- Hit --> J[Player draws card] - J --> K{Player busts (>21)?} - K -- Yes --> L + J --> K{Player busts} + K -- Yes --> L[Player loses] K -- No --> H I -- Stand --> M[Player ends turn] M --> N[Dealer reveals face-down card] - N --> O{Dealer hand < 17?} + N --> O{Dealer hand < 17} O -- Yes --> P1[Dealer draws card] P1 --> O - O -- No --> Q{Dealer busts (>21)?} - Q -- Yes --> W1[Player wins 1:1] + O -- No --> Q{Dealer busts} + Q -- Yes --> W1[Player wins] Q -- No --> R[Compare hands] - R --> S{Player > Dealer?} - S -- Yes --> W2[Player wins 1:1 or 3:2] - S -- No --> T{Player = Dealer?} - T -- Yes --> P - T -- No --> L - L --> Z[End] + R --> S{Player > Dealer} + S -- Yes --> W2[Player wins] + S -- No --> T{Player = Dealer} + T -- Yes --> P[Tie] + T -- No --> L[Player loses] + L --> Z[End: update chips, new round] P --> Z W1 --> Z W2 --> Z ``` + +## Sequence Diagram + +```mermaid +sequenceDiagram + participant Player + participant Dealer + participant Game + + Game->>Player: Deal 2 cards + Game->>Dealer: Deal 1 face-up, 1 face-down + Dealer->>Game: Check for Blackjack + alt Dealer has Blackjack + Dealer->>Player: Reveal face-down card + alt Player also has Blackjack + Game->>Player: PUSH (Tie) + else Player does not have Blackjack + Game->>Player: Player loses + end + else No Blackjack + loop Player's turn + Player->>Game: Hit or Stand + alt Hit + Game->>Player: Deal card + Player->>Game: Check for bust + alt Bust + Game->>Player: Player loses + else Not bust + Player->>Game: Continue + end + else Stand + Player->>Game: End turn + end + end + Dealer->>Game: Reveal face-down card + loop Dealer draws until >= 17 + Dealer->>Game: Draw card + end + Dealer->>Game: Check for bust + alt Dealer busts + Game->>Player: Player wins + else Compare hands + alt Player > Dealer + Game->>Player: Player wins + else Player = Dealer + Game->>Player: PUSH (Tie) + else Dealer > Player + Game->>Player: Player loses + end + end + end + +```