internal void GotABlackJack(Gambler player, Gambler diller) { if (IsAceOnHend(player.playerCards) & IsFigureOnHend(player.playerCards)) { MoneyService.BlackJackWinnings(player); GameProvider.NewGameSelector(player, diller); } }
private bool MoneyCounter(Gambler player) { if (player.Cash > 0) { return(true); } return(false); }
internal void ClearGamblerData(Gambler player) { player.Bet = 0; player.EndTurn = false; player.IsLoose = false; player.PlayerPoint = 0; player.Style = HandStyle.Soft; player.playerCards.Clear(); }
internal void ChangeHand(Gambler player, Gambler diller) { if (player.Type == PlayerType.Player) { PlayerHand(player, diller); return; } DillerHand(player); }
private void CardCounter(Gambler player) { int points = 0; foreach (var card in player.playerCards) { points += card.Point; } player.PlayerPoint = points; }
internal static void OneTurn(Gambler player, Gambler diller) { if (player.Type == PlayerType.Player) { _gamblerService.PlayerGame(player, diller); return; } _gamblerService.DillerTurn(player, diller); }
internal static void ClasicWinnings(Gambler player) { Console.WriteLine($"{player.Name} Victory!"); var winnings = player.Bet * MoneyConst.StandartWinnings; Console.WriteLine($"Your winnings is {winnings}, your bet {player.Bet} will be added to the winnings"); player.Cash += player.Bet + (int)winnings; }
internal static void BlackJackWinnings(Gambler player) { Console.WriteLine($"BjackJack!!!!!!!!!!!!!{player.Name} Victory!!!"); var winnings = player.Bet * MoneyConst.BlackJackWinnings; Console.WriteLine($"Your winnings is {winnings}, your bet {player.Bet} will be added to the winnings"); player.Cash += player.Bet + (int)winnings; }
internal static void ExitGame(Gambler player, Gambler diller) { if (player.EndTurn & diller.EndTurn) { _victoryConditions.CheckVictoryConditions(player, diller); return; } Game.eventMessage.HandleGameEvent(EventMessageConst.EndGameMessage); Console.ReadLine(); Environment.Exit(0); }
private void GoForTheMoney(Gambler player, Gambler diller) { Dictionary <string, Action <Gambler, Gambler> > choiseOperations = new Dictionary <string, Action <Gambler, Gambler> > { { EventMessageConst.YesKey, AddMoney }, { EventMessageConst.NoKey, GameProvider.ExitGame }, { EventMessageConst.Default, GoForTheMoney } }; Game.eventMessage.HandleGameEvent(EventMessageConst.NotEnoughMoney); Game.eventMessage.WorkWithGamblerDictionary(player, diller, choiseOperations); }
internal void CheckVictoryConditions(Gambler player, Gambler diller) { if (player.IsLoose & diller.IsLoose || player.PlayerPoint == diller.PlayerPoint) { Console.WriteLine($"{player.Name} and {diller.Name} dead heat !!!"); player.Cash += player.Bet; GameProvider.NewGameSelector(player, diller); return; } CheckAllConditions(player, diller); }
private void CheckAllConditions(Gambler player, Gambler diller) { if (player.PlayerPoint > diller.PlayerPoint & !player.IsLoose) { Console.WriteLine($"{player.Name} Victory!!!"); MoneyService.ClasicWinnings(player); GameProvider.NewGameSelector(player, diller); return; } DillerVictory(player, diller); }
private static void HardHandStyle(Gambler player, Gambler diller) { player.Style = HandStyle.Hard; for (int i = 0; i < player.playerCards.Count; i++) { if (player.playerCards[i].Rank == Rank.Ace) { player.playerCards[i].Point = (int)Rank.AceByHardHand; break; } } }
private void PlayerHand(Gambler player, Gambler diller) { Dictionary <string, Action <Gambler, Gambler> > choiseOperations = new Dictionary <string, Action <Gambler, Gambler> > { { EventMessageConst.YesKey, HardHandStyle }, { EventMessageConst.NoKey, PlayerGame }, { EventMessageConst.Default, PlayerHand } }; Game.eventMessage.HandleGameEvent(EventMessageConst.ChangeHandMessage); Game.eventMessage.WorkWithGamblerDictionary(player, diller, choiseOperations); }
internal void DillerTurn(Gambler diller, Gambler player) { if (diller.PlayerPoint < GamblerConst.DillerMaxHandPoint) { GameProvider.NextTurnGame(diller, player); return; } diller.IsLoose = VictoryConditions.IsLosing(diller); diller.EndTurn = true; GameProvider.ExitGame(player, diller); }
internal void EnterBet(Gambler player, Gambler diller) { if (MoneyCounter(player)) { Console.WriteLine($"You have {player.Cash}. Enter you bet"); BetCounter(player, diller); return; } GoForTheMoney(player, diller); GameProvider.NewGameSelector(player, diller); }
internal void PlayerGame(Gambler player, Gambler diller) { Dictionary <string, Action <Gambler, Gambler> > choiseOperations = new Dictionary <string, Action <Gambler, Gambler> > { { EventMessageConst.YesKey, GameProvider.NextTurnGame }, { EventMessageConst.NoKey, DillerGame }, { EventMessageConst.Default, PlayerGame } }; Game.eventMessage.HandleGameEvent(EventMessageConst.AddCardMessage); Game.eventMessage.WorkWithGamblerDictionary(player, diller, choiseOperations); }
private static void EnterName(Gambler player, Gambler diller) { diller.Name = GamblerConst.DillerName; player.Name = "Player"; Console.WriteLine("Enter your Name"); var name = Console.ReadLine(); if (!string.IsNullOrEmpty(name) && Regex.Match(name, Game.regularExpression).Success) { player.Name = name; } }
internal void WorkWithGamblerDictionary(Gambler player, Gambler diller, Dictionary <string, Action <Gambler, Gambler> > choiseOperations) { var choise = StringCheck(); if (choiseOperations.ContainsKey(choise) & Regex.Match(choise, Game.regularExpression).Success) { choiseOperations[choise](player, diller); return; } HandleGameEvent(EventMessageConst.InvalidInputMessage); choiseOperations[EventMessageConst.Default](player, diller); }
private void DillerVictory(Gambler player, Gambler diller) { if (!diller.IsLoose) { Console.WriteLine($"{player.Name} Bust! The game is over"); GameProvider.NewGameSelector(player, diller); return; } Console.WriteLine($"{diller.Name} Bust! The game is over"); MoneyService.ClasicWinnings(player); GameProvider.NewGameSelector(player, diller); }
internal static void NextTurnGame(Gambler player, Gambler diller) { player.playerCards.Add(_cardService.AddCard(ref Game.deck)); Console.Clear(); _cardService.ShowCards(player); _cardService.ShowCards(diller); if (VictoryConditions.IsAceOnHend(player.playerCards) & player.Style == HandStyle.Soft & !player.EndTurn) { _gamblerService.ChangeHand(player, diller); _cardService.ShowCards(player); } OneTurn(player, diller); }
private void DillerHand(Gambler diller) { if (diller.PlayerPoint > GamblerConst.DillerMaxHandPoint) { diller.Style = HandStyle.Hard; for (int i = 0; i < diller.playerCards.Count; i++) { if (diller.playerCards[i].Rank == Rank.Ace) { diller.playerCards[i].Point = 1; break; } } } }
internal static void NewGameSelector(Gambler player, Gambler diller) { _gamblerService.ClearGamblerData(player); _gamblerService.ClearGamblerData(diller); Dictionary <string, Action <Gambler, Gambler> > choiseOperations = new Dictionary <string, Action <Gambler, Gambler> > { { EventMessageConst.YesKey, FirstDistribution }, { EventMessageConst.NoKey, ExitGame }, { EventMessageConst.Default, NewGameSelector } }; Game.eventMessage.HandleGameEvent(EventMessageConst.StartGameMessage); Game.eventMessage.WorkWithGamblerDictionary(player, diller, choiseOperations); }
private void BetCounter(Gambler player, Gambler diller) { int bet = 0; bool isBetDone = int.TryParse(Console.ReadLine(), out bet); if (isBetDone & bet <= player.Cash) { player.Bet = bet; player.Cash -= bet; return; } Game.eventMessage.HandleGameEvent(EventMessageConst.InvalidInputMessage); EnterBet(player, diller); }
internal static void FirstDistribution(Gambler player, Gambler diller) { if (player.Name == null) { EnterName(player, diller); } _moneyOp.EnterBet(player, diller); player.playerCards = _cardService.AddTwoCard(ref Game.deck); diller.playerCards = _cardService.AddTwoCard(ref Game.deck); Console.Clear(); _cardService.ShowCards(player); _cardService.ShowCards(diller); _victoryConditions.GotABlackJack(player, diller); OneTurn(player, diller); }
internal void ShowCards(Gambler player) { Console.WriteLine(player.Name + "\n"); foreach (var card in player.playerCards) { Console.WriteLine("{0} {1} {2}", card.Rank, card.Suit, card.Point); } CardCounter(player); if (player.Type == PlayerType.Player) { Console.WriteLine("---------------------"); Console.WriteLine($"Total points: {player.PlayerPoint}"); Console.WriteLine($"Player bet: {player.Bet}"); Console.WriteLine($"Player cash: {player.Cash}"); Console.WriteLine("---------------------"); return; } Console.WriteLine("---------------------"); Console.WriteLine($"Total points: {player.PlayerPoint}"); Console.WriteLine("---------------------"); }
internal static bool IsLosing(Gambler player) { bool isLosing = player.PlayerPoint > GamblerConst.MaxPoint; return(isLosing); }
private void AddMoney(Gambler player, Gambler diller) { player.Cash = 200; }
internal void DillerGame(Gambler player, Gambler diller) { player.EndTurn = true; player.IsLoose = VictoryConditions.IsLosing(player); DillerTurn(diller, player); }