예제 #1
0
 public void PlayedCard(Card mCard)
 {
     mCard.LastPlayer = this;
     Game.Table.Add(mCard);
     Hand.Remove(mCard);
     Game.OutOfGame.Add(mCard);
 }
예제 #2
0
        public void GiveCardByDeal(Card mCard, bool hidden)
        {
            Hand.Add(mCard);

            if (hidden == false)
            {
                KnownCards.Add(mCard);
            }
        }
예제 #3
0
        public static bool IsCardUnbeatable(Card mCard)
        {
            int cardRank = mCard.Rank;
            List<Card> outOfGameCardsThatBeat = new List<Card>();

            foreach (Card card in Game.OutOfGame)
            {
                if (card.Suit == mCard.Suit)
                {
                    if (card.IsWinnerAgainst(mCard))
                    {
                        outOfGameCardsThatBeat.Add(card);
                    }
                }
            }

            outOfGameCardsThatBeat.Sort(
                delegate(Card p1, Card p2)
                {
                    return p1.Rank.CompareTo(p2.Rank);
                }
            );

            outOfGameCardsThatBeat.Reverse();

            int currentRank = cardRank - 1;

            foreach (Card card in outOfGameCardsThatBeat)
            {
                if (currentRank < 0)
                {
                    return true;
                }

                if (card.Rank == currentRank)
                {
                    currentRank--;
                }
                else
                {
                    return false;
                }
            }

            return false;
        }
예제 #4
0
        public void NextPlayCard(Card mCardToPlay)
        {
            GameForm.AddLog(string.Format("{0} plays {1}", CurrentPlayer.Name, mCardToPlay.ToString()));

            CurrentPlayer.PlayedCard(mCardToPlay);

            bool lastPlayer = (Table.Count == Players.Count);

            if (lastPlayer)
            {
                Card bestCard = Table.First();

                for (int i = 0; i < Table.Count; i++)
                {
                    if (Table[i].IsWinnerAgainst(bestCard))
                        bestCard = Table[i];
                }

                Player winnerPlayer = bestCard.LastPlayer;

                GameForm.AddLog(string.Format("{0} is the best card, played by {1}", bestCard.ToString(), winnerPlayer.Name));

                for (int index = 0; index < Table.Count; index++)
                {
                    Card card = Table[index];
                    winnerPlayer.Taken.Add(card);
                    GameForm.AddLog(string.Format("{0} wins {1}", winnerPlayer.Name, card.ToString()));
                }

                Table.Clear();

                NextPlayer(winnerPlayer);
                NextDeal();
            }
            else
            {
                NextPlayer();
            }
        }