コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //Колода
            List <Card> deck = new List <Card>();

            for (int i = 1; i < 5; i++)
            {
                for (int j = 6; j < 15; j++)
                {
                    deck.Add(new Card((CardSuit)i, (CardNominal)j));
                }
            }
            List <Card> playerhand = new List <Card>();
            List <Card> bothand    = new List <Card>();
            Random      random     = new Random();

            ///Рука бота
            for (int i = 0; i < 6; i++)
            {
                int randomcardBot = random.Next(0, deck.Count);
                bothand.Add(deck[randomcardBot]);
                deck.RemoveAt(randomcardBot);
            }
            ///Рука Человека
            for (int i = 0; i < 6; i++)
            {
                int randomcardUser = random.Next(0, deck.Count);
                playerhand.Add(deck[randomcardUser]);
                deck.RemoveAt(randomcardUser);
            }

            int  KozirRandom = random.Next(0, deck.Count);
            Card Trump       = deck[KozirRandom];

            deck.RemoveAt(KozirRandom);
            Kozir.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + Trump.sourse));


            int User = 0;
            int Bot  = 0;
            //foreach (Image img in UserHand.Children)
            //{
            //    img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + playerhand[User].sourse));
            //    User++;
            //}

            int left = 35;

            for (int i = 0; i < 6; i++)
            {
                left += 70;
                CardImage img = new CardImage
                {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin = new Thickness(left, 80, 0, 0),
                    card   = playerhand[User],
                };

                img.MouseDown += OneUser_MouseDown;

                img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + playerhand[User].sourse));
                User++;
                UserHand.Children.Add(img);
            }


            left = 35;
            for (int i = 0; i < 6; i++)
            {
                left += 70;
                CardImage img = new CardImage
                {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin = new Thickness(left, 70, 0, 0),
                    card   = bothand[Bot],
                };

                img.MouseDown += OneBot_MouseDown;

                img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + bothand[Bot].sourse));
                Bot++;
                BotHand.Children.Add(img);
            }

            //foreach (Image img in BotHand.Children)
            //{
            //    img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + bothand[Bot].sourse));
            //    Bot++;
            //}
        }