Ejemplo n.º 1
0
        private async Task CheckRaise(int currentTurn, int raiseTurn)
        {
            if (this.raising)
            {
                this.turnCount = 0;
                this.raising = false;
                this.raisedTurn = currentTurn;
                this.changed = true;
            }
            else
            {
                if (this.turnCount >= this.playersLeft - 1 || !this.changed && this.turnCount == this.playersLeft)
                {
                    if (currentTurn == this.raisedTurn - 1 || !this.changed && this.turnCount == this.playersLeft ||
                        this.raisedTurn == 0 && currentTurn == 5)
                    {
                        this.changed = false;
                        this.turnCount = 0;
                        this.raise = 0;
                        this.neededChipsToCall = 0;
                        this.raisedTurn = 123;
                        this.rounds++;
                        if (!this.Player.OutOfChips)
                        {
                            this.playerStatus.Text = string.Empty;
                        }

                        if (!this.FirstBot.OutOfChips)
                        {
                            this.botOneStatus.Text = string.Empty;
                        }

                        if (!this.SecondBot.OutOfChips)
                        {
                            this.botTwoStatus.Text = string.Empty;
                        }

                        if (!this.ThirdBot.OutOfChips)
                        {
                            this.botThreeStatus.Text = string.Empty;
                        }

                        if (!this.FourthBot.OutOfChips)
                        {
                            this.botFourStatus.Text = string.Empty;
                        }

                        if (!this.FifthBot.OutOfChips)
                        {
                            this.botFiveStatus.Text = string.Empty;
                        }
                    }
                }
            }

            if (this.rounds == (int)RoundStage.Flop)
            {
                for (int j = 12; j <= 14; j++)
                {
                    if (this.cardPicture[j].Image != this.deck[j])
                    {
                        this.cardPicture[j].Image = this.deck[j];

                        ResetCall();

                        ResetRaise();
                    }
                }
            }

            if (this.rounds == (int)RoundStage.Turn)
            {
                this.cardPicture[15].Image = this.deck[15];

                ResetCall();

                ResetRaise();
            }

            if (this.rounds == (int)RoundStage.River)
            {
                this.cardPicture[16].Image = this.deck[16];

                ResetCall();

                ResetRaise();
            }

            if (this.rounds == (int)RoundStage.End && this.playersLeft == 6)
            {
                FixWinners();

                this.restart = true;
                this.Player.AbleToMakeTurn = true;
                this.Player.OutOfChips = false;
                this.FirstBot.OutOfChips = false;
                this.SecondBot.OutOfChips = false;
                this.ThirdBot.OutOfChips = false;
                this.FourthBot.OutOfChips = false;
                this.FifthBot.OutOfChips = false;

                // TODO: Add chips on two place.
                if (this.Player.Chips <= 0)
                {
                    AddChips addChips = new AddChips(this.messageBoxWriter);
                    addChips.ShowDialog();
                    if (addChips.AddedChips != 0)
                    {
                        this.Player.Chips = addChips.AddedChips;
                        this.FirstBot.Chips += addChips.AddedChips;
                        this.SecondBot.Chips += addChips.AddedChips;
                        this.ThirdBot.Chips += addChips.AddedChips;
                        this.FourthBot.Chips += addChips.AddedChips;
                        this.FifthBot.Chips += addChips.AddedChips;
                        this.Player.OutOfChips = false;
                        this.Player.AbleToMakeTurn = true;
                        this.raiseButton.Enabled = true;
                        this.foldButton.Enabled = true;
                        this.checkButton.Enabled = true;
                        this.raiseButton.Text = "Raise";
                    }
                }

                this.MakePlayersNonVisible();

                this.ResetCall();

                this.ResetRaise();

                this.neededChipsToCall = this.bigBlind;

                this.raise = 0;
                this.ImgLocation = Directory.GetFiles(@"..\..\Resources\Assets\Cards", "*.png",
                    SearchOption.TopDirectoryOnly);

                this.rounds = 0;

                this.winners = 0;

                this.ResetPower();

                this.ResetType();

                this.allInChips.Clear();
                this.CheckWinners.Clear();
                this.eliminatedPlayers.Clear();
                this.Win.Clear();

                this.sorted.Current = 0;
                this.sorted.Power = 0;

                for (int index = 0; index < 17; index++)
                {
                    this.cardPicture[index].Image = null;
                    this.cardPicture[index].Invalidate();
                    this.cardPicture[index].Visible = false;
                }

                this.potStatus.Text = "0";
                this.playerStatus.Text = string.Empty;

                await this.Shuffle();
                await this.Turns();
            }
        }
Ejemplo n.º 2
0
        private async Task Finish(int n)
        {
            if (n == 2)
            {
                this.FixWinners();
            }

            ResetStatsOfPlayers();

            // TODO: Here add chips, duplicate.
            if (this.Player.Chips <= 0)
            {
                AddChips addChips = new AddChips(this.messageBoxWriter);
                addChips.ShowDialog();
                if (addChips.AddedChips != 0)
                {
                    this.Player.Chips = addChips.AddedChips;
                    this.FirstBot.Chips += addChips.AddedChips;
                    this.SecondBot.Chips += addChips.AddedChips;
                    this.ThirdBot.Chips += addChips.AddedChips;
                    this.FourthBot.Chips += addChips.AddedChips;
                    this.FifthBot.Chips += addChips.AddedChips;

                    this.Player.OutOfChips = false;
                    this.Player.AbleToMakeTurn = true;
                    this.raiseButton.Enabled = true;
                    this.foldButton.Enabled = true;
                    this.checkButton.Enabled = true;
                    this.raiseButton.Text = "Raise";
                }
            }

            this.ImgLocation = Directory.GetFiles(@"..\..\Resources\Assets\Cards", "*.png",
                SearchOption.TopDirectoryOnly);

            for (int index = 0; index < 17; index++)
            {
                this.cardPicture[index].Image = null;
                this.cardPicture[index].Invalidate();
                this.cardPicture[index].Visible = false;
            }

            await this.Shuffle();

            //await Turns();
        }