Example #1
0
        public TexasHoldemGame(SystemUser user, MustPreferences gamePreferences, Action <int[]> rankMoneyUpdateCallback, Action <int[]> leaderBoardUpdateCallback)
        {
            firstJoin            = true;
            gameCreatorUserId    = user.id;
            this.gamePreferences = gamePreferences;
            pot                = 0;
            active             = true;
            deck               = new Deck();
            spectators         = new List <SystemUser>();
            gameStatesObserver = new GameObserver();
            spectateObserver   = new GameObserver();
            //setting the players array according to the max players pref if entered else 9 players is the max.
            maxPlayers = 9;
            MaxPlayersDecPref maxPlayersDec = (MaxPlayersDecPref)gamePreferences.getOptionalPref(new MaxPlayersDecPref(0, null));

            if (maxPlayersDec != null)
            {
                maxPlayers = maxPlayersDec.maxPlayers;
            }
            players        = new Player[maxPlayers];
            playersStats   = new LeaderboardsStats[maxPlayers];
            availableSeats = maxPlayers - 1;
            this.rankMoneyUpdateCallback = rankMoneyUpdateCallback;
            flop            = null;
            currentBlindBet = 20;

            gameOnChips = true;
            StartingAmountChipsCedPref startingChipsPref = (StartingAmountChipsCedPref)gamePreferences.getOptionalPref(new StartingAmountChipsCedPref(0, null));

            if (startingChipsPref != null)
            {
                if (startingChipsPref.startingChipsPolicy == 0)
                {
                    gameOnChips = false;
                }
            }

            gameId = getNextId();
            GameLog.setLog(gameId, DateTime.Now);
            GameLog.logLine(gameId, GameLog.Actions.Game_Create, gameId.ToString(), user.name, DateTime.Now.ToString());
            for (int i = 1; i < maxPlayers; i++)
            {
                players[i] = null;
            }
        }