예제 #1
0
 public BlackjackRequest(
     Player player,
     BlackjackAction action,
     BlackjackTable table,
     string message = "")
 {
     Player  = player;
     Action  = action;
     Table   = table;
     Message = message;
 }
예제 #2
0
파일: Player.cs 프로젝트: edfowle/blackjack
 public BlackjackActionResult Play(BlackjackAction action, Dealer dealer)
 {
     //perform the action specified for this player
     switch (action)
     {
         case BlackjackAction.Hit:
             GiveCard(dealer.TakeCard());
             break;
     }
     LastAction = action;
     return Bust ? BlackjackActionResult.Bust : BlackjackActionResult.Ok;
 }
예제 #3
0
        /// <summary>
        /// Performs a given turn
        /// </summary>
        /// <param name="c">The action that the player chose</param>
        /// <param name="onSplit">If the move is for the second hand in a split, set this to true. Otherwise, the default is false.</param>
        /// <returns>Returns false if the game should continue, true if the game should end.</returns>
        //TODO: the whole returning thing makes no sense. See below.
        // If the player chose to end the game, we should totally not be going into this method just to realize they chose that. We should end it there, in Game.
        public bool doTurn(BlackjackAction c, bool onSplit = false)
        {
            if (onSplit) {
                return SplitHand.doTurn(c);
            }

            switch (c) {
                case BlackjackAction.Hit:
                    Draw();
                    break;
                case BlackjackAction.Stand:
                    // taken care of in Game (Standing is a complete *lack* of action of the Player
                    break;
                case BlackjackAction.Split:
                    if (Count == 2 && CanSplit) {
                        Split();
                    }
                    break;
                case BlackjackAction.EndGame:
                    // also taken care of in Game - this is a high level action.
                    return true;
                default:
                    throw new ArgumentOutOfRangeException("What?");
            }
            return false;
        }