Пример #1
0
        public void GetValue_ShouldReturnCorrectResult_ForTwoCards(Ranks rank1, Ranks rank2, int expectedValue, Hand hand, Suits suit)
        {
            hand.AddCard(rank1.Of(suit));
            hand.AddCard(rank2.Of(suit));

            Assert.Equal(expectedValue, hand.GetValue());
        }
Пример #2
0
 public Table(int max, Suits suit)
 {
     _attackCard = new List<Card>();
     _defenceCard = new List<Card>();
     _maxAttackCard = max;
     _suit = suit;
 }
Пример #3
0
        private double GetHeuristicHandStrength(Player currentPlayer, Suits trump)
        {
            double predictionOfTricks = 0;

            foreach(Card card in currentPlayer.hand.Cards)
            {
                predictionOfTricks += (int)card.Number - 1;//2 is card rank 1, 3 is card rank 2, ..., king is card rank 12, ace is card rank 13
                if(card.Suit == trump)
                {
                    predictionOfTricks += 39;//trump is stronger than all other suits(13 * 3 = 39)
                }
            }
            //return predictionOfTricks / 52;//divide by total amount of cards(chance of card winning a trick)      this works better for worse cards
            return predictionOfTricks / 598 * 13;//all trumpvalues added equals 598(max value of cards in hand)     this works better for better cards

            //double heuristicHandStrength = 0;
            //for (int i = 0; i < 13; i++)
            //{
            //    heuristicHandStrength += (int)currentPlayer.hand.Cards[i].Number;
            //    if (currentPlayer.hand.Cards[i].Suit == trump)
            //    {
            //        heuristicHandStrength += 13;
            //    }
            //}
            //sum of all cardStrengths = (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14) * 3 + (15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27) = 585
            //your handStrength / sum of all cardStrengths * #tricks = statistical average number of tricks you will make in unlimited # games
            //return heuristicHandStrength / 273 * 13; 273 is sum of all trump values
        }
Пример #4
0
       // Card constructor using enumerated types.
       public Card (Suits suit, Rank rank)
       {
           this.suit = suit;
           this.rank = rank;
           description = this.ToString().ToLower().Replace(" ", "_");
 
       }
Пример #5
0
 public Card(int value, Suits givenSuits)
 {
     _suits = givenSuits;
     if (value >= 2 && value <= 14)
         Value = value;
     else
         throw new ArgumentOutOfRangeException("Card Constructor Error", "Card constructor recieved a value that was either < 2 or > 14.");
 }
Пример #6
0
        internal Card(Suits suit, int number)
        {
            if (number > 14 || number < 2)
            {
                throw new ArgumentOutOfRangeException("Number must be between 2 and 14, but instead was: " + number);
            }

            Suit = suit;
            Number = number;
        }
Пример #7
0
        public Card(Suits suit, int rank)
        {
            if (rank <= 0 || rank >= 14)
            {
                throw new ArgumentOutOfRangeException("Rank");
            }

            Rank = rank;
            Suit = suit;
        }
Пример #8
0
 public static bool DoesCardMatch(Card cardToCheck, Suits suit)
 {
     if (cardToCheck.Suit == suit)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #9
0
        private static int GetHandStrength(Player player, Suits trump)
        {
            int handStrength = 0;

            var cards = player.hand.Cards;
            var kingsAndAces = cards.Where(c => c.Number == Numbers.ACE || c.Number == Numbers.KING);
            handStrength += kingsAndAces.Count();
            var trumps = cards.Where(c => c.Suit == trump);
            handStrength += trumps.Except(kingsAndAces).Count();

            return handStrength;
        }
Пример #10
0
 public static string ToString(Suits suit)
 {
     switch (suit) {
         case Suits.Clubs:
             return "C";
         case Suits.Diamonds:
             return "D";
         case Suits.Hearts:
             return "H";
         case Suits.Spades:
             return "S";
         default:
             throw new InvalidEnumArgumentException(suit.ToString());
     }
 }
Пример #11
0
        public bool HasBeenRuffed(Suits suit)
        {
            for (int trick = 1; trick < this.currentTrick; trick++)
            {
                if (this.CardPlayed(trick, 1).Suit == suit)
                {               // the suit has been led in this trick
                    for (int manInTrick = 2; manInTrick <= 4; manInTrick++)
                    {
                        if (this.CardPlayed(trick, manInTrick).Suit == this.Trump)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #12
0
        /// <summary>
        /// 创建一副牌
        /// </summary>
        private static void CreateDeck(this DeckComponent self)
        {
            //创建普通扑克
            for (int color = 0; color < 4; color++)
            {
                for (int value = 0; value < 13; value++)
                {
                    Weight w    = (Weight)value;
                    Suits  s    = (Suits)color;
                    Card   card = new Card(w, s);
                    self.library.Add(card);
                }
            }

            //创建大小王扑克
            self.library.Add(new Card(Weight.SJoker, Suits.None));
            self.library.Add(new Card(Weight.LJoker, Suits.None));
        }
        public string MArk(Suits cardSuit)
        {
            switch (cardSuit)
            {
            case Suits.Diamonds:
                return("♦");

            case Suits.Hearts:
                return("♥");

            case Suits.Clubs:
                return("♠");

            case Suits.Spades:
                return("♣");
            }
            return("");
        }
Пример #14
0
        public static string ToParser(this Suits value)
        {
            switch (value)
            {
            case Suits.Clubs: return("C");

            case Suits.Diamonds: return("D");

            case Suits.Hearts: return("H");

            case Suits.Spades: return("S");

            case Suits.NoTrump: return("N");

            default:
                throw new FatalBridgeException(string.Format("SuitConverter.ToParser: unknown suit: {0}", value));
            }
        }
Пример #15
0
        public static string ToString(this Suits value)
        {
            switch (value)
            {
            case Suits.Clubs: return(LocalizationResources.Clubs.Substring(0, 1));

            case Suits.Diamonds: return(LocalizationResources.Diamonds.Substring(0, 1));

            case Suits.Hearts: return(LocalizationResources.Hearts.Substring(0, 1));

            case Suits.Spades: return(LocalizationResources.Spades.Substring(0, 1));

            case Suits.NoTrump: return(LocalizationResources.NoTrump);

            default:
                throw new FatalBridgeException(string.Format("SuitConverter.ToString: unknown suit: {0}", value));
            }
        }
Пример #16
0
        public static string ToCustomSymbol(this Suits me)
        {
            switch (me)
            {
            case Suits.Spade:
                return("♠");

            case Suits.Club:
                return("♣");

            case Suits.Diamond:
                return("♦");

            case Suits.Heart:
                return("♥");
            }
            return(null);
        }
Пример #17
0
        public void BuildDeck()
        {
            if (Cards.Count > 1)
            {
                Cards.Clear();
            }

            for (int i = 0; i < DECK_SIZE; i++)
            {
                Suits suits = (Suits)(Math.Floor((decimal)i / 13));
                int   value = i % 13 + 1;
                Cards.Add(new PlayingCard(value, suits));
            }

            DeckCount = Cards.Count;

            CheckForDuplicates();
        }
Пример #18
0
        public static string ToLocalizedString(this Suits value)
        {
            switch (value)
            {
            case Suits.Clubs: return(LocalizationResources.Clubs);

            case Suits.Diamonds: return(LocalizationResources.Diamonds);

            case Suits.Hearts: return(LocalizationResources.Hearts);

            case Suits.Spades: return(LocalizationResources.Spades);

            case Suits.NoTrump: return(LocalizationResources.NoTrump);

            default:
                throw new FatalBridgeException($"SuitConverter.ToString: unknown suit: {value}");
            }
        }
 //Constructor
 public Card(char value, CardSuit suit)
     : this()
 {
     if (!Suits.Contains(suit))
     {
         throw new Exception("Invalid Suite");
     }
     else if (value < CharJoker)
     {
         value = CharJoker;
     }
     value = char.ToLower(value);
     Value = value;
     if (Rank > 13 || Rank < 0)
     {
         throw new Exception("Invalid Card Value");
     }
     Suit = suit;
 }
Пример #20
0
        private void SeatSuit2String(Seats seat, Suits suit, StringBuilder result)
        {
            result.Append(SuitHelper.ToXML(suit) + " ");
            int length = 0;

            for (Ranks rank = Ranks.Ace; rank >= Ranks.Two; rank--)
            {
                if (this.Owns(seat, suit, rank))
                {
                    result.Append(Rank.ToXML(rank));
                    length++;
                }
            }

            for (int l = length + 1; l <= 13; l++)
            {
                result.Append(" ");
            }
        }
Пример #21
0
        public string ChoseCard(string input, Suits suits)
        {
            {
                foreach (var card in cards.Where(c => c.Equals(input.ToUpper())))
                {
                    if (suits != Suits.INVALID)
                    {
                        string result = string.Format("{0} of {1}", card, suits);
                        return(result);
                    }
                    else
                    {
                        return("Must be a valid value!");
                    }
                }
            }

            return("Must be a valid value!");
        }
Пример #22
0
        public override void HandleCardPlayed(Seats source, Suits suit, Ranks rank)
        {
            //Log.Trace("BoardResultEventPublisher({3}).HandleCardPlayed: {0} played {2}{1}", source, suit.ToXML(), rank.ToXML(), this.Owner);

            //if (!this.theDistribution.Owns(source, card))
            //  throw new FatalBridgeException(string.Format("{0} does not own {1}", source, card));
            /// 18-03-08: cannot check here: hosted tournaments get a card at the moment the card is played
            ///

            if (this.Play == null)      // this is an event that is meant for the previous boardResult
            {
                throw new ArgumentNullException("this.Play");
            }

            if (source != this.Play.whoseTurn)
            {
                throw new ArgumentOutOfRangeException("source", "Expected a card from " + this.Play.whoseTurn);
            }

            base.HandleCardPlayed(source, suit, rank);
            if (this.Play.PlayEnded)
            {
                //Log.Trace("BoardResultEventPublisher({0}).HandleCardPlayed: play finished", this.Owner);
                this.EventBus.HandlePlayFinished(this);
            }
            else
            {
                if (!this.dummyVisible)
                {
                    this.dummyVisible = true;
                    this.EventBus.HandleNeedDummiesCards(this.Play.whoseTurn);
                }
                else if (this.Play.TrickEnded)
                {
                    this.EventBus.HandleTrickFinished(this.Play.whoseTurn, this.Play.Contract.tricksForDeclarer, this.Play.Contract.tricksForDefense);
                    this.NeedCard();
                }
                else
                {
                    this.NeedCard();
                }
            }
        }
Пример #23
0
 private Image GetImageSuit(Suits suit)
 {
     if (suit == Suits.Clubs)
     {
         return(Resources.CLUBS);
     }
     else if (suit == Suits.Diamonds)
     {
         return(Resources.DIAMONDS);
     }
     else if (suit == Suits.Hearts)
     {
         return(Resources.HEARTS);
     }
     else
     {
         return(Resources.SPADES);
     }
 }
Пример #24
0
        private void PopulateWithCards()
        {
            int currentIndexOfDeck = 0;

            for (int suit = 0; suit < Common.NumberOfSuits; suit++)
            {
                for (int rank = 2; rank < Common.NumberOfCardsRanks + 2; rank++)
                {
                    Suits     cardSuit = (Suits)suit;
                    CardsRank cardRank = (CardsRank)rank;

                    string cardImagePath = this.CardsImagesLocation + cardRank + cardSuit + ".png";
                    Image  cardImage     = Image.FromFile(cardImagePath);

                    this.cards[currentIndexOfDeck] = new Card(cardSuit, cardRank, cardImage);
                    currentIndexOfDeck++;
                }
            }
        }
Пример #25
0
 public static char GetSuitChar(Suits s)
 {
     if (s == Suits.SPADES)
     {
         return('S');
     }
     if (s == Suits.CLUBS)
     {
         return('C');
     }
     if (s == Suits.DIAMONDS)
     {
         return('D');
     }
     else
     {
         return('H');
     }
 }
Пример #26
0
        // Converts Suits to user friendly strings that are printed on the console
        public static char ToDisplayString(Suits suit)
        {
            switch (suit)
            {
            case Suits.Clubs:
                return('♣');

            case Suits.Diamonds:
                return('♦');

            case Suits.Hearts:
                return('♥');

            case Suits.Spades:
                return('♠');

            default:
                return(' ');
            }
        }
Пример #27
0
        private List <Card> CreateSuit(Suits suit)
        {
            var newSuit = new List <Card>();

            newSuit.Add(new Card(suit, CardValue.Ace));
            newSuit.Add(new Card(suit, CardValue.Two));
            newSuit.Add(new Card(suit, CardValue.Three));
            newSuit.Add(new Card(suit, CardValue.Four));
            newSuit.Add(new Card(suit, CardValue.Five));
            newSuit.Add(new Card(suit, CardValue.Six));
            newSuit.Add(new Card(suit, CardValue.Seven));
            newSuit.Add(new Card(suit, CardValue.Eight));
            newSuit.Add(new Card(suit, CardValue.Nine));
            newSuit.Add(new Card(suit, CardValue.Ten));
            newSuit.Add(new Card(suit, CardValue.Jack));
            newSuit.Add(new Card(suit, CardValue.Queen));
            newSuit.Add(new Card(suit, CardValue.King));

            return(newSuit);
        }
Пример #28
0
        public static string ToString(Suits suit)
        {
            switch (suit)
            {
            case Suits.Clubs:
                return("C");

            case Suits.Diamonds:
                return("D");

            case Suits.Hearts:
                return("H");

            case Suits.Spades:
                return("S");

            default:
                throw new InvalidEnumArgumentException(suit.ToString());
            }
        }
Пример #29
0
        /// <summary>
        /// assigns string name to a card from enum and int
        /// </summary>
        /// <param name="suit"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private string NameCard(Suits suit, int rank)
        {
            switch (rank)
            {
            case 11:
                return("Jack of " + suit);

            case 12:
                return("Queen of " + suit);

            case 13:
                return("King of " + suit);

            case 14:
                return("Ace of " + suit);

            default:
                return(rank + " of " + suit);
            }
        }
Пример #30
0
        public VideoClip GetAnimationVideo(Suits Suit, Values Value)
        {
            switch ((int)Suit - 1)
            {
            case 0:
                return(Spades[(int)Value - 1]);

            case 1:
                return(Diamonds[(int)Value - 1]);

            case 2:
                return(Hearts[(int)Value - 1]);

            case 3:
                return(Clubs[(int)Value - 1]);

            default:
                return(null);
            }
        }
Пример #31
0
 /// <summary>
 /// 创建n副牌
 /// </summary>
 void CreateDeck(int deck_count)
 {
     library.Clear();
     //指定几副牌
     for (int i = 0; i < deck_count; i++)
     {
         //创建普通扑克
         for (int color = 0; color < 4; color++)
         {
             for (int value = 1; value < 14; value++)
             {
                 Weight w    = (Weight)value;
                 Suits  s    = (Suits)color;
                 string name = s.ToString() + w.ToString();
                 Card   card = new Card(name, w, s);
                 library.Add(card);
             }
         }
     }
 }
Пример #32
0
        private static string AlertToTM(string alert, Seats whoseRule)
        {
            string result = "";

#if Olympus
            // pH0510*=H5*!S4*(C4+D4)
            // C=0-9,D=0-9,H=5-5,S=0-3,HCP=04-11,Total=06-11
            var parseInfo = Rule.Conclude(alert, this.InterpretFactor, this.ConcludeFactor, whoseRule, false);
            for (Suits s = Suits.Clubs; s <= Suits.Spades; s++)
            {
                result += string.Format("{0}={1:0}-{2:0},", s.ToParser(), parseInfo.L[s].Min, parseInfo.L[s].Max > 9 ? 9 : parseInfo.L[s].Max);
            }

            result += string.Format("HCP={0:00}-{1:00},", parseInfo.P.Min, parseInfo.P.Max);
            result += string.Format("Total={0:00}-{1:00}.", parseInfo.FitPoints.Min, parseInfo.FitPoints.Max);
#else
            //result = alert;
#endif
            return(result);
        }
Пример #33
0
        public PokerHand(string[] currentPokerHand)
        {
            // The expectation is that the class is being
            // initalized with an array of five cards
            // There really should be more error handling, but this
            // is just supposed to be a quick exercise

            pokerHand              = currentPokerHand;
            pokerHandSuit          = Suits.Unknown;
            pokerHandRank          = HandRanks.Unknown;
            pokerHandPrimaryCard   = Cards.Unknown;
            pokerHandSecondaryCard = Cards.Unknown;

            // Now that the poker hand is set we are going
            // to set first the list of cards and the suit
            SetPokerHandCardsAndSuit();

            // Now we set the rank and card values for primary and secondary cards
            SetPokerHandRankAndValues();
        }
Пример #34
0
    public List <Card> InitializeCards()
    {
        List <Card> cards = new List <Card>();

        for (Suits s = Suits.Circle; s <= Suits.Triangle; ++s)
        {
            for (Ranks r = Ranks.one; r <= Ranks.fourteen; ++r)
            {
                cards.Add(new Card(r, s));
            }
        }

        cards = RemoveInvalidCards(cards);

        //cards = AddWhotCards(cards);

        cards = ShuffleCards(cards);

        return(cards);
    }
Пример #35
0
        //constructor
        public Deck()
        {
            Suits suits       = Suits.Clubs;
            Value value       = Value.Ace;
            int   deckCounter = 0;

            for (int s = 0; s < NUMB_SUITS; s++)
            {
                for (int v = 0; v < NUMB_VALUE; v++)
                {
                    Card card = new Card(suits, value);
                    value++;
                    deck[deckCounter] = card;
                    deckCounter++;
                }
                value = Value.Ace;
                suits++;
            }
            Shuffle();
        }
Пример #36
0
        public Deck(int n)
        {
            // construct a deck with 'n' random Cards. Where n is capped at 52
            n = Math.Min(n, numberOfSuits * numberOfValues);

            for (int i = 0; i < n; i++)
            {
                // Construct a temporary card.
                Suits  tempSuit  = (Suits)fRandom.Next(numberOfSuits);
                Values tempValue = 1 + (Values)fRandom.Next(numberOfValues);
                Card   tempCard  = new Card(tempValue, tempSuit);

                // If tempCard hasn't been added to Deck yet, then add it.
                bool exists = this.Any(c => c.Equals(tempCard));
                if (!exists)
                {
                    this.Add(tempCard);
                }
            }
        }
Пример #37
0
    void CreateDeck()
    {
        for (int color = 0; color < 4; color++)
        {
            for (int value = 0; value < 13; value++)
            {
                Weight w    = (Weight)value;
                Suits  s    = (Suits)color;
                string name = s.ToString() + w.ToString();
                Card   card = new Card(name, w, s, ctype);
                library.Add(card);
            }
        }
        //创建大小joker
        Card smallJoker = new Card("SJoker", Weight.SJoker, Suits.None, ctype);
        Card largeJoker = new Card("LJoker", Weight.LJoker, Suits.None, ctype);

        library.Add(smallJoker);
        library.Add(largeJoker);
    }
Пример #38
0
        public static Action GetAction(Player player, IEnumerable<Action> possibleActions, Suits trump)
        {
            int handStrength = GetHandStrength(player, trump);

            if (!possibleActions.Contains(Action.PASS))
            {
                switch (trump)
                {
                    case Suits.HEARTS:
                        return Action.HEARTS;
                    case Suits.DIAMONDS:
                        return Action.DIAMONDS;
                    case Suits.SPADES:
                        return Action.SPADES;
                    case Suits.CLUBS:
                        return Action.CLUBS;
                    default:
                        return 0;
                }
            }

            if (handStrength >= 9)
            {
                if (possibleActions.Contains(Action.ABONDANCE))
                    return Action.ABONDANCE;
            }
            if (handStrength >= 5)
            {
                if (possibleActions.Contains(Action.ASK))
                    return Action.ASK;
                if (possibleActions.Contains(Action.ALONE))
                    return Action.ALONE;
            }
            if (handStrength >= 3)
            {
                if (possibleActions.Contains(Action.JOIN))
                    return Action.JOIN;
            }

            return Action.PASS;
        }
Пример #39
0
        /// <summary>Constructor</summary>
        /// <param name="index">Index of the bid</param>
        /// <param name="newExplanation">Explanation of the bid</param>
        public Bid(int index, string newExplanation, bool alert, string newHumanExplanation)
        {
            switch (index)
            {
            case 0:
                this.level   = BidLevels.Pass;
                this.special = SpecialBids.Pass; break;

            case 36:
                this.level   = BidLevels.Pass;
                this.special = SpecialBids.Double; break;

            case 37:
                this.level   = BidLevels.Pass;
                this.special = SpecialBids.Redouble; break;

            default:
            {
                if (index > 35)
                {
                    throw new FatalBridgeException("invalid index: {0}", index);
                }
                this.special = SpecialBids.NormalBid;
                this.suit    = (Suits)((index - 1) % 5);
                this.level   = (BidLevels)(((index - 1) / 5) + 1);
                break;
            }
            }

            if (this.level > BidLevels.Level7)
            {
                throw new InvalidCastException("level " + this.level.ToString());
            }
            if (this.suit > Suits.NoTrump)
            {
                throw new InvalidCastException("suit " + this.suit.ToString());
            }
            this.explanation      = newExplanation;
            this.alert            = alert;
            this.humanExplanation = newHumanExplanation;
        }
Пример #40
0
 private bool IsFlush(List <Card> cards)
 {
     Suit = Suits.Unknown;
     if (cards.Count(card => card.Suit.Equals(Suits.Spades)) >= 5)
     {
         Suit = Suits.Spades;
     }
     if (cards.Count(card => card.Suit.Equals(Suits.Hearts)) >= 5)
     {
         Suit = Suits.Hearts;
     }
     if (cards.Count(card => card.Suit.Equals(Suits.Clubs)) >= 5)
     {
         Suit = Suits.Clubs;
     }
     if (cards.Count(card => card.Suit.Equals(Suits.Diamonds)) >= 5)
     {
         Suit = Suits.Diamonds;
     }
     return(Suit != Suits.Unknown);
 }
Пример #41
0
        /*Sequence
         * Input: Card[] hand, int points, get the array with the hand and the number of points the player has
         * Output: return a bool indicating if the player won or lost
         * The method Sequence receive the array of card that the user has and compare the suit and the value of
         * each card to the winning combination of Sequence. If the hand match with the winning combination, the method
         * will return a bool indicated the player won and the number of points gain. To have a winning combination,
         * all the cards in the hand need to be of the same suit and need to show consecutive numbers.
         */
        public static bool Sequence(Card[] hand, ref int points)
        {
            Suits     suits         = hand[0].Suits;
            Value     value         = hand[0].Value;
            const int winningPoints = 600;

            for (int i = 0; i < hand.Length; i++)
            {
                if (hand[i].Suits != suits || hand[i].Value != value)
                {
                    return(false);
                }
                value++;
                if (value > Value.King)
                {
                    return(false);
                }
            }
            points = winningPoints;
            return(true);
        }
Пример #42
0
 public UserTableManager(Player u, Player c, Deck d, Suits s, Table t, int state)
 {
     _u = u; _c = c; _d = d; _s = s; _t = t;
     end = false;
     if (state == 1)
     {
         while (_u.CardCount < 6 && !_d.isEmpty())
         {
             _u.CardToHand(_d.GiveNextCard());
         }
         while (_c.CardCount < 6 && !_d.isEmpty())
         {
             _c.CardToHand(_d.GiveNextCard());
         }
         _t.PutToAttack(_c.Hand[0]);
         _c.Hand.RemoveAt(0);
     }
     else
     {
         while (_c.CardCount < 6 && !_d.isEmpty())
         {
             _c.CardToHand(_d.GiveNextCard());
         }
         while (_c.CardCount < 6 && !_d.isEmpty())
         {
             _c.CardToHand(_d.GiveNextCard());
         }
     }
 }
Пример #43
0
 public Card(Suits suit, Values value)
 {
     this.Suit = suit;
     this.Value = value;
 }
Пример #44
0
 public void ToString_ShouldReturnCorrectValue(Ranks rank, Suits suit)
 {
     Assert.Equal($"{rank} of {suit}", rank.Of(suit).ToString());
 }
Пример #45
0
 public void Equals_ShouldReturnFalse_ForCardsWithDifferentRanks(Suits suit)
 {
     Assert.NotEqual(Ace.Of(suit), Eight.Of(suit));
 }
Пример #46
0
 public void Equals_ShouldReturnTrue_ForSameCards(Ranks rank, Suits suit)
 {
     Assert.Equal(rank.Of(suit), rank.Of(suit));
 }
Пример #47
0
 public void setSuit(Suits suit)
 {
     this.suits = suit;
 }
Пример #48
0
	public FlushChecker(Suits suit, int amount)
	{
		Suit = suit;
		Amount = amount;
	}
Пример #49
0
 public Card(Suits suit, Faces face)
 {
     Suit = suit;
     Face = face;
 }
Пример #50
0
 private static Card GetLowestCardStrategic(IEnumerable<Card> cards, Suits pileSuit, Suits trump)
 {
     if (cards.Any(c => c.Suit == pileSuit))//Hand contains card of same suit as pile.
     {
         return GetLowestCard(cards.Where(c => c.Suit == pileSuit));//Return lowest possible pilesuit card.
     }
     else if (cards.Any(c => c.Suit != trump))//Hand doesn't contain card of same suit as pile and contains non-trump card.
     {
         return GetLowestCard(cards.Where(c => c.Suit != trump));//Return lowest possible non trump card.
     }
     else//Hand only contains trump cards;
     {
         return GetLowestCard(cards);//return lowest possible card.
     }
 }
Пример #51
0
 public SuitCard(Suits suit, Values value)
 {
     _s = suit;
     _v = value;
 }
Пример #52
0
 public Card(Ranks rank, Suits suit)
 {
     Rank = rank;
     Suit = suit;
 }
Пример #53
0
 public Card(Suits suit, string cardvalue)
 {
     Suit = suit;
     Cardvalue = cardvalue;
 }
Пример #54
0
 public CardBasic(int rank, Suits suit)
 {
     Rank = rank;
     Suit = suit;
 }
Пример #55
0
 public Card(Suits suits, Ranks ranks)
 {
     this.suits = suits;
     this.ranks = ranks;
 }
 /// <summary> Default constructor.  Defines the two necessary components of a playing card. </summary>
 /// <param name="rank">Playing card's value.</param>
 /// <param name="suit">Playing card's suit.</param>
 public SuitPrecedencePlayingCard(Ranks rank, Suits suit)
     : base(rank, (PlayingCard.Suits)TypeDescriptor.GetConverter(suit).ConvertTo(suit, typeof(PlayingCard.Suits)))
 {
 }
Пример #57
0
 public Card(Suits suit, Values value )
 {
     Suit = suit;
     Value = value;
 }
Пример #58
0
        protected override int GetHandStrength(Suits trump)
        {
            Player[] CopyPlayers = new Player[]
            {
                new Player("copy0", 0),
                new Player("copy1", 1),
                new Player("copy2", 2),
                new Player("copy3", 3)
            };

            Round simRound;
            do
            {
                simRound = new Round(CopyPlayers);
            } while (simRound.GameCase != Case.UNDECIDED);

            for (int i = 0; i < 4; i++)
            {
                CopyPlayers[i].hand.Cards.Clear();
                foreach (var card in game.Players[i].hand.Cards)
                    CopyPlayers[i].hand.AddCard(card);
            }

            while (simRound.InBiddingPhase)
            {
                if (simRound.CurrentPlayer == CopyPlayers.Where(cp => cp.Number == player.Number).Single())
                {
                    if (simRound.BiddingGetPossibleActions().Contains(Action.ABONDANCE))
                        simRound.BiddingDoAction(Action.ABONDANCE);
                    else
                    {
                        switch (trump)
                        {
                            case Suits.HEARTS:
                                {
                                    simRound.BiddingDoAction(Action.HEARTS);
                                    break;
                                }
                            case Suits.DIAMONDS:
                                {
                                    simRound.BiddingDoAction(Action.DIAMONDS);
                                    break;
                                }
                            case Suits.SPADES:
                                {
                                    simRound.BiddingDoAction(Action.SPADES);
                                    break;
                                }
                            case Suits.CLUBS:
                                {
                                    simRound.BiddingDoAction(Action.CLUBS);
                                    break;
                                }
                            default:
                                break;
                        }
                    }
                    simRound.BiddingDoAction(Action.ASK);
                }
                else
                    simRound.BiddingDoAction(Action.PASS);
            }

            simRound.EndBiddingRound();
            while (simRound.InTrickPhase)
            {
                while (simRound.TrickInProgress)
                    simRound.PlayCard(SimpleGameAI.GetMove(simRound));
                simRound.EndTrick();
            }

            return CopyPlayers.Where(cp => cp.Number == player.Number).Single().Tricks;
        }
Пример #59
0
 public Card(Suits suit, CardsRank rank, Image cardImage)
 {
     this.Suit = suit;
     this.Rank = rank;
     this.CardImage = cardImage;
 }
Пример #60
0
 public WhistController(Player[] players, Player FirstPlayer, Suits trump, IReferee referee)
     : base(players, referee)
 {
     this.trump = trump;
     for (int i = 0; i < players.Length; i++)
         if (players[i] == FirstPlayer)
         {
             currentPlayer = i;
             break;
         }
     CardPlayedByPlayer = new Dictionary<Player, Card>();
     foreach (Player player in players)
         CardPlayedByPlayer.Add(player, null);
 }