Example #1
0
 public Card(RANK rank,SUIT suit)
 {
     this.rank = (int)rank;
     this.suit = (int)suit;
     faceUp = false;
     highlight = false;
 }
Example #2
0
 public Card(RANK rank, SUIT suit,bool faceUp)
 {
     this.rank = (int)rank;
     this.suit = (int)suit;
     this.faceUp = faceUp;
     highlight = false;
 }
Example #3
0
        private Card FromString(string cardStr)
        {
            RANK rank = (RANK)Enum.Parse(typeof(RANK), "R" + cardStr.Split('_')[1]);
            SUIT suit = (SUIT)Enum.Parse(typeof(SUIT), cardStr.Split('_')[0]);

            return(new Card(rank, suit));
        }
Example #4
0
 public Card(RANK rank, SUIT suit)
 {
     this.rank = (int)rank;
     this.suit = (int)suit;
     faceUp    = false;
     highlight = false;
 }
Example #5
0
        /// <summary>
        /// Converts a string suit to the suit value
        /// </summary>
        /// <param name="suit">The inputted suit</param>
        /// <returns>Suit</returns>
        public SUIT ConvertToSuit(string suit)
        {
            SUIT tempSuit = SUIT.HEARTS;

            switch (suit.ToUpper())
            {
            case "H":
                tempSuit = SUIT.HEARTS;
                break;

            case "S":
                tempSuit = SUIT.SPADES;
                break;

            case "D":
                tempSuit = SUIT.DIAMONDS;
                break;

            case "C":
                tempSuit = SUIT.CLUBS;
                break;
            }

            return(tempSuit);
        }
Example #6
0
 public Card(RANK rank, SUIT suit, bool faceUp)
 {
     this.rank   = (int)rank;
     this.suit   = (int)suit;
     this.faceUp = faceUp;
     highlight   = false;
 }
 public BlackjackCard(SUIT suit, int faceValue) : base(suit, faceValue)
 {
     this.GameValue = faceValue;
     if (this.GameValue > 10)
     {
         this.GameValue = 10;
     }
 }
Example #8
0
 public Card(int idx)
 {
     _iCard = idx;
     _iSuit = idx / 13;
     _iRank = idx % 13;
     _eSUIT = (SUIT)(0x10000 << _iSuit);
     _eRANK = (RANK)(0x1 << _iRank);
 }
Example #9
0
    public bool HasCardOfSuit(SUIT suit)
    {
        foreach (Card c in Cards)
        {
            if (c.Suit == suit && c.card_state == Card.CARD_STATE.IN_HAND)
            {
                return(true);
            }
        }

        return(false);
    }
Example #10
0
        private static bool SameSuit(params Card[] list)
        {
            SUIT s = list[0].suit;

            for (int i = 0; i < list.Length; i++)
            {
                if (s != list[i].suit)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #11
0
        public string SuitString(SUIT suit)
        {
            switch (suit)
            {
            default: return("");

            case SUIT.D: return("D");   // "♦";

            case SUIT.C: return("C");   // "♣";

            case SUIT.H: return("H");   // "♥";

            case SUIT.S: return("S");   // "â™ ";
            }
        }
Example #12
0
    public Card[] GetLegalMoves(bool firstTrick, bool heartsBroken, SUIT startingSuit, int CurrentPlaceInTrick)
    {
        List <Card> legalCards = new List <Card>();

        SetLegalMoves(firstTrick, heartsBroken, startingSuit, CurrentPlaceInTrick);

        foreach (Card c in Cards)
        {
            if (c.isLegal)
            {
                legalCards.Add(c);
            }
        }

        return(legalCards.ToArray());
    }
Example #13
0
        public Card(string _cardName)
        {
            switch (_cardName[_cardName.Length - 1])
            {
            case 'D': m_suit = SUIT.DIAMOND; break;

            case 'H': m_suit = SUIT.HEART; break;

            case 'C': m_suit = SUIT.CLUB; break;

            case 'S': m_suit = SUIT.SPADE; break;

            default: throw new Exception("Unsupported suit character!");
            }

            _cardName = _cardName.Substring(0, _cardName.Length - 1);
            switch (_cardName)
            {
            case "2": m_value = 0; break;

            case "3": m_value = 1; break;

            case "4": m_value = 2; break;

            case "5": m_value = 3; break;

            case "6": m_value = 4; break;

            case "7": m_value = 5; break;

            case "8": m_value = 6; break;

            case "9": m_value = 7; break;

            case "10": m_value = 8; break;

            case "J": m_value = 9; break;

            case "Q": m_value = 10; break;

            case "K": m_value = 11; break;

            case "A": m_value = 12; break;

            default: throw new Exception("Unsupported card type!");
            }
        }
Example #14
0
        public Card(SUIT suit, RANK rank)
        {
            _eSUIT = suit;
            _eRANK = rank;

            switch (suit)
            {
            case SUIT.D: _iSuit = 0; break;

            case SUIT.C: _iSuit = 1; break;

            case SUIT.H: _iSuit = 2; break;

            case SUIT.S: _iSuit = 3; break;
            }

            switch (rank)
            {
            case RANK._2: _iRank = 0; break;

            case RANK._3: _iRank = 1; break;

            case RANK._4: _iRank = 2; break;

            case RANK._5: _iRank = 3; break;

            case RANK._6: _iRank = 4; break;

            case RANK._7: _iRank = 5; break;

            case RANK._8: _iRank = 6; break;

            case RANK._9: _iRank = 7; break;

            case RANK._T: _iRank = 8; break;

            case RANK._J: _iRank = 9; break;

            case RANK._Q: _iRank = 10; break;

            case RANK._K: _iRank = 11; break;

            case RANK._A: _iRank = 12; break;
            }

            _iCard = _iSuit * 13 + _iRank;
        }
Example #15
0
    public void SetLegalMoves(bool firstTrick, bool heartsBroken, SUIT startingSuit, int CurrentPlaceInTrick)
    {
        foreach (Card c in Cards)
        {
            // default all moves to illegal
            c.SetLegality(false);

            // during the first trick, hearts cannot be played
            if (firstTrick)
            {
                if (CurrentPlaceInTrick == 1)
                {
                    if (c.IsTwoOfClubs())
                    {
                        c.SetLegality(true);
                    }
                }
                else
                {
                    // if player has clubs, only clubs can be played
                    if (HasCardOfSuit(SUIT.CLUBS))
                    {
                        if (c.Suit == SUIT.CLUBS)
                        {
                            c.SetLegality(true);
                        }
                    }
                    else
                    {
                        // if player doesn't have clubs, all cards apart from hearts and QoS can be played
                        if (c.Suit != SUIT.HEARTS && !c.IsQueenOfSpades())
                        {
                            c.SetLegality(true);
                        }
                    }
                }
            }
            // not the first trick
            else
            {
                // first player to play a card can play any card (not hearts if hearts not broken)
                if (CurrentPlaceInTrick == 1)
                {
                    if (heartsBroken && c.card_state == Card.CARD_STATE.IN_HAND)
                    {
                        c.SetLegality(true);
                    }
                    else
                    {
                        if (c.Suit != SUIT.HEARTS && c.card_state == Card.CARD_STATE.IN_HAND)
                        {
                            c.SetLegality(true);
                        }
                    }
                }
                // not the first person to pick
                else
                {
                    // see if player can match suit already played
                    if (HasCardOfSuit(startingSuit))
                    {
                        if (c.Suit == startingSuit && c.card_state == Card.CARD_STATE.IN_HAND)
                        {
                            c.SetLegality(true);
                        }
                    }
                    // doesnt have a card of the starting suit; play anything
                    else
                    {
                        if (c.card_state == Card.CARD_STATE.IN_HAND)
                        {
                            c.SetLegality(true);
                        }
                    }
                }
            }
        }
    }
Example #16
0
 public Card(RANK r, SUIT s)
 {
     rank = r;
     suit = s;
 }
Example #17
0
 public Card(string value, string suit)
 {
     Value = MapNumber(value);
     Suit  = MapSuit(suit);
 }
Example #18
0
 public Card(SUIT suit, int faceValue)
 {
     this.Suit      = suit;
     this.FaceValue = faceValue;
 }
Example #19
0
 public Card(int x, string file, SUIT s)
 {
     cardValue = x;
     fileName  = file;
     suit      = s;
 }
Example #20
0
 public Card(SUIT s, int n)
 {
     Suit   = s;
     Number = n;
 }
Example #21
0
 public Card(SUIT suit, RANK rank)
 {
     this._suit = suit;
     this._rank = rank;
 }
Example #22
0
 public Card(SUIT suit, VALUE value)
 {
     Suit  = suit;
     Value = value;
 }
Example #23
0
 /// <summary>
 /// Constructor that sets the suit and value properties of a card
 /// </summary>
 /// <param name="st">Suit of a card</param>
 /// <param name="val">Value of a card</param>
 public Card(SUIT st, VALUE val)
 {
     suit  = st;
     value = val;
 }
Example #24
0
 public Card(Card card)
 {
     rank = card.rank;
     suit = card.suit;
 }
Example #25
0
 public Card(SUIT suit, VALUE value)
 {
     CardSuit  = suit;
     CardValue = value;
 }
Example #26
0
 public Card(SUIT suit, string value)
 {
     this.Suit  = suit;
     this.Value = value;
 }
Example #27
0
 public Card(RANK rank, SUIT suit)
 {
     this._rank = rank;
     this._suit = suit;
 }
Example #28
0
 public Card()
 {
     Rank = RANK.Small;
     Suit = SUIT.Joker;
 }
Example #29
0
 public void setCard(RANK rank, SUIT suit)
 {
     this.rank = (int)rank;
     this.suit = (int)suit;
 }
Example #30
0
 public Card(RANK _rank, SUIT _suit)
 {
     Rank = _rank;
     Suit = _suit;
 }
Example #31
0
 public Card(RANK rank, SUIT suit)
 {
     this.rank = rank;
     this.suit = suit;
 }
Example #32
0
 public void setCard(RANK rank, SUIT suit)
 {
     this.rank = (int)rank;
     this.suit = (int)suit;
 }
Example #33
0
 public Card(SUIT suit, RANK rank)
 {
     Suit = suit;
     Rank = rank;
 }
Example #34
0
 public Card(int v, SUIT suit)
 {
     faceValue = v;
     this.suit = suit;
 }