예제 #1
0
        public void ConfirmSetTest()
        {
            SET.Processing isSet = new Processing();
            List<Cards> cardList = new List<Cards>();

            SET.Cards card1 = new Cards();
            SET.Cards card2 = new Cards();
            SET.Cards card3 = new Cards();

            card1.Color = "red";
            card1.Number = 1;
            card1.Shade = "solid";
            card1.Shape = "oval";
            card2.Color = "green";
            card2.Number = 2;
            card2.Shade = "solid";
            card2.Shape = "oval";
            card3.Color = "blue";
            card3.Number = 3;
            card3.Shade = "solid";
            card3.Shape = "oval";

            cardList.Insert(0, card1);
            cardList.Insert(1, card2);
            cardList.Insert(2, card3);

            Assert.IsTrue(isSet.ConfirmSet(cardList) > 0);

            card1.Color = "red";
            card1.Number = 1;
            card1.Shade = "solid";
            card1.Shape = "oval";
            card2.Color = "green";
            card2.Number = 2;
            card2.Shade = "solid";
            card2.Shape = "oval";
            card3.Color = "blue";
            card3.Number = 2;
            card3.Shade = "solid";
            card3.Shape = "oval";

            cardList.Clear();
            cardList.Insert(0, card1);
            cardList.Insert(1, card2);
            cardList.Insert(2, card3);

            Assert.IsFalse(isSet.ConfirmSet(cardList) > 0);
        }
예제 #2
0
파일: Data.cs 프로젝트: UgotAlan/SET
        public void buildDeck()
        {
            string shape = "temp";
            string color = "temp";
            string shade = "temp";

            for (var number = 1; number <= 3; ++number)
            {
                for (var b = 0; b < 3; ++b)
                {
                    switch(b)
                    {
                        case 0:
                            shape = "dia";
                            break;
                        case 1:
                            shape = "ova";
                            break;
                        case 2:
                            shape = "squ";
                            break;
                    }
                    for (var c = 0; c < 3; ++c)
                    {
                        switch (c)
                        {
                            case 0:
                                color = "blu";
                                break;
                            case 1:
                                color = "gre";
                                break;
                            case 2:
                                color = "red";
                                break;
                        }
                        for (var d = 0; d < 3; ++d)
                        {
                            switch(d)
                            {
                                case 0:
                                    shade = "emp";
                                    break;
                                case 1:
                                    shade = "hat";
                                    break;
                                case 2:
                                    shade = "sol";
                                    break;
                            }
                            string path = number + shape + color + shade;
                            Cards card = new Cards(path, color, shade, shape, number);
                            deck.Add(card);
                        }
                    }
                }
            }

            shuffleDeck();
            for (int i = 0; i < 12; ++i)
                getNewCard();
        }
예제 #3
0
파일: Data.cs 프로젝트: UgotAlan/SET
        private bool CheckSetOnBoard(List<Cards> listTwelve)
        {
            List<Cards> listThree = new List<Cards>();

            Cards card1 = new Cards();
            Cards card2 = new Cards();
            Cards card3 = new Cards();

            for (int i = 0; i < 12; ++i)
            {
                for (int j = 0; j < 12; ++j)
                {
                    if (j != i)
                    {
                        for (int k = 0; k < 12; ++k)
                        {
                            if (k != i && k != j)
                            {
                                listThree.Clear();

                                card1.Color = listTwelve.ElementAt(i).Color;
                                card1.Number = listTwelve.ElementAt(i).Number;
                                card1.Shade = listTwelve.ElementAt(i).Shade;
                                card1.Shape = listTwelve.ElementAt(i).Shape;

                                card2.Color = listTwelve.ElementAt(j).Color;
                                card2.Number = listTwelve.ElementAt(j).Number;
                                card2.Shade = listTwelve.ElementAt(j).Shade;
                                card2.Shape = listTwelve.ElementAt(j).Shape;

                                card3.Color = listTwelve.ElementAt(k).Color;
                                card3.Number = listTwelve.ElementAt(k).Number;
                                card3.Shade = listTwelve.ElementAt(k).Shade;
                                card3.Shape = listTwelve.ElementAt(k).Shape;

                                listThree.Insert(0, card1);
                                listThree.Insert(1, card2);
                                listThree.Insert(2, card3);

                                // If the current combination is a set, return true and exit the method.
                                if (CheckSet(listThree) == true)
                                {
                                    return true;
                                }
                            }
                        }
                    }
                }
            }

            // Return false if there are no possible SET combinations on the gameboard.
            return false;
        }