private ConsoleKeyInfo ChooseGamerDraw() { ConsoleKeyInfo cki; while (true) { PrintInfo.PrintOtherMes(TypeMessage.FinishRound); cki = WorkKey.GetPressKey(); if (WorkKey.CompareKey(cki, ConsoleKey.Y) || WorkKey.CompareKey(cki, ConsoleKey.N)) { break; } } return(cki); }
public static void InitMenu(Deck deck, Game game, Croupier croupier, Player gamer) { Console.ForegroundColor = ConsoleColor.Green; ConsoleKeyInfo cki; while (true) { Console.Clear(); Console.WriteLine("\t\t\t\t Меню"); Console.WriteLine("\t\t\t F1 - Показать карты"); Console.WriteLine("\t\t\t F2 - Тасовать карты"); Console.WriteLine("\t\t\t F3 - Сбросить счет игры"); Console.WriteLine("\t\t\t F4 - Начать раунд"); Console.WriteLine("\t\t\t F10 - Выход"); cki = WorkKey.GetPressKey(); Console.Clear(); if (WorkKey.CompareKey(cki, ConsoleKey.F1)) { ShowAllDeck(deck); } if (WorkKey.CompareKey(cki, ConsoleKey.F2)) { Shuffle(deck); Console.WriteLine("Колода потасована"); } if (WorkKey.CompareKey(cki, ConsoleKey.F3)) { ClearScore(game, gamer); Console.WriteLine("Счет сброшен"); } if (WorkKey.CompareKey(cki, ConsoleKey.F4)) { StartRound(deck, game); } if (WorkKey.CompareKey(cki, ConsoleKey.F10)) { break; } else { Console.ReadKey(); } } }
public void StartRound() { InitRound(_croupier, _gamer); _gamerSpot = PlayerSpot(_gamer); _croupierSpot = PlayerSpot(_croupier); // if gamer has 21 spot and croupier has less 10 then win if (_gamerSpot == 21 && _croupierSpot < 10) { FinishRound(ResultGame.Win); return; } // if gamer has 21 spot and croupier has 10 or 11 then gamer can say Draw if (_gamerSpot == 21 && (_croupierSpot == 10 || _croupierSpot == 11)) { if (WorkKey.CompareKey(ChooseGamerDraw(), ConsoleKey.Y)) { FinishRound(ResultGame.Draw); return; } } StepGamer(); _gamerSpot = PlayerSpot(_gamer); if (_gamerSpot > 21) { FinishRound(ResultGame.Loss); return; } CroupierTakeSecondCard(); _croupierSpot = PlayerSpot(_croupier); // Croupier take second card and if croupier's spot = 21 then loss if (_croupierSpot == 21) { FinishRound(ResultGame.Loss); return; } StepCoupier(); _gamerSpot = PlayerSpot(_gamer); _croupierSpot = PlayerSpot(_croupier); ResultBlackJack(_croupierSpot, _gamerSpot); }
private void StepGamer() { ConsoleKeyInfo cki; while (_gamer.State == StatusPlayer.Play) { PrintInfo.PrintOtherMes(TypeMessage.MenuPlayer); cki = WorkKey.GetPressKey(); //Gamer take one card if (WorkKey.CompareKey(cki, ConsoleKey.F5)) { StepGamerTakeOneCard(_gamer); } //Gamer refuse one card if (WorkKey.CompareKey(cki, ConsoleKey.F6)) { } // Gamer say Enough if (WorkKey.CompareKey(cki, ConsoleKey.F7)) { _gamer.State = StatusPlayer.Enough; } } }