示例#1
0
 internal void GotABlackJack(Gambler player, Gambler diller)
 {
     if (IsAceOnHend(player.playerCards) & IsFigureOnHend(player.playerCards))
     {
         MoneyService.BlackJackWinnings(player);
         GameProvider.NewGameSelector(player, diller);
     }
 }
示例#2
0
 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);
 }
示例#5
0
        private void CardCounter(Gambler player)
        {
            int points = 0;

            foreach (var card in player.playerCards)
            {
                points += card.Point;
            }
            player.PlayerPoint = points;
        }
示例#6
0
        internal static void OneTurn(Gambler player, Gambler diller)
        {
            if (player.Type == PlayerType.Player)
            {
                _gamblerService.PlayerGame(player, diller);
                return;
            }

            _gamblerService.DillerTurn(player, diller);
        }
示例#7
0
        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;
        }
示例#8
0
        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;
        }
示例#9
0
 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);
 }
示例#10
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);
        }
示例#11
0
        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);
        }
示例#12
0
        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);
        }
示例#13
0
 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;
         }
     }
 }
示例#14
0
        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);
        }
示例#15
0
        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);
        }
示例#16
0
        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);
        }
示例#17
0
        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);
        }
示例#18
0
        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;
            }
        }
示例#19
0
        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);
        }
示例#20
0
        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);
        }
示例#21
0
        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);
        }
示例#22
0
 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;
             }
         }
     }
 }
示例#23
0
        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);
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
        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("---------------------");
        }
示例#27
0
        internal static bool IsLosing(Gambler player)
        {
            bool isLosing = player.PlayerPoint > GamblerConst.MaxPoint;

            return(isLosing);
        }
示例#28
0
 private void AddMoney(Gambler player, Gambler diller)
 {
     player.Cash = 200;
 }
示例#29
0
 internal void DillerGame(Gambler player, Gambler diller)
 {
     player.EndTurn = true;
     player.IsLoose = VictoryConditions.IsLosing(player);
     DillerTurn(diller, player);
 }