/// <summary>
            /// The private constructor that gets called from the other two, allowing a custom startTime
            /// </summary>
            /// <param name="tableId"></param>
            /// <param name="numStartPlayers"></param>
            /// <param name="dealerPosition"></param>
            /// <param name="parentCache"></param>
            /// <param name="startTime"></param>
            private void handConstructor(long tableId, byte numStartPlayers, byte dealerPosition, databaseCache parentCache, DateTime startTime, int handRandomNumber)
            {
                this.parentCache     = parentCache;
                this.tableId         = tableId;
                this.numStartPlayers = numStartPlayers;
                this.dealerPosition  = dealerPosition;

                //Use defaults
                this.startTime = startTime;
                //this.endTime = startTime;
                this.potValue   = 0;
                this.tableCard1 = 0;
                this.tableCard2 = 0;
                this.tableCard4 = 0;
                this.tableCard3 = 0;
                this.tableCard5 = 0;
                //this.handErrorId = 1;

                this.cacheHandIndex   = parentCache.getNumHandsPlayed();
                this.handRandomNumber = handRandomNumber;

                databaseCache.databaseRAM.NewHand(this);

                parentCache.currentPokerHand = this;
            }
            /// <summary>
            /// Populates cache with hold cards and adds to the database submit queue.
            /// </summary>
            /// <param name="handId"></param>
            /// <param name="playerId"></param>
            /// <param name="holeCard1"></param>
            /// <param name="holeCard2"></param>
            public holeCard(long handId, long playerId, byte holeCard1, byte holeCard2, databaseCache parentCache)
            {
                this.parentCache = parentCache;

                this.handId    = handId;
                this.playerId  = playerId;
                this.holeCard1 = holeCard1;
                this.holeCard2 = holeCard2;
            }
            /// <summary>
            /// Populates the pokerPlayer object from values stored in the database
            /// </summary>
            /// <param name="playerId"></param>
            public pokerPlayer(long playerId, string playerName, bool isBot, databaseCache parentCache)
            {
                this.parentCache = parentCache;

                this.playerId      = playerId;
                this.playerName    = playerName;
                this.pokerClientId = parentCache.PokerClientId;
                this.isBot         = isBot;
            }
 /// <summary>
 /// Adds a player to the tablePlayer object which does not already exist in the database
 /// </summary>
 /// <param name="tableId"></param>
 /// <param name="playerId"></param>
 /// <param name="stack"></param>
 /// <param name="position"></param>
 /// <param name="isDead"></param>
 public tablePlayer(long tableId, long playerId, decimal stack, byte position, bool isDead, databaseCache parentCache)
 {
     this.tableId     = tableId;
     this.playerId    = playerId;
     this.stack       = stack;
     this.position    = position;
     this.isDead      = isDead;
     this.parentCache = parentCache;
 }
            private void actionConstructor(long handId, long playerId, byte actionTypeId, decimal actionValue, databaseCache parentCache)
            {
                //ActionId will not be known until the entry is committed to the database so should not be used client side
                this.parentCache  = parentCache;
                this.handId       = handId;
                this.playerId     = playerId;
                this.actionTypeId = actionTypeId;
                this.actionValue  = actionValue;

                //Set the localindex
                //We don't have to worry about multithreading here because we can only ever do things serially for an individual table
                localSeqIndex = parentCache.currentPokerHand.NextSeqIndex();
            }
            /// <summary>
            /// Populates the handAction object from provided values (a shortcut without database!)
            /// </summary>
            /// <param name="actionId"></param>
            /// <param name="handId"></param>
            /// <param name="playerId"></param>
            /// <param name="actionTypeId"></param>
            /// <param name="actionTime"></param>
            /// <param name="actionValue"></param>
            public handAction(long handId, byte seqIndex, long playerId, byte actionTypeId, decimal actionValue, databaseCache parentCache)
            {
                this.parentCache = parentCache;
                if (seqIndex == 0 || handId == 0 || playerId == 0)
                {
                    throw new Exception("This constructor can only be used if all values are known.");
                }

                this.localSeqIndex = seqIndex;
                this.handId        = handId;
                this.playerId      = playerId;
                this.actionTypeId  = actionTypeId;
                this.actionValue   = actionValue;
            }
            /// <summary>
            /// Create a new poker table which does not exist in the database
            /// </summary>
            /// <param name="pokerClientId"></param>
            /// <param name="littleBlind"></param>
            /// <param name="bigBlind"></param>
            /// <param name="maxStack"></param>
            /// <param name="tableRef"></param>
            public pokerTable(short pokerClientId, decimal littleBlind, decimal bigBlind, decimal maxStack, string tableRef, byte numSeats, byte dataSource, databaseCache parentCache, int tableRandomNumber)
            {
                //Create this table in the DatabaseCache instance
                this.pokerClientId = pokerClientId;
                //this.startTime = DateTime.Now;
                //this.endTime = this.startTime;
                this.littleBlind = littleBlind;
                this.bigBlind    = bigBlind;
                this.maxStack    = maxStack;
                this.tableRef    = tableRef;
                this.numSeats    = numSeats;
                this.parentCache = parentCache;
                this.dataSource  = dataSource;

                this.tableRandomNumber = tableRandomNumber;

                databaseCache.databaseRAM.NewPokerTable(this);
            }
            /// <summary>
            /// If the player already exists in the database, pokerPlayer object is populated. If player does not exist, a new player is created and pokerPlayer object is populated.
            /// </summary>
            /// <param name="playerId"></param>
            /// <param name="botConfigId"></param>
            /// <param name="playerName"></param>
            /// <param name="pokerClientId"></param>
            public pokerPlayer(string playerName, short pokerClientId, databaseCache parentCache)
            {
                this.parentCache = parentCache;
                PokerPlayer pokerPlayers = databaseQueries.playerDetailsByPlayerName(playerName, pokerClientId);

                if (pokerPlayers != null)
                {
                    //Player already exists, populate pokerPlayer object
                    this.playerId      = pokerPlayers.PlayerId;
                    this.playerName    = pokerPlayers.PlayerName;
                    this.pokerClientId = pokerPlayers.PokerClientId;
                    this.isBot         = (pokerPlayers.AiType == AIGeneration.NoAi_Human ? false : true);
                }
                else
                {
                    //Player does not exist, so create new player
                    this.playerName    = playerName;
                    this.pokerClientId = pokerClientId;
                    this.isBot         = false;

                    this.playerId = databaseQueries.CreateNewNonBotPlayer(playerName, pokerClientId);
                }
            }
 /// <summary>
 /// Adds an action to the handAction object and adds it to the database insert queue using a provided actionTime
 /// </summary>
 /// <param name="handId"></param>
 /// <param name="playerId"></param>
 /// <param name="actionTypeId"></param>
 /// <param name="actionValue"></param>
 /// <param name="parentCache"></param>
 /// <param name="actionTime"></param>
 public handAction(long handId, long playerId, byte actionTypeId, decimal actionValue, databaseCache parentCache)
 {
     //ActionId will not be known until the entry is committed to the database so should not be used client side
     actionConstructor(handId, playerId, actionTypeId, actionValue, parentCache);
 }
 /// <summary>
 /// Populates pokerHand object and adds data to database immediately.
 /// </summary>
 /// <param name="handId"></param>
 /// <param name="tableId"></param>
 /// <param name="startTime"></param>
 /// <param name="numStartPlayers"></param>
 /// <param name="dealerPosition"></param>
 public pokerHand(long tableId, byte numStartPlayers, byte dealerPosition, databaseCache parentCache, DateTime startTime, int handRandomNumber)
 {
     handConstructor(tableId, numStartPlayers, dealerPosition, parentCache, startTime, handRandomNumber);
 }