Esempio n. 1
0
        static void Main(string[] args)
        {
            CustomLogger.InitializeLogger("C:/logs/pokerLogs.txt");

            var handEvaluator = new HandEvaluator();
            var poker = new Poker.PokerGame.Poker(new StaticBlindsController(10));
            poker.AddPlayer(new Player(new ConsolePlayerController(), new Wallet(15000)) { Name = "Benas" });
            poker.AddPlayer(new Player(new AlwaysCallPlayerController(), new Wallet(10000)) { Name = "Benas2" });
            poker.OnChange(() => Update(poker, handEvaluator));
            poker.Start(() => false);
        }
        public GameController()
        {
            ViewModel = new GameViewModel(this);
            PokerGameObject = new Poker.PokerGame.Poker(new StaticBlindsController(10));
            View = new GameView() { DataContext = ViewModel };
            PokerGameObject.OnChange(UpdateUI);

            token = tokenSource.Token;

            var task = Task.Factory.StartNew(() =>
            {
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas1"});
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas2"});
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas3"});
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas4"});
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas5"});
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas6"});
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas7"});
                PokerGameObject.AddPlayer(new Player(this, new Wallet(1000)) {Name = "Benas8"});
                PokerGameObject.Start(() => token.IsCancellationRequested);
            }, token);

            View.Closed += (sender, args) => tokenSource.Cancel();
        }
Esempio n. 3
0
        static void Update(Poker.PokerGame.Poker poker, HandEvaluator handEvaluator)
        {
            var table = poker.GetData();
            System.Console.Clear();

            var hand = handEvaluator.EvaluateCards(Enumerable.Concat(table.ActivePlayer.Cards, table.DealerCards).ToList());

            System.Console.WriteLine(@"Turn: {0}", table.ActivePlayer.Name);
            System.Console.Write(@"Your best hand: {0} ", hand.Rank);
            foreach (var card in hand.HandCards)
            {
                System.Console.Write(@"{0} ", ShortStringCard(card));
            }
            System.Console.WriteLine();

            System.Console.WriteLine(@"      -----------------------------------");
            System.Console.WriteLine(@"    /                                     \");
            System.Console.WriteLine(@"   /                                       \");
            System.Console.WriteLine(@"  /             {0,-14}              \", table.DealerCards.Count >= 1 ? table.DealerCards[0].ToString() : new string('?', 14));
            System.Console.WriteLine(@" /              {0,-14}               \", table.DealerCards.Count >= 2 ? table.DealerCards[1].ToString() : new string('?', 14));
            System.Console.WriteLine(@"|               {0,-14}                |", table.DealerCards.Count >= 3 ? table.DealerCards[2].ToString() : new string('?', 14));
            System.Console.WriteLine(@"|               {0,-14}                |", table.DealerCards.Count >= 4 ? table.DealerCards[3].ToString() : new string('?', 14));
            System.Console.WriteLine(@"|               {0,-14}                |", table.DealerCards.Count >= 5 ? table.DealerCards[4].ToString() : new string('?', 14));
            System.Console.WriteLine(@"|                  ${0,-6}                    |", table.Pot);
            System.Console.WriteLine(@"|                                             |");
            System.Console.WriteLine(@" \                                           /");
            System.Console.WriteLine(@"  \                                         /");

            System.Console.Write(@"   \    ");
            foreach (var player in table.Players)
            {
                var bet = table.Bets.FirstOrDefault(x => x.Player == player);
                System.Console.Write("${0,-11}", bet == null ? 0 : bet.Amount);
            }
            System.Console.WriteLine(@"    /");

            System.Console.Write(@"    \  ");
            foreach (var player in table.Players)
            {
                var firstCard = player.Cards.Count >= 1 ?
                    string.Format("{0} ", ShortStringCard(player.Cards[0]))
                    : string.Format("{0} ", "?");

                var secondCard = player.Cards.Count >= 2 ?
                    string.Format("{0}", ShortStringCard(player.Cards[1]))
                    : string.Format("{0}", "?", "");

                System.Console.Write("{0,-11}", firstCard + " " + secondCard);
            }
            System.Console.WriteLine("    /");
            System.Console.WriteLine(@"      -----------------------------------");

            System.Console.Write(@"      ");
            foreach (var player in table.Players)
            {
                System.Console.Write("{0,-13}", player.Name);
            }
            System.Console.WriteLine("");

            System.Console.Write(@"      ");
            foreach (var player in table.Players)
            {
                System.Console.Write("${0,-12}", player.Wallet.Money);
            }
            System.Console.WriteLine(@"                                      ");
            System.Console.WriteLine(@"	   Fold, Call, Raise, Check");
        }