예제 #1
0
        //******************************************************************************************

        public Card(CardSymbol symbol, CardSuit suit)
        {
            Symbol = symbol;
            Suit   = suit;

            SetCardValue();
            SetCardStringRepresentation();
        }
예제 #2
0
    public void setValues(string value)
    {
        number = Int32.Parse(value.Substring(0, value.Length - 1));
        string symbolChar = value[value.Length - 1].ToString();

        symbol    = (CardSymbol)Enum.Parse(typeof(CardSymbol), symbolChar);
        clickable = false;
    }
예제 #3
0
        static public Image LoadCardImage(int card, CardSymbol symbol)
        {
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cards");

            filePath = Path.Combine(filePath, ((int)symbol).ToString() + "kar" + card + ".gif");

            if (!File.Exists(filePath))
            {
                return(null);
            }

            return(Image.FromFile(filePath));
        }
예제 #4
0
        /// <summary>
        /// Checks if all of the cards have the same suite
        /// </summary>
        /// <param name="cards">Held cards</param>
        /// <returns>Returns true if all of the hands have same suite</returns>
        private bool CheckForSameSuite(Card[] cards)
        {
            for (int i = 0; i < Card.amountOfSuits; i++)
            {
                CardSymbol checkedCardSymbol = (CardSymbol)i;

                if (cards.All(x => x.cardSymbol.Equals(checkedCardSymbol)))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #5
0
        /// <summary>
        /// Populates deck with automatically generated cards
        /// </summary>
        public void PopulateDeck()
        {
            for (int i = 0; i < Card.amountOfSuits; i++)
            {
                CardSymbol symbol = (CardSymbol)i;

                for (int j = 0; j < Card.amountOfRanks; j++)
                {
                    CardRank rank = (CardRank)j;

                    availableCards.Add(new Card {
                        cardRank   = rank,
                        cardSymbol = symbol
                    });
                }
            }
        }
        public static string GetImage(CardSymbol Symbol, int Number)
        {
            string url = "{0}_of_{1}.png";

            switch (Number)
            {
            case 2:
                url = url.Replace("{0}", "2");
                break;

            case 3:
                url = url.Replace("{0}", "3");
                break;

            case 4:
                url = url.Replace("{0}", "4");
                break;

            case 5:
                url = url.Replace("{0}", "5");
                break;

            case 6:
                url = url.Replace("{0}", "6");
                break;

            case 7:
                url = url.Replace("{0}", "7");
                break;

            case 8:
                url = url.Replace("{0}", "8");
                break;

            case 9:
                url = url.Replace("{0}", "9");
                break;

            case 10:
                url = url.Replace("{0}", "10");
                break;

            case 11:
                url = url.Replace("{0}", "jack");
                break;

            case 12:
                url = url.Replace("{0}", "queen");
                break;

            case 13:
                url = url.Replace("{0}", "king");
                break;

            case 14:
                url = url.Replace("{0}", "ace");
                break;

            default:
                throw new Exception("Not Found Image");
            }

            switch (Symbol)
            {
            case CardSymbol.Club:
                url = url.Replace("{1}", "clubs");
                break;

            case CardSymbol.Diamond:
                url = url.Replace("{1}", "diamonds");
                break;

            case CardSymbol.Heart:
                url = url.Replace("{1}", "hearts");
                break;

            case CardSymbol.Spade:
                url = url.Replace("{1}", "spades");
                break;

            default:
                throw new Exception("Not Found Image");
            }

            return(url);
        }