Ejemplo n.º 1
0
    public List <Card> FindSet()
    {
        List <Card> found = new List <Card>();

        found.Add(null);
        found.Add(null);
        found.Add(null);

        /*
         * Pick any two cards, then see if we have the third card we need
         */
        foreach (Card card1 in currentCards)
        {
            found[0] = card1;
            foreach (Card card2 in currentCards)
            {
                if (card2 == card1)
                {
                    continue;
                }
                found[1] = card2;
                foreach (Card card3 in currentCards)
                {
                    if (card3 == card2 || card3 == card1)
                    {
                        continue;
                    }
                    found[2] = card3;
                    //check if this is a set
                    if (SetCheck.ValidateSet(found) == "")
                    {
                        Debug.Log("At least one set is available: " + card1 + ", " + card2 + ", " + card3);
                        return(found);
                    }
                }
            }
        }

        Debug.Log("No sets left");
        found.Clear();
        return(found);
    }
Ejemplo n.º 2
0
    public void SelectCard(CardObject card)
    {
        selectedCards.Add(card);
        if (selectedCards.Count == 3)
        {
            string err = SetCheck.ValidateSet(selectedCards);
            if (err == "")
            {
                err = "Set!";
                CollectSet(selectedCards);
                GameManager.instance.computerPlayer.ResetTimer();
            }
            else
            {
                err = "Not a set!\n" + err;
                if (sets.Count > 0)
                {
                    List <Card> giveBack = new List <Card>();
                    for (int i = 0; i < 3; i++)
                    {
                        giveBack.Add(sets[0]);
                        sets.RemoveAt(0);
                    }
                    GameManager.instance.cardManager.ReshuffleCards(giveBack);
                }
            }
            foreach (CardObject selected in selectedCards)
            {
                selected.Release();
            }
            selectedCards.Clear();

            //update set msg
            SetMsg(err);

            //update score
            SetScore();
        }
    }