예제 #1
0
파일: Deck.cs 프로젝트: GennrichJ/Set
        /// <summary>
        /// Returns collection of Matches for every possible match with the cards in this deck
        /// and the card argument.
        /// Note that a single card may be a part of multiple potential matches,
        /// in which case it will appear in multiple Matches in the returned List.
        /// </summary>
        /// <param name="card">Card to be compared to other cards in this deck for matches.</param>
        public List<Match> GetAllMatches(Card card)
        {
            var matches = new List<Match>();

            for (var i = 0; i < Cards.Count; i++)
            {
                for (var j = i + 1; j < Cards.Count; j++)
                {
                    var firstCard = Cards[i];
                    var secondCard = Cards[j];

                    if (firstCard == secondCard || firstCard == card || secondCard == card)
                        continue;

                    if (!Card.IsMatch(firstCard, secondCard, card))
                        continue;

                    var match = new Match();
                    match.Cards[0] = firstCard;
                    match.Cards[1] = secondCard;
                    match.Cards[2] = card;

                    if (matches.All(x => x.Cards != match.Cards))
                        matches.Add(match);
                }
            }

            return matches;
        }
예제 #2
0
파일: CardTests.cs 프로젝트: GennrichJ/Set
        public void IsMatchDifferentShapeDifferentColorDifferentNumberSameShading()
        {
            var card1 = new Card
            {
                Shading = Enums.Shading.Outlined,
                Color = Enums.Color.Green,
                Number = Enums.Number.One,
                Shape = Enums.Shape.Diamond
            };

            var card2 = new Card
            {
                Shading = Enums.Shading.Outlined,
                Color = Enums.Color.Purple,
                Number = Enums.Number.Two,
                Shape = Enums.Shape.Oval
            };

            var card3 = new Card
            {
                Shading = Enums.Shading.Outlined,
                Color = Enums.Color.Red,
                Number = Enums.Number.Three,
                Shape = Enums.Shape.Squiggle
            };

            Assert.IsTrue(Card.IsMatch(card1, card2, card3));
        }
예제 #3
0
파일: CardTests.cs 프로젝트: GennrichJ/Set
        public void IsColorMatch()
        {
            var card1 = new Card { Color = Enums.Color.Green };
            var card2 = new Card { Color = Enums.Color.Green };
            var card3 = new Card { Color = Enums.Color.Green };

            Assert.IsTrue(Card.IsColorMatch(card1, card2, card3));

            card1.Color = Enums.Color.Green;
            card2.Color = Enums.Color.Purple;
            card3.Color = Enums.Color.Red;

            Assert.IsTrue(Card.IsColorMatch(card1, card2, card3));

            card1.Color = Enums.Color.Green;
            card2.Color = Enums.Color.Purple;
            card3.Color = Enums.Color.Green;

            Assert.IsFalse(Card.IsColorMatch(card1, card2, card3));
        }
예제 #4
0
파일: CardTests.cs 프로젝트: GennrichJ/Set
        public void IsShapeMatch()
        {
            var card1 = new Card {Shape = Enums.Shape.Diamond};
            var card2 = new Card { Shape = Enums.Shape.Diamond };
            var card3 = new Card { Shape = Enums.Shape.Diamond };

            Assert.IsTrue(Card.IsShapeMatch(card1, card2, card3));

            card1.Shape = Enums.Shape.Diamond;
            card2.Shape = Enums.Shape.Oval;
            card3.Shape = Enums.Shape.Squiggle;

            Assert.IsTrue(Card.IsShapeMatch(card1, card2, card3));

            card1.Shape = Enums.Shape.Diamond;
            card2.Shape = Enums.Shape.Oval;
            card3.Shape = Enums.Shape.Diamond;

            Assert.IsFalse(Card.IsShapeMatch(card1, card2, card3));
        }
예제 #5
0
파일: CardTests.cs 프로젝트: GennrichJ/Set
        public void IsShadingMatch()
        {
            var card1 = new Card { Shading = Enums.Shading.Outlined };
            var card2 = new Card { Shading = Enums.Shading.Outlined };
            var card3 = new Card { Shading = Enums.Shading.Outlined };

            Assert.IsTrue(Card.IsShadingMatch(card1, card2, card3));

            card1.Shading = Enums.Shading.Outlined;
            card2.Shading = Enums.Shading.Solid;
            card3.Shading = Enums.Shading.Striped;

            Assert.IsTrue(Card.IsShadingMatch(card1, card2, card3));

            card1.Shading = Enums.Shading.Outlined;
            card2.Shading = Enums.Shading.Solid;
            card3.Shading = Enums.Shading.Outlined;

            Assert.IsFalse(Card.IsShadingMatch(card1, card2, card3));
        }
예제 #6
0
파일: CardTests.cs 프로젝트: GennrichJ/Set
        public void IsNumberMatch()
        {
            var card1 = new Card { Number = Enums.Number.One };
            var card2 = new Card { Number = Enums.Number.One };
            var card3 = new Card { Number = Enums.Number.One };

            Assert.IsTrue(Card.IsNumberMatch(card1, card2, card3));

            card1.Number = Enums.Number.One;
            card2.Number = Enums.Number.Two;
            card3.Number = Enums.Number.Three;

            Assert.IsTrue(Card.IsNumberMatch(card1, card2, card3));

            card1.Number = Enums.Number.One;
            card2.Number = Enums.Number.Two;
            card3.Number = Enums.Number.One;

            Assert.IsFalse(Card.IsNumberMatch(card1, card2, card3));
        }
예제 #7
0
파일: CardTests.cs 프로젝트: GennrichJ/Set
        public void IsMatchSameShapeSameColorSameNumberSameShading()
        {
            var card1 = new Card
            {
                Shading = Enums.Shading.Outlined,
                Color = Enums.Color.Green,
                Number = Enums.Number.One,
                Shape = Enums.Shape.Diamond
            };

            var card2 = new Card
            {
                Shading = Enums.Shading.Outlined,
                Color = Enums.Color.Green,
                Number = Enums.Number.One,
                Shape = Enums.Shape.Diamond
            };

            var card3 = new Card
            {
                Shading = Enums.Shading.Outlined,
                Color = Enums.Color.Green,
                Number = Enums.Number.One,
                Shape = Enums.Shape.Diamond
            };

            Assert.IsTrue(Card.IsMatch(card1, card2, card3));
        }
예제 #8
0
파일: CardTests.cs 프로젝트: GennrichJ/Set
        public void IsMatchSameShapeSameColorDifferentNumberDifferentShading()
        {
            var card1 = new Card
            {
                Shading = Enums.Shading.Outlined,
                Color = Enums.Color.Green,
                Number = Enums.Number.One,
                Shape = Enums.Shape.Diamond
            };

            var card2 = new Card
            {
                Shading = Enums.Shading.Solid,
                Color = Enums.Color.Green,
                Number = Enums.Number.Two,
                Shape = Enums.Shape.Diamond
            };

            var card3 = new Card
            {
                Shading = Enums.Shading.Striped,
                Color = Enums.Color.Green,
                Number = Enums.Number.Three,
                Shape = Enums.Shape.Diamond
            };

            Assert.IsTrue(Card.IsMatch(card1, card2, card3));
        }
예제 #9
0
        private void ProcessMatches()
        {
            var cardType1 = _cardsSelected[0].GetComponent<CardTypes>();
            var card1 = new Card
            {
                Shape = cardType1.Shape,
                Color = cardType1.Color,
                Number = cardType1.Number,
                Shading = cardType1.Shading
            };

            var cardType2 = _cardsSelected[1].GetComponent<CardTypes>();
            var card2 = new Card
            {
                Shape = cardType2.Shape,
                Color = cardType2.Color,
                Number = cardType2.Number,
                Shading = cardType2.Shading
            };

            var cardType3 = _cardsSelected[2].GetComponent<CardTypes>();
            var card3 = new Card
            {
                Shape = cardType3.Shape,
                Color = cardType3.Color,
                Number = cardType3.Number,
                Shading = cardType3.Shading
            };

            if (Card.IsMatch(card1, card2, card3))
            {
                //TODO rewrite using new deck properties with DeckScript class
                //_cardsMatched.Cards.Add(card1);
                //_cardsMatched.Cards.Add(card2);
                //_cardsMatched.Cards.Add(card3);

                //_cardsInPlay.Cards.RemoveAll(
                //    x =>
                //        x.Shape == card1.Shape && x.Color == card1.Color && x.Number == card1.Number &&
                //        x.Shading == card1.Shading);
                //_cardsInPlay.Cards.RemoveAll(
                //    x =>
                //        x.Shape == card2.Shape && x.Color == card2.Color && x.Number == card2.Number &&
                //        x.Shading == card2.Shading);
                //_cardsInPlay.Cards.RemoveAll(
                //    x =>
                //        x.Shape == card3.Shape && x.Color == card3.Color && x.Number == card3.Number &&
                //        x.Shading == card3.Shading);

                MoveCardFromDeckIntoPlay(_cardsSelected[0].transform.position);
                MoveCardFromDeckIntoPlay(_cardsSelected[1].transform.position);
                MoveCardFromDeckIntoPlay(_cardsSelected[2].transform.position);

                Destroy(_cardsSelected[0]);
                Destroy(_cardsSelected[1]);
                Destroy(_cardsSelected[2]);

                DeselectAllCards();
            }
            else
            {
                DeselectAllCards();
            }
        }
예제 #10
0
파일: DeckScript.cs 프로젝트: GennrichJ/Set
 /// <summary>
 /// Removes a specific card from the deck.
 /// </summary>
 /// <param name="card">The exact card to be removed from the deck.</param>
 public void RemoveCard(Card card)
 {
     throw new NotImplementedException();
 }
예제 #11
0
파일: DeckScript.cs 프로젝트: GennrichJ/Set
        /// <summary>
        /// Adds a specific card to the deck.
        /// </summary>
        /// <param name="card">Card to be added to the deck.</param>
        public void AddCard(Card card)
        {
            throw new NotImplementedException();

            //TODO do we want to support adding a card if that CardType already exists in the deck (duplicates)?
        }