示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Card"/> class.
 /// </summary>
 /// <param name="cardIndex">Index of the card.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="sequenceNumber">The sequence number.</param>
 public Card(int cardIndex, CardMode mode, int sequenceNumber)
 {
     this._suit = GetSuitFromCardIndex(cardIndex, mode);
     this._rank = GetRankFromIndex(cardIndex, mode);
     this._sequence = sequenceNumber;
     this._cardIndex = cardIndex;
 }
示例#2
0
        public void Card_cardRankHasCorrectValue(CardRank rank, CardSuit suit, int expected)
        {
            Card card   = new Card(rank, suit);
            var  actual = (int)card.Rank;

            Assert.Equal(expected, actual);
        }
示例#3
0
        public void Card_pairWithDifferentRankOrSuitAreNotEqual(CardRank card1Rank, CardSuit card1Suit, CardRank card2Rank, CardSuit card2Suit)
        {
            Card card1 = new Card(card1Rank, card1Suit);
            Card card2 = new Card(card2Rank, card2Suit);

            Assert.False(card1.Rank == card2.Rank && card1.Suit == card2.Suit);
        }
示例#4
0
        public PlayableCard(int suitIndex, int rankIndex)
        {
            suit = (CardSuit)suitIndex;
            rank = (CardRank)rankIndex;
            switch (suit)
            {
            case CardSuit.DIAMONDS:
            case CardSuit.HEARTS:
            {
                cardColor = CardColor.RED;
                break;
            }

            case CardSuit.CLUBS:
            case CardSuit.SPADES:
            {
                cardColor = CardColor.BLACK;
                break;
            }

            default:
            {
                break;
            }
            }
        }
示例#5
0
    // TODO à développer
    public Card ChooseAllyCard(CardList hand, CardRank minRank, Deck standardDeck)
    {
        Card heart   = hand.GetCard(CardType.Heart, minRank);
        Card diamond = hand.GetCard(CardType.Diamond, minRank);
        Card spade   = hand.GetCard(CardType.Spade, minRank);
        Card club    = hand.GetCard(CardType.Club, minRank);

        if (heart == null)
        {
            return(standardDeck.GetCard(CardType.Heart, minRank));
        }
        else if (diamond == null)
        {
            return(standardDeck.GetCard(CardType.Diamond, minRank));
        }
        else if (spade == null)
        {
            return(standardDeck.GetCard(CardType.Spade, minRank));
        }
        else if (club == null)
        {
            return(standardDeck.GetCard(CardType.Club, minRank));
        }
        else
        {
            return(standardDeck.GetCard(defaultType, minRank));
        }
    }
示例#6
0
        /// <summary>
        /// Checks if there are same ranked cards
        /// </summary>
        /// <param name="amountNeeded">Amount of cards that need to have same Ranking</param>
        /// <param name="cards">Held cards</param>
        /// <param name="countOfSameKinds">Amount of different sets of cards that have matched the criteria</param>
        /// <returns></returns>
        private bool CheckForSameRank(int amountNeeded, Card [] cards, out int countOfSameKinds)
        {
            countOfSameKinds = 0;

            for (int i = 0; i < Card.amountOfRanks; i++)
            {
                CardRank checkedCardRank = (CardRank)i;

                Card[] cardsGottenFromHand = cards.Where(x => x.cardRank.Equals(checkedCardRank)).ToArray();

                if (cardsGottenFromHand.Length == amountNeeded)
                {
                    countOfSameKinds++;
                }
            }

            if (countOfSameKinds > 0)
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
示例#7
0
 public CardVo(CardSuit suit, CardRank rank, bool shirtVisible, int cardId)
 {
     _id           = cardId;
     _suit         = suit;
     _rank         = rank;
     _shirtVisible = shirtVisible;
 }
示例#8
0
 public Card(int kind, int rank)
 {
     _kind          = (Kind)kind;
     _rank          = (CardRank)rank;
     _image         = new Image();
     _image.Stretch = Stretch.Fill;
 }
示例#9
0
    private void AddCardHand(CardType type, CardRank rank)
    {
        Card card = GetCard(type, rank);

        player.Hand.Add(card);
        Debug.Log("Add card to hand: " + card);
    }
示例#10
0
 public Card(CardRank rank, CardSuit suit, Deck deck)
 {
     this.rank = rank;
     this.suit = suit;
     this.deck = deck;
     this.deck.Game.Cards.Add(this);
 }
示例#11
0
        /// <summary>
        /// Handles the card changed packet
        /// </summary>
        /// <param name="inMsg">The message to decode</param>
        private void HandleCardChanged(NetIncomingMessage inMsg)
        {
            bool added    = inMsg.ReadBoolean();
            bool hasValue = inMsg.ReadBoolean();

            inMsg.ReadPadBits();

            if (hasValue)
            {
                CardRank rank = (CardRank)inMsg.ReadByte();
                CardSuit suit = (CardSuit)inMsg.ReadByte();

                PlayingCard card = new PlayingCard(rank, suit)
                {
                    FaceUp = true
                };

                if (added)
                {
                    myHand.Add(card);

                    OnHandCardAdded?.Invoke(this, card);
                }
                else
                {
                    myHand.Discard(card);

                    OnHandCardRemoved?.Invoke(this, card);
                }
            }
        }
示例#12
0
        public static char GetRankChar(CardRank rank)
        {
            switch (rank)
            {
            case CardRank.Deuce: return('2');

            case CardRank.Trey: return('3');

            case CardRank.Four: return('4');

            case CardRank.Five: return('5');

            case CardRank.Six: return('6');

            case CardRank.Seven: return('7');

            case CardRank.Eight: return('8');

            case CardRank.Nine: return('9');

            case CardRank.Ten: return('T');

            case CardRank.Jack: return('J');

            case CardRank.Queen: return('Q');

            case CardRank.King: return('K');

            case CardRank.Ace: return('A');

            default: return('?');
            }
        }
示例#13
0
 public Card(int number, CardSuit suit, Deck deck)
 {
     this.rank = (CardRank)number;
     this.suit = suit;
     this.deck = deck;
     this.deck.Game.Cards.Add(this);
 }
        public static List <Card> CreateDealerCardSet(CardRank cardRank)
        {
            var result = CreateCardSet(cardRank);

            result.Last().Flag = Visibility.Invisible;
            return(result);
        }
示例#15
0
 public Pair(CardRank pairRank, CardRank rank1, CardRank rank2, CardRank rank3)
 {
     PairRank = pairRank;
     Rank1    = rank1;
     Rank2    = rank2;
     Rank3    = rank3;
 }
示例#16
0
        public static string GetRankString(this CardRank rank)
        {
            switch (rank)
            {
            case CardRank.ace:
            case CardRank.two:
            case CardRank.three:
            case CardRank.four:
            case CardRank.five:
            case CardRank.six:
            case CardRank.seven:
            case CardRank.eight:
            case CardRank.nine:
            case CardRank.ten:
                return(((int)rank).ToString());

            case CardRank.jack:
                return("j");

            case CardRank.queen:
                return("q");

            case CardRank.king:
                return("k");

            default:
                return("");
            }
        }
        protected BaseCardValue(
            char asChar,
            [NotNull] string name,
            [NotNull] uint[] values,
            CardRank rank)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException(
                          "Card value 'name' can't be null or empty!",
                          nameof(name));
            }

            if (!values.Any())
            {
                throw new ArgumentException(
                          "Card values 'values' can't be empty!",
                          nameof(name));
            }

            Name   = name;
            AsChar = asChar;
            Values = values;
            Value  = values [0];
            Rank   = rank; // todo testing
        }
示例#18
0
 public Card(int kind, int rank)
 {
     _kind = (Kind)kind;
     _rank = (CardRank)rank;
     _image = new Image();
     _image.Stretch = Stretch.Fill;
 }
示例#19
0
    public static int GetCardValue(CardSuit suit, CardRank rank)
    {
        int baseValue = ((int)rank - 1) * 4;
        int addValue  = (int)suit - 1;

        return(baseValue + addValue);
    }
示例#20
0
        public static void CardsCompare()

        {
            var rankInput = Console.ReadLine();

            var suitInput = Console.ReadLine();

            CardRank rank = (CardRank)Enum.Parse(typeof(CardRank), rankInput);

            CardSuit suit = (CardSuit)Enum.Parse(typeof(CardSuit), suitInput);

            Card cardOne = new Card(suit, rank);

            var rankInput2 = Console.ReadLine();

            var suitInput2 = Console.ReadLine();

            CardRank rank2 = (CardRank)Enum.Parse(typeof(CardRank), rankInput2);

            CardSuit suit2 = (CardSuit)Enum.Parse(typeof(CardSuit), suitInput2);

            Card cardTwo = new Card(suit2, rank2);

            List <Card> cards = new List <Card>();

            cards.Add(cardOne);

            cards.Add(cardTwo);

            Card resultCard = cards.OrderByDescending(c => c).First();

            Console.WriteLine(resultCard.ToString());
        }
示例#21
0
 /// <summary>
 /// Parameterized constructor of a Card object
 /// </summary>
 /// <param name="suit">The Card Suit</param>
 /// <param name="rank">The Card Rank</param>
 public PlayingCard(CardSuit suit, CardRank rank, bool faceUp = false)
 {
     this.mySuit  = suit;
     this.myRank  = rank;
     this.myValue = (int)rank;
     this.FaceUp  = faceUp;
 }
示例#22
0
 public Card(CardRank rank, CardSuit suit, Deck deck)
 {
     Rank      = rank;
     Suit      = suit;
     this.deck = deck;
     GameBehavior.Cards.Add(this);
 }
示例#23
0
        public int Power()
        {
            CardSuits cardSuit = (CardSuits)Enum.Parse(typeof(CardSuits), this.cardSuit);
            CardRank  cardRank = (CardRank)Enum.Parse(typeof(CardRank), this.cardRank);

            return((int)(cardSuit) + (int)(cardRank));
        }
示例#24
0
 public Card(int number, CardSuit suit, Deck deck)
 {
     Rank      = (CardRank)number;
     Suit      = suit;
     this.deck = deck;
     GameBehavior.Cards.Add(this);
 }
示例#25
0
        public void CardsAreEqual(CardRank rank1, CardSuit suit1, CardRank rank2, CardSuit suit2, bool expected)
        {
            Card card1 = new Card(rank1, suit1);
            Card card2 = new Card(rank2, suit2);

            Assert.AreEqual(card1.Equals(card2), expected);
        }
示例#26
0
 /// <summary>
 /// Card Cosntructor sets suit, name, value and isHidden
 /// </summary>
 /// <param name="suit"></param>
 /// <param name="name"></param>
 /// <param name="value"></param>
 public Card(CardSuit suit, CardRank rank, int value)
 {
     Suit     = suit;
     Rank     = rank;
     Value    = value;
     IsHidden = false;
 }
示例#27
0
        public void Card_pairWithSameSuitAndRankAreEqual(CardRank rank, CardSuit suit)
        {
            Card card1 = new Card(rank, suit);
            Card card2 = new Card(rank, suit);

            Assert.True(card1.Rank == card2.Rank && card1.Suit == card2.Suit);
        }
        public void GetValue_ShouldBeNine()
        {
            ICardName cardName = new CardName(ECardName.Nine);
            ICardRank sut      = new CardRank(cardName);

            Assert.AreEqual(sut.GetValue(), 9);
        }
示例#29
0
 public PlayingCard(CardRank rank, CardSuit suit, Texture2D cardBack, SpriteBatch spriteBatch)
 {
     this.Rank         = rank;
     this.Suit         = suit;
     this._cardBack    = cardBack;
     this._spriteBatch = spriteBatch;
 }
示例#30
0
 public HandEvaluation(HandRank rank, CardRank highcard, CardRank lowcard, params CardRank[] kickers)
 {
     Rank     = rank;
     HighCard = highcard;
     LowCard  = lowcard;
     Kickers  = kickers;
 }
示例#31
0
    private void AddCardBoard(CardType type, CardRank rank)
    {
        Card card = GetCard(type, rank);

        boardCards.Add(card);
        Debug.Log("Add card to board: " + card);
    }
        public bool IsValid()
        {
            IEnumerable <CardRank> values = Cards.Select(x => x.Rank);

            IEnumerable <CardRank> cardRanks = values as CardRank[] ?? values.ToArray();
            IEnumerable <IGrouping <CardRank, CardRank> > grouped = cardRanks.GroupBy(x => x).ToArray();

            if (grouped.Count() < 2)
            {
                return(false);
            }

            foreach (IGrouping <CardRank, CardRank> grouping in grouped)
            {
                int count = grouping.Count();

                if (count != 3)
                {
                    continue;
                }

                CardRank cardRank = grouping.Key;

                Rank         = cardRank;
                ThreeOfAKind = Cards.Where(x => x.Rank == cardRank);
                OtherCards   = Cards.Where(x => x.Rank != cardRank);
                HighestCard  = OtherCards.OrderBy(x => x.Rank).Last();

                return(true);
            }

            return(false);
        }
示例#33
0
 public Card(CardSuit suit, CardRank rank, Image frontImage) : this(suit, rank)
 {
     this.FrontImage = frontImage;
     //Can we make it to private readonly or const?
     this.BackCardPath = "..\\..\\Resources\\Cards\\Back.png";
     this.BackImage = Image.FromFile(BackCardPath);
     this.CardPictureBox = new PictureBox();
 }
示例#34
0
 protected Card(Game game, int id, CardType type, CardSuit suit, CardRank rank)
 {
     this.game = game;
     this.id = id;
     this.type = type;
     this.suit = suit;
     this.rank = rank;
     color = GetColor(type);
     empty = new EmptyCard(this);
 }
示例#35
0
 public PlayingCardWidget(int id, CardType type, CardRank rank, CardSuit suit)
 {
     layout = new Pango.Layout(Gdk.PangoHelper.ContextGet());
     layout.FontDescription = Pango.FontDescription.FromString("Angleterre Book, Librarian bold 32");
     this.id = id;
     this.type = type;
     this.rank = rank;
     this.suit = suit;
     Card = CardManager.GetCard(type);
     UpdateMarkup();
 }
示例#36
0
 /// <summary>
 /// constructor of spades card
 /// </summary>
 /// <param name="i">Card Index</param>
 public SpadesCard(int i)
     : base()
 {
     if (i < 0 || i > 52)
     {
         throw new ApplicationException("Wrong value for card initilization.");
     }
        _cardindex = i;
        Suit = Card.SuitFromCardIndex(i);
        Rank = Card.RankFromCardIndex(i);
 }
示例#37
0
 public Card(Image im)
 {
     string name = im.Name;
     name = name.Trim();
     string kind = name.Substring(0, 1);
     Kind kindVal = (Kind)Enum.Parse(typeof(Kind), kind);
     string rank = name.Substring(1, name.Length - 1);
     CardRank rankVal = (CardRank)Enum.Parse(typeof(CardRank), rank);
     _kind = kindVal;
     _rank = rankVal;
     _image = new Image();
     _image.Stretch = Stretch.Fill;
 }
示例#38
0
        public Card(Kind kind, CardRank rank, bool trump)
        {
            _trump = trump;
            _kind = kind;
            _rank = rank;
            _image = new Image();
            _image.Stretch = Stretch.Fill;

            //Uri uri = new Uri("/images/c14.png", UriKind.Relative);
            //System.Diagnostics.Debug.WriteLine(uri);
            //_image.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(uri);
                //"images/"+_kind.ToString()+_rank.ToString()+".png", UriKind.Relative)); ;
        }
示例#39
0
        /// <summary>
        /// レアカードが獲得できた場合の処理
        /// </summary>
        /// <param name="env">環境設定</param>
        /// <param name="number">インデックス</param>
        /// <param name="rarerity">レアリティ</param>
        private static void HitRare(GatyaEnvironment env, out uint number, out CardRank rarerity)
        {
            uint result_num = Random.RandomIndex(env.CompleteCount);

            // 所持していないカードがヒットした場合、確変チェックを入れる
            if (env.Database.Rare[result_num] == 0)
            {
                if (env.Database.HitCount > env.StartUnhitCount)	// ここで確変チェック
                {
                    // 所持していないカードだったため、獲得できるか挑戦する
                    if (Random.RandomFloat() < env.UnhitPercent)
                    {
                        // 獲得成功!
                        number = result_num;
                        rarerity = CardRank.Rare;
                    }
                    else
                    {
                        // 失敗したので適当に所持している中から選ぶ
                        uint[] hitted = env.Database.HittedRareIndices;
                        number = Random.RandomIndex((uint)hitted.Length);
                        rarerity = CardRank.Rare;
                    }
                }
                else
                {
                    // 確変がまだ起きてないので通常通り
                    number = result_num;
                    rarerity = CardRank.Rare;
                }
            }
            else
            {
                // 所持しているカードがヒットしたので素通りする
                number = result_num;
                rarerity = CardRank.Rare;
            }
        }
示例#40
0
 private bool HasCard(CardSuit suit, CardRank rank, Hand hand)
 {
     foreach (SpadesCard card in hand.CardPile)
     {
         if (card.Rank == rank && card.Suit == suit)
         {
             return true;
         }
     }
     return false;
 }
示例#41
0
 public Schofield(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.Schofield, suit, rank)
 {
 }
示例#42
0
 public CanCan(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.CanCan, suit, rank, RequestType.CancelCard)
 {
 }
示例#43
0
 //无参构造
 public Card()
 {
     rank = (CardRank)0;
         color = (CardColor)0;
 }
示例#44
0
 public Dodge(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.Dodge, suit, rank)
 {
 }
示例#45
0
 public Card(CardRank rank,CardSuit suit)
 {
     Rank = rank;
     Suit = suit;
 }
示例#46
0
 public IronPlate(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.IronPlate, suit, rank)
 {
 }
示例#47
0
        private int RankBelow(CardSuit cardSuit, Hand hand, CardRank rank)
        {
            int cardCount = 0;
            foreach (SpadesCard card in hand.CardPile)
            {
                if (card.Suit == cardSuit)
                {
                    if (card.Rank < rank || card.Rank != CardRank.Ace)
                    {
                        cardCount++;
                    }
                }
            }

            return cardCount;
        }
示例#48
0
 public Card(CardRank rank,CardColor color)
 {
     this.rank=rank;
         this.color=color;
 }
示例#49
0
 public RagTime(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.RagTime, suit, rank, RequestType.StealCard)
 {
 }
示例#50
0
 public Sombrero(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.Sombrero, suit, rank)
 {
 }
示例#51
0
 public Card(CardRank rank, CardSuit suit)
 {
     this.rank = rank;
     this.suit = suit;
 }
示例#52
0
 protected PlayableTableCard(Game game, int id, CardType type, CardSuit suit, CardRank rank)
     : base(game, id, type, suit, rank)
 {
 }
示例#53
0
        public override int ToRankIndex(CardRank cardRank)
        {
            int index;

            switch (cardRank)
            {
                case CardRank.Two:
                    index = 0;
                    break;
                case CardRank.Three:
                    index = 1;
                    break;
                case CardRank.Four:
                    index = 2;
                    break;
                case CardRank.Five:
                    index = 3;
                    break;
                case CardRank.Six:
                    index = 4;
                    break;
                case CardRank.Seven:
                    index = 5;
                    break;
                case CardRank.Eight:
                    index = 6;
                    break;
                case CardRank.Nine:
                    index = 7;
                    break;
                case CardRank.Ten:
                    index = 8;
                    break;
                case CardRank.Jack:
                    index = 9;
                    break;
                case CardRank.Queen:
                    index = 10;
                    break;
                case CardRank.King:
                    index = 11;
                    break;
                case CardRank.Ace:
                    index = 12;
                    break;
                case CardRank.Undefined:
                    index = -1;
                    break;
                default:
                    index = -1;
                    break;
            }

            return index;
        }
示例#54
0
 public Bible(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.Bible, suit, rank)
 {
 }
示例#55
0
 protected AllPlayersTableCard(Game game, int id, CardType type, CardSuit suit, CardRank rank, bool includeSelf = false)
     : base(game, id, type, suit, rank)
 {
     this.includeSelf = includeSelf;
 }
示例#56
0
 public Card(CardSuit suit, CardRank rank)
 {
     this.suit = suit;
     this.rank = rank;
 }
示例#57
0
 public Hideout(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.Hideout, suit, rank)
 {
 }
示例#58
0
        private int RankAbove(CardSuit cardSuit, Hand hand, CardRank rank)
        {
            int cardCount = 1;

            foreach (SpadesCard card in hand.CardPile)
            {
                if (card.Suit == cardSuit)
                {
                    if (card.Rank >= rank || card.Rank == CardRank.Ace)
                    {
                        cardCount++;
                    }
                }
            }

            return cardCount;
        }
示例#59
0
        public override int ToCardIndex(CardRank cardRank, CardSuit cardSuit)
        {
            int cardIndex;

            checked
            {
                cardIndex = (ToSuitIndex(cardSuit)*RankCount) + ToRankIndex(cardRank);
            }

            return cardIndex;
        }
示例#60
0
 public Barrel(Game game, int id, CardSuit suit, CardRank rank)
     : base(game, id, CardType.Barrel, suit, rank)
 {
 }