Exemplo n.º 1
0
        public void AddGamer(PokerGamer pokerGamer)
        {
            if(_pokerGamers.Any(x=>x.Name == pokerGamer.Name))
                throw new Exception("User with this name has already joined to the PockerTable.");
            if(pokerGamer.Cards == null || pokerGamer.Cards.Count != _pokerRulesService.GetRulesPokerTable().CountCardsPerHand)
                throw new Exception("Count of Card for this User not match with Rules.");

            _pokerGamers.Add(pokerGamer);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Init();
            _pokerTableService.ConfigureRules(new PokerRules() { CountCardsPerHand = 5 });

            System.Console.WriteLine("Poker");
            System.Console.WriteLine("Rules: Count of cards per hand is 5" + Environment.NewLine);
            System.Console.WriteLine("Gamers:");

            var countGamers = _random.Next(_names.Count / 3, _names.Count);
            for (int i = 0; i < countGamers; i++)
            {
                var name = _names.ElementAt(_random.Next(_names.Count));
                _names.Remove(name);
                var cards = _pokerTableService.GetPokerCardsFromDeck();
                var gamer = new PokerGamer(name, cards);
                _pokerTableService.AddGamer(gamer);

                System.Console.WriteLine($"{name} - {string.Join(",", cards.OrderByDescending(x=>x.Number).Select(x => $"{x.Number}_{x.Suit}"))}" + Environment.NewLine);
            }

            var gameResult = _pokerTableService.PlayGame();
            System.Console.WriteLine(Environment.NewLine + "Result of the Game:" + Environment.NewLine);

            foreach (var gamerPokerHand in gameResult.GamerPokerHands)
            {
                System.Console.WriteLine($"{gamerPokerHand.Gamer.Name} - {gamerPokerHand.PokerHand}");
            }

            System.Console.WriteLine(Environment.NewLine + "Winners:" + Environment.NewLine);
            foreach (var winner in gameResult.Winners)
            {
                System.Console.WriteLine($"{winner.Gamer.Name}");
            }
            System.Console.Read();
        }
Exemplo n.º 3
0
 public GamerPokerHand(PokerGamer gamer, PokerHands pokerHand)
 {
     Gamer = gamer;
     PokerHand = pokerHand;
 }