From 2b86bcf8360a216f43d008115126a83c7cfe18b2 Mon Sep 17 00:00:00 2001
From: Dominic Masters <dominic@domsplace.com>
Date: Mon, 27 Sep 2021 15:21:25 -0700
Subject: [PATCH] Fixed more betting bugs.

---
 src/game/poker/actions/bet.c     |  2 +-
 src/game/poker/actions/flop.c    | 11 +++++++----
 src/game/poker/pokerdiscussion.c |  7 +++++++
 src/poker/poker.c                |  2 ++
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/game/poker/actions/bet.c b/src/game/poker/actions/bet.c
index c5325165..8f9086f8 100644
--- a/src/game/poker/actions/bet.c
+++ b/src/game/poker/actions/bet.c
@@ -31,7 +31,7 @@ void _pokerGameActionBetOnUpdate(
   
   // Are they human?
   player = game->poker.players + game->poker.bet.better;
-  isHuman = game->poker.bet.better == POKER_PLAYER_HUMAN_INDEX;
+  isHuman = game->poker.bet.better == POKER_PLAYER_HUMAN_INDEX && false;
 
   // Handle as an AI
   if(isHuman) {
diff --git a/src/game/poker/actions/flop.c b/src/game/poker/actions/flop.c
index 1ec1f7bd..9a5ab06a 100644
--- a/src/game/poker/actions/flop.c
+++ b/src/game/poker/actions/flop.c
@@ -22,21 +22,24 @@ void _pokerGameActionFlopOnStart(
     // Add the actual flop action.
     next = pokerActionNextFlopAdd(queue, &game->poker);
 
+    // Reset all the players 
+
     // Is there any flop "left to do" ?
     if(next != NULL) {
       // Talk about it.
       discussion.reason = POKER_DISCUSSION_REASON_FLOP;
       pokerDiscussionQueue(&discussion);
+      
+      // Reset the better to the betting round initial.
+      pokerBetResetBetter(
+        &game->poker.bet, game->poker.players, game->poker.roundSmallBlind
+      );
 
       // Now, get the count of players left to bet. If "everyone is all in" then
       // this will be 0 and no actual betting needs to happen.
       if(pokerBetGetRemainingPlayerCount(
         &game->poker.bet, game->poker.players
       ) > 1) {
-        // Reset the better to the betting round initial.
-        pokerBetResetBetter(
-          &game->poker.bet, game->poker.players, game->poker.roundSmallBlind
-        );
 
         // Begin betting.
         pokerGameActionLookAdd(game, game->poker.bet.better);
diff --git a/src/game/poker/pokerdiscussion.c b/src/game/poker/pokerdiscussion.c
index 77804a18..516b8892 100644
--- a/src/game/poker/pokerdiscussion.c
+++ b/src/game/poker/pokerdiscussion.c
@@ -92,6 +92,13 @@ void pokerDiscussionGet(
       discussion->emotions[0] = VN_CHARACTER_EMOTION_ANIME_MOM;
       break;
 
+    case POKER_DISCUSSION_REASON_BETTING_DONE:
+      discussion->count++;
+      discussion->messages[0] = "Winner Winner Chicken Dinner";
+      discussion->players[0] = POKER_DEALER_INDEX;
+      discussion->emotions[0] = VN_CHARACTER_EMOTION_SMUG_VERY;
+      break;
+
     // Fallback
     default:
       discussion->count++;
diff --git a/src/poker/poker.c b/src/poker/poker.c
index 58a21756..3c7b322c 100644
--- a/src/poker/poker.c
+++ b/src/poker/poker.c
@@ -14,6 +14,8 @@ void pokerGameWin(poker_t *poker) {
   int32_t chipsRounded, chipsDifferent;
   float chipsEach;
 
+  poker->state = POKER_STATE_DECIDING_WINNER;
+
   // Get the chips each.
   chipsEach = poker->bet.pot / ((float)poker->winner.winnerCount);