Beispiel #1
0
        public List <Card> newDistribute(int quantity)
        {
            if (20 >= cardDeck.Count)
            {
                cardDeck = CardDeckMaker.GetCardDeck();
            }
            int         numberOfCard;
            Random      rnd = new Random();
            List <Card> returnedCardList = new List <Card>();

            for (int i = quantity; 0 != i; i--)
            {
                numberOfCard = rnd.Next(0, cardDeck.Count);
                int  j = 0;
                int  k = 0;
                Card remuvedCardFromCardList = new Card();
                foreach (var card in cardDeck)
                {
                    if (j == numberOfCard)
                    {
                        returnedCardList.Add(card);
                        remuvedCardFromCardList = card;
                        k = 1;
                    }
                    j++;
                }
                if (0 != k)
                {
                    cardDeck.Remove(remuvedCardFromCardList);
                }
            }
            return(returnedCardList);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            int             numberOfPlayers = 2;
            CardDistributor cardDistributor = new CardDistributor(CardDeckMaker.GetCardDeck());
            Diller          diller          = new Diller(cardDistributor, numberOfPlayers);
            Player          player          = new Player(diller, cardDistributor);

            diller.ConnectWithPlayer = player;
            diller.newDistribut();
            while (true)
            {
                Console.Clear();
                Console.WriteLine("\tКарты диллера");
                Console.WriteLine();
                diller.ShowCards();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("\tВаши карты");
                Console.WriteLine();
                player.ShowCards();
                Console.WriteLine();
                Console.WriteLine("\tЧтобы взять карту, нажмите 1");
                Console.WriteLine("\tЧтобы вскрыть диллера, нажмите 2");
                player.ScoreCount();
                diller.ScoreCount();
                if (diller.CardsDisplayFlag)
                {
                    continue;
                }
                char key = Console.ReadKey().KeyChar;
                switch (key)
                {
                case '1':
                    player.GetOneCard();
                    break;

                case '2':
                    diller.OpenDiller();
                    break;
                }
            }
        }