void OnMouseDown()
    {
        if (deck.DeckCount() == 0)
        {
            return;
        }
        GameObject[] cards = deck.DrawCards(1);
        foreach (GameObject cardObject in cards)
        {
            Card c = cardObject.GetComponent <Card>();
            c.AnimateCard(transform, hand, 1.0f);
        }

        UpdateDeckDisplay();
    }
Beispiel #2
0
        public void DrawCards_drawTwoCards_deckHasTwoLessCards()
        {
            GameObject test = new GameObject();

            test.name = "DrawCards_drawTwoCards_deckHasTwoLessCards";
            GameObject  obj  = Helpers.MakeDeckObject(test.transform);
            DeckActions deck = obj.GetComponent <DeckActions> ();

            GameObject[] cardsToAdd = Helpers.MakeCards(4, test.transform);
            deck.AddCards(cardsToAdd);
            int deckCountBeforeDraw = deck.DeckCount();

            deck.DrawCards(2);

            int  deckCountAfterDraw = deck.DeckCount();
            bool deckIsTwoLess      = ((deckCountBeforeDraw - deckCountAfterDraw) == 2);

            Assert.That(deckIsTwoLess);
            GameObject.DestroyImmediate(test);
        }
Beispiel #3
0
        public void AddCards_insertTwoCards_deckHasTwoCards()
        {
            GameObject test = new GameObject();

            test.name = "AddCards_insertTwoCards_deckHasTwoCards";
            GameObject  obj  = Helpers.MakeDeckObject(test.transform);
            DeckActions deck = obj.GetComponent <DeckActions> ();

            GameObject[] cardsToAdd = Helpers.MakeCards(2, test.transform);

            deck.AddCards(cardsToAdd);

            bool deckHasTwoCards = (deck.DeckCount() == 2);

            Assert.That(deckHasTwoCards);
            GameObject.DestroyImmediate(test);
        }
Beispiel #4
0
        public void AddCards_insertOneCard_deckHasOneCard()
        {
            GameObject test = new GameObject();

            test.name = "AddCards_insertOneCard_deckHasOneCard";
            //arrange
            GameObject obj = Helpers.MakeDeckObject(test.transform);

            obj.transform.parent = test.transform;
            DeckActions deck = obj.GetComponent <DeckActions> ();

            GameObject[] cardToAdd = Helpers.MakeCards(1, test.transform);
            //act
            deck.AddCards(cardToAdd);
            //assert
            bool deckHasOneCard = (deck.DeckCount() == 1);

            Assert.That(deckHasOneCard);
            //cleanup
            GameObject.DestroyImmediate(test);
        }
Beispiel #5
0
        public void DrawCards_draw4CardsOutOfDeckOf2With2Discards_deckAndDiscardsEmpty()
        {
            GameObject test = new GameObject();

            test.name = "DrawCards_draw4CardsOutOfDeckOf2With2Discards_deckAndDiscardsEmpty";
            GameObject  obj  = Helpers.MakeDeckObject(test.transform);
            DeckActions deck = obj.GetComponent <DeckActions> ();

            GameObject[] cardsToAdd = Helpers.MakeCards(2, test.transform);
            deck.AddCards(cardsToAdd);
            GameObject[] cardsToDiscard = Helpers.MakeCards(2, test.transform);
            deck.DiscardCards(cardsToDiscard);

            deck.DrawCards(4);

            int deckCount    = deck.DeckCount();
            int discardCount = deck.DiscardCount();
            //Debug.Log (deckCount);
            //Debug.Log (discardCount);
            bool decksAreEmpty = (0 == (deckCount + discardCount));

            Assert.That(decksAreEmpty);
            GameObject.DestroyImmediate(test);
        }