public static void Main() { int counter = 0; int players = 0; const int EDGE = 1000; Game game = new Game(); List <Card> Cards = new List <Card>(); Cards = game.CreateCardDeck(); game.Shuffling(ref Cards); Console.WriteLine("Choose count of players (6 maximum)."); try { players = Int32.Parse(Console.ReadLine()); if (players == 1) { throw new Exception(message: "You cant choose only one player."); } } catch (Exception ex) { Console.WriteLine(ex.Message); Main(); } for (int i = 0; i < players; i++) { Console.WriteLine("Enter the name of player."); string nameOfPlayer = Console.ReadLine(); game.AddPlayer(new Player(nameOfPlayer)); Console.Clear(); } game.GiveCardsToPlayers(); Console.WriteLine("Playing....."); while (!game.CardsOnTable()) { game.CardsOnTable(); counter++; if (counter == EDGE) { Console.Clear(); Console.WriteLine("|||||||||||||||||||||||||DRAW|||||||||||||||||||||||||"); Console.ReadKey(); return; } } Console.Clear(); Console.WriteLine(game.results); Console.ReadKey(); }
static void Main(string[] args) { Player player1 = new Player(); Player player2 = new Player(); Player player3 = new Player(); Player player4 = new Player(); Player player5 = new Player(); Game game = new Game(); game.AddPlayer(player1); game.AddPlayer(player2); game.AddPlayer(player3); game.AddPlayer(player4); game.AddPlayer(player5); game.Shuffle(); game.DistributeCards(); game.ShowCardsAllPlayers(); game.Gameplay(); }
static void Main(string[] args) { const int COUNTCARD = 36; List <Card> card = new List <Card>(); Game game = new Game(); Card cardTemp = new Card(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 9; j++) { cardTemp.CardLear = (CardLear)i; cardTemp.CardType = (CardType)j; card.Add(cardTemp); } } #region Menu string[] stringsMainMenu = { "Добавить игроков", "Начать игру", "Правила", "Выход" }; ConsoleMenu mainMenu = new ConsoleMenu(stringsMainMenu); int mainMenuResult; do { mainMenuResult = mainMenu.PrintMenu(); mainMenuResult++; switch (mainMenuResult) { case 1: Console.WriteLine("Введите имя игрока"); Player playerTmp = new Player(); playerTmp.Name = Console.ReadLine(); game.AddPlayer(playerTmp); Console.WriteLine("Игрок успешно добавлен!"); break; case 2: if (game.Player.Count >= 2) { int countCardOfPlayer = COUNTCARD / game.Player.Count; int countLayer = 0; Card cardTmp; for (int i = 0; i < game.Player.Count; i++) { Queue <Card> cardTmpQueue = new Queue <Card>(); for (int j = 0; j < countCardOfPlayer; j++) { countLayer++; cardTmp = new Card((CardLear)(countLayer), (CardType)((i + 1) * j)); cardTmpQueue.Enqueue(cardTmp); } game.Player[i].Card = cardTmpQueue; } Console.WriteLine("Игра началась!"); bool switchForWhile = true; Card maxCard = new Card(0, 0); int positionMaxCard = 0; for (int i = 0; i < game.Player.Count; i++) { Card cardtmp = game.Player[i].Card.Dequeue(); if ((int)cardtmp.CardType > (int)maxCard.CardType) { maxCard = cardtmp; positionMaxCard = i; } } game.Player[positionMaxCard].Card.Enqueue(maxCard); int countCardInPlayer = 0; int positionCountCardInPlayer = -1; for (int i = 0; i < game.Player.Count; i++) { if (game.Player[i].Card.Count >= countCardInPlayer) { countCardInPlayer = game.Player[i].Card.Count; positionCountCardInPlayer = i; } } Console.WriteLine("Победил; " + game.Player[positionCountCardInPlayer].Name); Console.ReadLine(); } else { Console.WriteLine("Недостаточно игроков!"); } break; case 3: Console.WriteLine(" Игровой процесс.\n" + "Принцип: Игроки кладут по одной карте. У кого карта больше, то тот игрок забирает все карты и кладет их в конец своей колоды.\n" + "Упрощение: при совпадении карт забирает первый игрок, шестерка не забирает туза. Выигрывает игрок, который забрал все карты.\n"); Console.WriteLine(" Управление.\n" + "По нажатию 'пробела' ход переходит другому игроку"); break; } } while (mainMenuResult != stringsMainMenu.Length); #endregion }