コード例 #1
0
        /// <summary>
        /// Method checks the states of all players
        /// </summary>
        /// <returns>true if all players are busted or won the game; false - otherwise</returns>
        private bool CheckAllBustOrWon()
        {
            int k = 0;

            for (; k < game.GetPlayersCount(); k++)
            {
                if (game.GetPlayerState(k) != PlayerState.BUST && game.GetPlayer(k).PlayResult != PlayerResult.WIN)
                {
                    break;
                }
            }
            return(k == game.GetPlayersCount());
        }
コード例 #2
0
        /// <summary>
        /// Method draws:
        /// 1) results of the game for each player
        /// 2) the set of possible options for each player at the current moment
        /// 3) additional things such as the Blackjack sign and bust sign
        /// </summary>
        public void DrawOptions()
        {
            for (int i = 0; i < game.GetPlayersCount(); i++)
            {
                if (game.GetPlayer(i).PlayResult != PlayerResult.UNDEFINED)
                {
                    switch (game.GetPlayer(i).PlayResult)
                    {
                    case PlayerResult.WIN:
                        DrawResult(" WIN!", Color.LightGreen, Color.White, Color.Green, i);
                        break;

                    case PlayerResult.LOSE:
                        DrawResult("LOSE!", Color.LightBlue, Color.White, Color.Blue, i);
                        break;

                    case PlayerResult.STAY:
                        DrawResult("STAY!", Color.LightGoldenrodYellow, Color.Black, Color.Red, i);
                        break;
                    }
                }
                else if (game.GetPlayerState(i) == PlayerState.STAND)
                {
                    g.DrawImage(Properties.Resources.stand_fix, 60 + 105 * i, 285, 30, 30);
                }
                else
                {
                    g.DrawImage(Properties.Resources.hit, 25 + (15 + drawCardWidth) * i, 285, 30, 30);
                    g.DrawImage(Properties.Resources.stand, 60 + (15 + drawCardWidth) * i, 285, 30, 30);
                    g.DrawImage(Properties.Resources.double_down, 95 + (15 + drawCardWidth) * i, 285, 30, 30);
                }

                if (game.GetPlayerState(i) == PlayerState.BLACKJACK)
                {
                    g.DrawImage(Properties.Resources.blackjack_21, 90 + (15 + drawCardWidth) * i, 265, 40, 40);
                }
                if (game.GetPlayerState(i) == PlayerState.BUST)
                {
                    g.DrawImage(Properties.Resources.bust, 95 + (15 + drawCardWidth) * i, 265, 30, 30);
                }
            }
        }