public void Run()
        {
            //Start thread for UI
            var thread = new Thread(ThreadStart);

            thread.TrySetApartmentState(ApartmentState.STA);
            thread.Start();

            CreatePlayers();

            //Sets players in current game
            GenerateCurrPlayers();

            //врътка players
            GenerateCyclePlayers();


            dealer.FillDeck(database, cardFactory);
            dealer.Shuffle(database.Deck);
            dealer.DealCards(database.Deck, database.HumanPlayers, database.BotPlayers, database.TableCards);

            //Sets players power depending on their cards combinations
            SetPlayersPower();

            AddBlindsToPot();
        }
Ejemplo n.º 2
0
        public void Match()
        {
            _dealer.Shuffle();
            if (!_dealer.PeekAtDeck())
            {
                throw new Exception("No Cards in Deck");
            }

            var lastCard = _dealer.Deal();
            var cards    = new List <Card>()
            {
                lastCard
            };

            while (_dealer.PeekAtDeck())
            {
                var card = _dealer.Deal();
                cards.Add(card);
                if (_matchCondition.IsMatch(lastCard, card))
                {
                    if (_rdm.Next(2) == 1)
                    {
                        _player1.GiveCards(cards);
                    }
                    else
                    {
                        _player2.GiveCards(cards);
                    }

                    if (!_dealer.PeekAtDeck())
                    {
                        break;
                    }

                    lastCard = _dealer.Deal();
                    cards    = new List <Card>()
                    {
                        lastCard
                    };
                }
                else
                {
                    lastCard = card;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Play next game round. Game Status change to GameOver when there are no more rounds to play.
        /// </summary>
        public void PlayRound()
        {
            if (!this.CanPlayRound())
            {
                return;
            }

            var shuffledDeck = _dealer.Shuffle(_deck);

            _dealer.Deal(shuffledDeck, Players, 2);
            var score = _dealer.ScorePlayers(Players);

            Rounds.Add(new Round(Rounds.Count + 1, score));

            Status = Rounds.Count == NumberOfRounds
                ? GameStatus.GameOver
                : GameStatus.InProgress;

            if (Status == GameStatus.GameOver)
            {
                GameOver();
            }
        }
Ejemplo n.º 4
0
 public void PlayRound(List <IPlayer> players, ushort numberOfShuffles, ushort handSize)
 {
     _dealer.Shuffle(numberOfShuffles);
     _dealer.Deal(players, handSize);
 }