Пример #1
0
        /// <summary>
        /// Called by a client which needs to manually draw cards. Default implementation selects random cards.
        /// </summary>
        /// <param name="player">The automated player</param>
        /// <param name="action">The drawing action which must be modified to pass the strategy decision</param>
        public virtual void Draw(Player player, PlayerDrawingAction action)
        {
            Random rand = new Random();

            int drawCount = rand.Next(3);

            for (int i = 0; i < drawCount; ++i)
            {
                action.DrawnCards.Add(player.Cards[rand.Next(player.Cards.Count)]);
            }
        }
Пример #2
0
        /// <summary>
        /// A method which is used to get the player drawing action. Derived classes must override this method to perform the action.
        /// </summary>
        /// <param name="player">The player which may draw new cards</param>
        /// <param name="action">The drawing action which must be updated with the player drawing selection</param>
        public void WaitPlayerDrawingAction(Player player, PlayerDrawingAction action)
        {
            Player safeCopy = GetSafePlayer(player);

            forEachBut(player, (cur) => cur.NotifyPlayerIsThinking(safeCopy));
            PlayerDrawingAction result = waitAction <PlayerDrawingAction>(player, (cur) => cur.WaitPlayerDrawingAction(player, action));

            // when the request failed, draw 0 cards
            if (result != null && result.DrawnCards != null)
            {
                action.DrawnCards.AddRange(result.DrawnCards.Distinct());
                forEachBut(player, (cur) => cur.NotifyPlayerDraws(safeCopy, action.DrawnCards.Count));
            }
        }
Пример #3
0
        /// <summary>
        /// Called by the client to get the player drawing response.
        /// </summary>
        /// <param name="player">The player which draws the cards</param>
        /// <param name="action">The action which should be modified according to the player actions</param>
        public void WaitPlayerDrawingAction(Player player, PlayerDrawingAction action)
        {
            PrintPlayer(player);
            Console.WriteLine("=======================");
            Console.WriteLine("{0}, which cards would you like to draw?", player.Name);
            // prompt the user for the cards to draw:
            string[] numbers = Console.ReadLine().Split(',');
            // only 3 cards are allowed to draw
            int         max        = Math.Min(numbers.Length, 3);
            List <Card> drawnCards = action.DrawnCards;

            for (int j = 0; j < max; ++j)
            {
                int curCard;
                // skip unknown card format
                if (int.TryParse(numbers[j], out curCard))
                {
                    --curCard;
                    drawnCards.Add(player.Cards[curCard]);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Called by a client which needs to manually draw cards. Draws the cards which are not part of the best hand.
        /// </summary>
        /// <param name="player">The automated player</param>
        /// <param name="action">The drawing action which must be modified to pass the strategy decision</param>
        public override void Draw(Player player, PlayerDrawingAction action)
        {
            // get the player best hand
            lastHand = client.GetBestHand(player.Cards);
            // the other cards holder
            List <Card> otherCards = new List <Card>();
            // get all of the hand cards
            IEnumerator <Card> allCards = lastHand.GetAllCards();

            while (allCards.MoveNext())
            {
                if (!lastHand.Contains(allCards.Current))
                {
                    otherCards.Add(allCards.Current);
                }
            }
            // sort the other cards by value, the order is ascending
            otherCards.Sort();
            // can draw at most 3 cards:
            int max = Math.Min(3, otherCards.Count);

            // draw the first (max) cards out of the other cards:
            action.DrawnCards.AddRange(otherCards.Take(max));
        }
Пример #5
0
 /// <summary>
 /// A method which is used to get the player drawing action. Derived classes must override this method to perform the action.
 /// </summary>
 /// <param name="player">The player which may draw new cards</param>
 /// <param name="action">The drawing action which must be updated with the player drawing selection</param>
 protected override void WaitPlayerDrawingAction(Player player, PlayerDrawingAction action)
 {
     helper.WaitPlayerDrawingAction(player, action);
 }
Пример #6
0
 /// <summary>
 /// Called by the client to get the player drawing response.
 /// </summary>
 /// <param name="player">The player which draws the cards</param>
 /// <param name="action">The action which should be modified according to the player actions</param>
 public void WaitPlayerDrawingAction(Player player, PlayerDrawingAction action)
 {
     currentStrategy.Draw(player, action);
 }
Пример #7
0
 /// <summary>
 /// Called by the client to get the player drawing response.
 /// </summary>
 /// <param name="player">The player which draws the cards</param>
 /// <param name="action">The action which should be modified according to the player actions</param>
 public void WaitPlayerDrawingAction(Player player, PlayerDrawingAction action)
 {
     helper.WaitPlayerDrawingAction(player, action);
 }
Пример #8
0
 /// <summary>
 /// A method which is used to get the player drawing action. Derived classes must override this method to perform the action.
 /// </summary>
 /// <param name="player">The player which may draw new cards</param>
 /// <param name="action">The drawing action which must be updated with the player drawing selection</param>
 public PlayerDrawingAction WaitPlayerDrawingAction(Player player, PlayerDrawingAction action)
 {
     checkDrawingStarted();
     fiveCardConcreteClient.WaitPlayerDrawingAction(player, action);
     return(action);
 }
Пример #9
0
 /// <summary>
 /// A method which is used to get the player drawing action. Derived classes must override this method to perform the action.
 /// </summary>
 /// <param name="player">The player which may draw new cards</param>
 /// <param name="action">The drawing action which must be updated with the player drawing selection</param>
 public void WaitPlayerDrawingAction(PokerEngine.Player player, PlayerDrawingAction action)
 {
     concreteHelper.WaitPlayerDrawingAction(player, action);
 }
Пример #10
0
 /// <summary>
 /// Called by a client which needs to manually draw cards. Draws no cards
 /// </summary>
 /// <param name="player">The automated player</param>
 /// <param name="action">The drawing action which must be modified to pass the strategy decision</param>
 public override void Draw(Player player, PlayerDrawingAction action)
 {
 }