示例#1
0
 private void CheckPlayerChipsAmount(ICharacter player)
 {
     if (player.Chips <= 0)
     {
         AddChips addChipsDialog = new AddChips();
         addChipsDialog.ShowDialog();
         if (addChipsDialog.ChipsValue != 0)
         {
             this.AddChips(this.GetAllPlayers(), addChipsDialog.ChipsValue);
             player.FoldTurn = false;
             player.IsInTurn = true;
         }
     }
 }
示例#2
0
        private bool CheckIfHumanContinues()
        {
            bool humanContinues = this.CheckIfHumanHasChips();

            if (humanContinues)
            {
                return(true);
            }

            AddChips addChipsOption = new AddChips();

            addChipsOption.ShowDialog();

            int addedAmount = addChipsOption.AddedChips;

            GameHandlerUtil.PlayersAddChips(this.Database.Players, addedAmount);

            humanContinues = addedAmount > 0;

            return(humanContinues);
        }
示例#3
0
 private void CheckPlayerChipsAmount(ICharacter player)
 {
     if (player.Chips <= 0)
     {
         AddChips addChipsDialog = new AddChips();
         addChipsDialog.ShowDialog();
         if (addChipsDialog.ChipsValue != 0)
         {
             this.AddChips(this.GetAllPlayers(), addChipsDialog.ChipsValue);
             player.FoldTurn = false;
             player.IsInTurn = true;
         }
     }
 }
示例#4
0
        private async Task Finish(int numberOfWinners)
        {
            if (numberOfWinners > 1)
            {
                this.SetWinners();
            }

            this.Table.PokerCall = this.Table.BigBlind;
            this.Table.LastRaise = 0;
            this.Table.FoldedBots = 5;
            this.type = 0;
            this.Table.Rounds = 0;
            this.Table.LastRaise = 0;

            this.GameEnd = false;
            this.Table.IsRaising = false;

            this.Table.WinnersCount = 0;
            this.Table.PlayersInTheGame = 6;
            this.Table.LastBotPlayed = 123;
            this.Table.LastRaisedPlayerId = 1;
            this.playersNotGameEnded.Clear();
            this.winnersNames.Clear();
            this.playersWithoutChips.Clear();

            this.Table.TurnCount = 0;

            foreach (var player in this.Players)
            {
                if (player is Gamer)
                {
                    player.Turn = true;
                }
                else
                {
                    player.Turn = true;
                }
                player.CardPower = 0;
                player.PokerHandMultiplier = -1;
                player.GameEnded = false;
                player.Status = string.Empty;
                player.Folded = false;
                player.Call = 0;
                player.Raise = 0;
            }

            if (this.Gamer.Chips <= 0)
            {
                AddChips addChipsForm = new AddChips();
                addChipsForm.ShowDialog();
                if (addChipsForm.AddedChips != 0)
                {
                    this.Gamer.Chips = addChipsForm.AddedChips;
                    this.Players[1].Chips += addChipsForm.AddedChips;
                    this.Players[2].Chips += addChipsForm.AddedChips;
                    this.Players[3].Chips += addChipsForm.AddedChips;
                    this.Players[4].Chips += addChipsForm.AddedChips;
                    this.Players[5].Chips += addChipsForm.AddedChips;
                    this.Gamer.GameEnded = false;
                    this.Gamer.Turn = true;
                    this.Gamer.CanRaise = true;
                    this.Gamer.CanFold = true;
                    this.Gamer.CanCheck = true;
                    //this.form.buttonRaise.Enabled = true;
                    //this.form.buttonFold.Enabled = true;
                    //this.form.buttonCheck.Enabled = true;
                    //this.renderer.Draw(this.Players);
                    //TODO :  raise value setup
                    //this.form.buttonRaise.Text = "Raise";
                }
            }

            await this.SetupPokerTable();
        }
示例#5
0
        private async Task CheckForGameRound(int playerId)
        {
            if (this.Table.IsRaising)
            {
                this.Table.TurnCount = 0;
                this.Table.IsRaising = false;
                this.Table.LastRaisedPlayerId = playerId;
                this.tableIsChanged = true;
            }
            else
            {
                if ((this.Table.TurnCount >= this.Table.PlayersInTheGame - 1 || !this.tableIsChanged) &&
                    this.Table.TurnCount == this.Table.PlayersInTheGame)
                {
                    if ((playerId == this.Table.LastRaisedPlayerId - 1 || !this.tableIsChanged) &&
                        (this.Table.TurnCount == this.Table.PlayersInTheGame || this.Table.LastRaisedPlayerId == 0) &&
                        playerId == 5)
                    {
                        this.tableIsChanged = false;
                        this.Table.TurnCount = 0;
                        this.Table.LastRaise = 0;
                        this.Table.PokerCall = 0;
                        this.Table.LastRaisedPlayerId = 123;
                        this.Table.Rounds++;

                        foreach (var player in this.Players)
                        {
                            if (!player.GameEnded)
                            {
                                player.Status = string.Empty;
                            }
                        }

                        this.renderer.SetAllLabelStatus(this.Players);
                    }
                }
            }

            if (this.Table.Rounds == PokerFlop)
            {
                for (int cardForFlop = 12; cardForFlop <= 14; cardForFlop++)
                {
                    this.GameDealtCards[cardForFlop].IsVisible = true;
                    this.renderer.Draw(this.GameDealtCards[cardForFlop]);
                }

                foreach (var player in this.Players)
                {
                    player.Call = 0;
                    player.Raise = 0;
                }
            }

            if (this.Table.Rounds == PokerTurn)
            {
                for (int j = 14; j <= 15; j++)
                {
                    this.GameDealtCards[j].IsVisible = true;
                    this.renderer.Draw(this.GameDealtCards[j]);
                }

                foreach (var player in this.Players)
                {
                    player.Call = 0;
                    player.Raise = 0;
                }
            }

            if (this.Table.Rounds == PokerRiver)
            {
                for (int j = 15; j <= 16; j++)
                {
                    this.GameDealtCards[j].IsVisible = true;
                    this.renderer.Draw(this.GameDealtCards[j]);
                }

                foreach (var player in this.Players)
                {
                    player.Call = 0;
                    player.Raise = 0;
                }
            }

            if (this.Table.Rounds == PokerEndRound &&
                this.Table.PlayersInTheGame == 6)
            {
                string fixedLast = "";

                foreach (var player in this.Players)
                {
                    if (!player.Folded)
                    {
                        fixedLast = player.Name;
                    }
                }

                foreach (IPlayer player in this.Players)
                {
                    this.CalculateWinners(fixedLast, player);
                }

                this.GameEnd = true;

                this.Gamer.Turn = true;

                for (int playerIndex = 0; playerIndex < this.Players.Length; playerIndex++)
                {
                    this.Players[playerIndex].GameEnded = false;
                }

                if (this.Gamer.Chips <= 0)
                {
                    AddChips addChipsForm = new AddChips();

                    addChipsForm.ShowDialog();

                    if (addChipsForm.AddedChips != 0)
                    {
                        this.Gamer.Chips = addChipsForm.AddedChips;

                        this.Players[1].Chips += addChipsForm.AddedChips;
                        this.Players[2].Chips += addChipsForm.AddedChips;
                        this.Players[3].Chips += addChipsForm.AddedChips;
                        this.Players[4].Chips += addChipsForm.AddedChips;
                        this.Players[5].Chips += addChipsForm.AddedChips;

                        this.Gamer.GameEnded = false;
                        this.Gamer.Turn = true;
                        this.Gamer.CanRaise = true;
                        this.Gamer.CanFold = true;
                        this.Gamer.CanCheck = true;

                        this.renderer.Draw(this.Gamer);
                    }
                }

                for (int playerIndex = 0; playerIndex < this.Players.Length; playerIndex++)
                {
                    this.Players[playerIndex].Call = 0;
                    this.Players[playerIndex].Raise = 0;
                    this.Players[playerIndex].CardPower = 0;
                    this.Players[playerIndex].PokerHandMultiplier = -1;
                    this.Players[playerIndex].Call = 0;
                }

                this.Table.LastBotPlayed = 0;
                this.Table.PokerCall = this.Table.BigBlind;
                this.Table.LastRaise = 0;
                this.playersNotGameEnded.Clear();
                this.Table.Rounds = 0;
                this.type = 0;

                this.playersWithoutChips.Clear();
                this.winnersNames.Clear();
                this.Table.WinnersCount = 0;

                for (int os = 0; os < 17; os++)
                {
                    this.GameDealtCards[os].CardFrontImageUri = null;
                    this.GameDealtCards[os].IsVisible = false;
                }

                this.Table.Pot = 0;
                this.Gamer.Status = string.Empty;
                this.renderer.SetAllLabelStatus((IPlayer[])this.Players.Where(p => p.Name == "Player"));

                await this.ClaculateTurns();
            }
        }
示例#6
0
        public Task Finish(int n)
        {
            if (n == 2)
            {
                //FixWinners();
            }
            playerPanel.Visible = false;
            firstBotPanel.Visible = false;
            secondBotPanel.Visible = false;
            thirdBotPanel.Visible = false;
            fourthBotPanel.Visible = false;
            fifthBotPanel.Visible = false;

            call = bigBlind;
            raise = 0;
            foldedPlayers = 5;
            type = 0;
            rounds = 0;

            firstBotPower = 0;
            secondBotPower = 0;
            thirdBotPower = 0;
            fourthBotPower = 0;
            fifthBotPower = 0;
            playerPower = 0;

            playerType = -1;
            raise = 0;

            firstBotType = -1;
            secondBotType = -1;
            thirdBotType = -1;
            fourthBotType = -1;
            fifthBotType = -1;

            B1turn = false;
            B2turn = false;
            B3turn = false;
            B4turn = false;
            B5turn = false;
            botOneFirstTurn = false;
            botTwoFirstTurn = false;
            botThreeFirstTurn = false;
            botFourFirstTurn = false;
            botFiveFirstTurn = false;

            playerFolded = false;
            botOneFolded = false;
            botTwoFolded = false;
            botThreeFolded = false;
            b4Folded = false;
            b5Folded = false;

            PlayerFirstTurn = false;
            playerTurn = true;
            restart = false;
            isRaising = false;

            playerCall = 0;
            firstBotCall = 0;
            secondBotCall = 0;
            thirdBotCall = 0;
            fourthBotCall = 0;
            fifthBotCall = 0;

            playerRise = 0;
            firstBotRise = 0;
            secondBotRise = 0;
            thirdBotRise = 0;
            fourthBotRise = 0;
            fifthBotRise = 0;

            height = 0;
            width = 0;

            winners = 0;

            Flop = 1;
            Turn = 2;
            River = 3;
            End = 4;
            maxLeft = 6;

            last = 123;
            raisedTurn = 1;

            bools.Clear();
            //CheckWinners.Clear();
            //ints.Clear();
            //Win.Clear();
            //sorted.Current = 0;
            //sorted.Power = 0;
            //potChips.Text = "0";

            t = 60;
            up = 10000000;
            turnCount = 0;

            playerStatus.Text = "";
            firstBotStatus.Text = "";
            secondBotStatus.Text = "";
            thirdBotStatus.Text = "";
            fourthBotStatus.Text = "";
            fifthBotStatus.Text = "";

            if (Chips <= 0)
            {
                var f2 = new AddChips();
                f2.ShowDialog();
                if (f2.a != 0)
                {
                    Chips = f2.a;
                    firstBotChips += f2.a;
                    secondBotChips += f2.a;
                    thirdBotChips += f2.a;
                    fourthBotChips += f2.a;
                    fifthBotChips += f2.a;
                    PlayerFirstTurn = false;
                    playerTurn = true;
                    raiseButton.Enabled = true;
                    foldButton.Enabled = true;
                    checkButton.Enabled = true;
                    raiseButton.Text = "raise";
                }
            }

            ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly);
            for (var os = 0; os < 17; os++)
            {
                Holder[os].Image = null;
                Holder[os].Invalidate();
                Holder[os].Visible = false;
            }
            await Shuffle();
            //await Turns();
        }
示例#7
0
        /// <summary>
        /// This method is called each turn, if needed.
        /// Checks if bet is raised in the current turn.
        /// After last round determines the winners 
        /// and finalizes the game.
        /// </summary>
        /// <param name="currentTurn">The current turn</param>
        public async Task CheckRaise(int currentTurn)
        {
            if (this.raising)
            {
                this.turnCount = 0;
                this.raising = false;
                this.raisedTurn = currentTurn;
                this.changed = true;
            }
            else
            {
                //maxLeft-playerLeft(callnebager)
                if (this.turnCount >= this.maxLeft - 1 || !this.changed && this.turnCount == this.maxLeft)
                {
                    if (currentTurn == this.raisedTurn - 1 || !this.changed && this.turnCount == this.maxLeft ||
                        this.raisedTurn == 0 && currentTurn == 5)
                    {
                        this.changed = false;
                        this.turnCount = 0;
                        this.raise = 0;
                        this.call = 0;
                        this.raisedTurn = 123;
                        this.rounds++;

                        foreach (var item in this.dataBase.Players)
                        {
                            item.Status.Text = String.Empty;
                        }
                    }
                }
            }

            if (this.rounds == this.flop)
            {
                for (int j = 12; j <= 14; j++)
                {
                    if (this.cardsHolder[j].Image != this.cardsImageDeck[j])
                    {
                        this.cardsHolder[j].Image = this.cardsImageDeck[j];
                        foreach (var item in this.dataBase.Players)
                        {
                            item.Call = 0;
                            item.Raise = 0;
                        }

                    }
                }
            }

            if (this.rounds == this.turn)
            {
                for (int j = 14; j <= 15; j++)
                {
                    if (this.cardsHolder[j].Image != this.cardsImageDeck[j])
                    {
                        this.cardsHolder[j].Image = this.cardsImageDeck[j];
                        foreach (var item in this.dataBase.Players)
                        {
                            item.Call = 0;
                            item.Raise = 0;
                        }
                        
                    }
                }
            }

            if (this.rounds == this.river)
            {
                for (int j = 15; j <= 16; j++)
                {
                    if (this.cardsHolder[j].Image != this.cardsImageDeck[j])
                    {
                        this.cardsHolder[j].Image = this.cardsImageDeck[j];
                        foreach (var item in this.dataBase.Players)
                        {
                            item.Call = 0;
                            item.Raise = 0;
                        }
                       
                    }
                }
            }

            if (this.rounds == this.end && this.maxLeft == 6)
            {
                string fixedLast = String.Empty; 

                foreach (var player in this.dataBase.Players)
                {
                    if (!player.Status.Text.Contains(GlobalConstants.FoldMessage))
                    {
                        fixedLast = player.Name;
                        this.rules.CheckForHand(player);
                        this.rules.Winner(player);
                        player.FoldTurn = false;
                    }
                }

                this.restart = true;
                this.humanPlayer.IsPlayerTurn = true;
                
                if (this.humanPlayer.Chips <= 0)
                {
                    AddChips addChips = new AddChips();
                    addChips.ShowDialog();
                    if (addChips.AmountOfChips != 0)
                    {
                        this.humanPlayer.Chips = addChips.AmountOfChips;
                        for (int i = 1; i < this.dataBase.Players.Length; i++)
                        {
                            this.dataBase.Players[i].Chips += addChips.AmountOfChips;
                        }
                        
                        this.humanPlayer.FoldTurn = false;
                        this.humanPlayer.IsPlayerTurn = true;
                        this.buttonRaise.Enabled = true;
                        this.buttonFold.Enabled = true;
                        this.buttonCheck.Enabled = true;
                        this.buttonRaise.Text = GlobalConstants.RaiseMessage;
                    }
                }

               foreach (var player in this.dataBase.Players)
                {
                    player.Panel.Visible = false;
                    player.Call = 0;
                    player.Raise = 0;
                    player.Power = 0;
                    player.HandFactor = TypeOfTheHand.HighCard;
                }
               
                this.last = 0;
                this.call = this.defaultBigBlind;
                this.raise = 0;
                this.imgLocation = Directory.GetFiles(
                    GlobalConstants.PlayingCardsDirectoryPath,
                    GlobalConstants.PlayingCardsWithPngExtension,
                    SearchOption.TopDirectoryOnly);

                this.inactivePlayers.Clear();
                this.rounds = 0;
                this.rules.Type = 0;
                this.ints.Clear();
                
                for (int os = 0; os < 17; os++)
                {
                    this.cardsHolder[os].Image = null;
                    this.cardsHolder[os].Invalidate();
                    this.cardsHolder[os].Visible = false;
                }

                this.textBoxPot.Text = "0";
                this.humanPlayer.Status.Text = String.Empty;
                await this.Shuffle();
                await this.Turns();
            }
        }
示例#8
0
        /// <summary>
        /// Reinitializes variables, disables players panels, 
        /// clears lists and text messages.
        /// </summary>
        /// <param name="n">The n parameter.</param>
        public async Task Finish(int n)
        {
            if (n == 2)
            {
                this.rules.FixWinners();
            }
            this.humanPlayer.Panel.Visible = false;
            this.firstBot.Panel.Visible = false;
            this.secondBot.Panel.Visible = false;
            this.thirdBot.Panel.Visible = false;
            this.fourthBot.Panel.Visible = false;
            this.fifthBot.Panel.Visible = false;

            this.call = this.defaultBigBlind;
            this.raise = 0;
            this.foldedPlayers = 5;
            this.rules.Type = 0;
            this.rounds = 0;

            this.firstBot.Power = 0;
            this.secondBot.Power = 0;
            this.thirdBot.Power = 0;
            this.fourthBot.Power = 0;
            this.fifthBot.Power = 0;
            this.humanPlayer.Power = 0;
            this.raise = 0;

            foreach (var player in this.dataBase.Players)
            {
                player.HandFactor = TypeOfTheHand.HighCard;
                player.Call = 0;
                player.Raise = 0;
                player.FoldTurn = false;
                player.HasPlayerFolded = false;
                player.Status.Text = String.Empty;
            }

            for (int i = 1; i < this.dataBase.Players.Length; i++)
            {
                this.dataBase.Players[i].IsPlayerTurn = false;
            }
            this.humanPlayer.IsPlayerTurn = true;
            this.restart = false;
            this.raising = false;
            this.height = 0;
            this.width = 0;
            this.rules.Winners = 0;
            this.turn = 2;
            this.river = 3;
            this.end = 4;
            this.maxLeft = 6;
            this.last = 123;
            this.raisedTurn = 1;
            this.inactivePlayers.Clear();
            this.rules.CheckWinners.Clear();

            this.ints.Clear();
            this.rules.Win.Clear();
            this.rules.Sorted.HandFactor = 0;
            this.rules.Sorted.Power = 0;
            this.textBoxPot.Text = "0";
            this.t = 60;
            this.up = 10000000;
            this.turnCount = 0;
            
            if (this.humanPlayer.Chips <= 0)
            {
                AddChips addChips = new AddChips();
                addChips.ShowDialog();
                if (addChips.AmountOfChips != 0)
                {
                    this.humanPlayer.Chips = addChips.AmountOfChips;
                    this.firstBot.Chips += addChips.AmountOfChips;
                    this.secondBot.Chips += addChips.AmountOfChips;
                    this.thirdBot.Chips += addChips.AmountOfChips;
                    this.fourthBot.Chips += addChips.AmountOfChips;
                    this.fifthBot.Chips += addChips.AmountOfChips;
                    this.humanPlayer.FoldTurn = false;
                    this.humanPlayer.IsPlayerTurn = true;
                    this.buttonRaise.Enabled = true;
                    this.buttonFold.Enabled = true;
                    this.buttonCheck.Enabled = true;
                    this.buttonRaise.Text = GlobalConstants.RaiseMessage;
                }
            }

            this.imgLocation = Directory.GetFiles(GlobalConstants.PlayingCardsDirectoryPath,
                GlobalConstants.PlayingCardsWithPngExtension,
                SearchOption.TopDirectoryOnly);
            for (int os = 0; os < 17; os++)
            {
                this.cardsHolder[os].Image = null;
                this.cardsHolder[os].Invalidate();
                this.cardsHolder[os].Visible = false;
            }
            await this.Shuffle();
           
        }
示例#9
0
 /// <summary>
 /// The event triggers when the add chips form appears.
 /// </summary>
 private void AddChipsWhenLost()
 {
     var addChipsForm = new AddChips();
     addChipsForm.ShowDialog();
     this.AddChipsToPlayers(addChipsForm.ChipsAdded);
 }
示例#10
0
        //Dealer
        private void CheckForHighCard(ref double current, ref double power)
        {
            if (current == -1)
            {
                if (Reserve[i] / 4 > Reserve[i + 1] / 4)
                {
                    power = Reserve[i] / 4;
                }
                else
                {
                    power = Reserve[i + 1] / 4;
                }
                Win.Add(new Type() { Power = power, Current = -1 });

                if (Reserve[i] / 4 == 0 || Reserve[i + 1] / 4 == 0)
                {
                    power = 13;
                    Win.Add(new Type() { Power = power, Current = -1 });
                }
                sorted = Win.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
            }

            //Dealer
            //This method determines winner
            void Winner(double current, double power, string currentText, int chips, string lastPlayed)
            {
            if (lastPlayed == string.Empty)
            {
                lastPlayed = "Bot 5";
            }

            for (int j = 0; j <= 16; j++)
            {
                //await Task.Delay(5);
                if (Holder[j].Visible)
                    Holder[j].Image = Deck[j];
            }
            if (current == sorted.Current)
            {
                if (power == sorted.Power)
                {
                    winners++;
                    CheckWinners.Add(currentText);

                    if (current == -1)
                    {
                        MessageBox.Show(currentText + " High Card ");
                    }
                    if (current == 1 || current == 0)
                    {
                        MessageBox.Show(currentText + " Pair ");
                    }
                    if (current == 2)
                    {
                        MessageBox.Show(currentText + " Two Pair ");
                    }
                    if (current == 3)
                    {
                        MessageBox.Show(currentText + " Three of a Kind ");
                    }
                    if (current == 4)
                    {
                        MessageBox.Show(currentText + " Straight ");
                    }
                    if (current == 5 || current == 5.5)
                    {
                        MessageBox.Show(currentText + " Flush ");
                    }
                    if (current == 6)
                    {
                        MessageBox.Show(currentText + " Full House ");
                    }
                    if (current == 7)
                    {
                        MessageBox.Show(currentText + " Four of a Kind ");
                    }
                    if (current == 8)
                    {
                        MessageBox.Show(currentText + " Straight Flush ");
                    }
                    if (current == 9)
                    {
                        MessageBox.Show(currentText + " Royal Flush ! ");
                    }
                }
            }
            if (currentText == lastPlayed)//lastfixed
            {
                if (winners > 1)
                {
                    if (CheckWinners.Contains("Player"))
                    {
                        Chips += int.Parse(potChips.Text) / winners;
                        tbChips.Text = Chips.ToString();
                        //playerPanel.Visible = true;

                    }
                    if (CheckWinners.Contains("Bot 1"))
                    {
                        firstBotChips += int.Parse(potChips.Text) / winners;
                        tbBotChips1.Text = firstBotChips.ToString();
                        //firstBotPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 2"))
                    {
                        secondBotChips += int.Parse(potChips.Text) / winners;
                        tbBotChips2.Text = secondBotChips.ToString();
                        //secondBotPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 3"))
                    {
                        thirdBotChips += int.Parse(potChips.Text) / winners;
                        tbBotChips3.Text = thirdBotChips.ToString();
                        //thirdBotPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 4"))
                    {
                        fourthBotChips += int.Parse(potChips.Text) / winners;
                        tbBotChips4.Text = fourthBotChips.ToString();
                        //fourthBotPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 5"))
                    {
                        fifthBotChips += int.Parse(potChips.Text) / winners;
                        tbBotChips5.Text = fifthBotChips.ToString();
                        //fifthBotPanel.Visible = true;
                    }
                    //await Finish(1);
                }
                if (winners == 1)
                {
                    if (CheckWinners.Contains("Player"))
                    {
                        Chips += int.Parse(potChips.Text);
                        //await Finish(1);
                        //playerPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 1"))
                    {
                        firstBotChips += int.Parse(potChips.Text);
                        //await Finish(1);
                        //firstBotPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 2"))
                    {
                        secondBotChips += int.Parse(potChips.Text);
                        //await Finish(1);
                        //secondBotPanel.Visible = true;

                    }
                    if (CheckWinners.Contains("Bot 3"))
                    {
                        thirdBotChips += int.Parse(potChips.Text);
                        //await Finish(1);
                        //thirdBotPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 4"))
                    {
                        fourthBotChips += int.Parse(potChips.Text);
                        //await Finish(1);
                        //fourthBotPanel.Visible = true;
                    }
                    if (CheckWinners.Contains("Bot 5"))
                    {
                        fifthBotChips += int.Parse(potChips.Text);
                        //await Finish(1);
                        //fifthBotPanel.Visible = true;
                    }
                }
            }
        }
    
        /// <summary>
        /// 
        /// </summary>
        /// <param name="currentTurn"></param>
        /// <param name="raiseTurn"></param>
        /// <returns></returns>

            //Dealer
            async Task CheckRaise(int currentTurn, int raiseTurn)
        {
                if (isRaising)
                {
                    turnCount = 0;
                    isRaising = false;
                    raisedTurn = currentTurn;
                    changed = true;
                }
                else
                {
                    if (turnCount >= maxLeft - 1 || !changed && turnCount == maxLeft)
                    {
                        if (currentTurn == raisedTurn - 1 || !changed && turnCount == maxLeft || raisedTurn == 0 && currentTurn == 5)
                        {
                            changed = false;
                            turnCount = 0;
                            raise = 0;
                            call = 0;
                            raisedTurn = 123;
                            rounds++;
                            if (!PFturn)
                                playerStatus.Text = "";
                            if (!B1Fturn)
                                firstBotStatus.Text = "";
                            if (!B2Fturn)
                                secondBotStatus.Text = "";
                            if (!B3Fturn)
                                thirdBotStatus.Text = "";
                            if (!B4Fturn)
                                fourthBotStatus.Text = "";
                            if (!B5Fturn)
                                fifthBotStatus.Text = "";
                        }
                    }
                }
                if (rounds == Flop)
                {
                    for (int j = 12; j <= 14; j++)
                    {
                        if (Holder[j].Image != Deck[j])
                        {
                            Holder[j].Image = Deck[j];

                            playerCall = 0;
                            playerRise = 0;

                            firstBotCall = 0;
                            firstBotRise = 0;

                            secondBotCall = 0;
                            secondBotRise = 0;

                            thirdBotCall = 0;
                            thirdBotRise = 0;

                            fourthBotCall = 0;
                            fourthBotRise = 0;

                            fifthBotCall = 0;
                            fifthBotRise = 0;
                        }
                    }
                }
                if (rounds == Turn)
                {
                    for (int j = 14; j <= 15; j++)
                    {
                        if (Holder[j].Image != Deck[j])
                        {
                            Holder[j].Image = Deck[j];
                            playerCall = 0; playerRise = 0;
                            firstBotCall = 0; firstBotRise = 0;
                            secondBotCall = 0; secondBotRise = 0;
                            thirdBotCall = 0; thirdBotRise = 0;
                            fourthBotCall = 0; fourthBotRise = 0;
                            fifthBotCall = 0; fifthBotRise = 0;
                        }
                    }
                }
                if (rounds == River)
                {
                    for (int j = 15; j <= 16; j++)
                    {
                        if (Holder[j].Image != Deck[j])
                        {
                            Holder[j].Image = Deck[j];

                            playerCall = 0;
                            playerRise = 0;
                            firstBotCall = 0;
                            firstBotRise = 0;
                            secondBotCall = 0;
                            secondBotRise = 0;
                            thirdBotCall = 0;
                            thirdBotRise = 0;
                            fourthBotCall = 0;
                            fourthBotRise = 0;
                            fifthBotCall = 0;
                            fifthBotRise = 0;
                        }
                    }
                }
                if (rounds == End && maxLeft == 6)
                {
                    string fixedLast = "qwerty";
                    if (!playerStatus.Text.Contains("Fold"))
                    {
                        fixedLast = "Player";
                        Rules(0, 1, "Player", ref playerType, ref playerPower, PFturn);
                    }
                    if (!firstBotStatus.Text.Contains("Fold"))
                    {
                        fixedLast = "Bot 1";
                        Rules(2, 3, "Bot 1", ref firstBotType, ref firstBotPower, B1Fturn);
                    }
                    if (!secondBotStatus.Text.Contains("Fold"))
                    {
                        fixedLast = "Bot 2";
                        Rules(4, 5, "Bot 2", ref secondBotType, ref secondBotPower, B2Fturn);
                    }
                    if (!thirdBotStatus.Text.Contains("Fold"))
                    {
                        fixedLast = "Bot 3";
                        Rules(6, 7, "Bot 3", ref thirdBotType, ref thirdBotPower, B3Fturn);
                    }
                    if (!fourthBotStatus.Text.Contains("Fold"))
                    {
                        fixedLast = "Bot 4";
                        Rules(8, 9, "Bot 4", ref fourthBotType, ref fourthBotPower, B4Fturn);
                    }
                    if (!fifthBotStatus.Text.Contains("Fold"))
                    {
                        fixedLast = "Bot 5";
                        Rules(10, 11, "Bot 5", ref fifthBotType, ref fifthBotPower, B5Fturn);
                    }

                    Winner(playerType, playerPower, "Player", Chips, fixedLast);
                    Winner(firstBotType, firstBotPower, "Bot 1", firstBotChips, fixedLast);
                    Winner(secondBotType, secondBotPower, "Bot 2", secondBotChips, fixedLast);
                    Winner(thirdBotType, thirdBotPower, "Bot 3", thirdBotChips, fixedLast);
                    Winner(fourthBotType, fourthBotPower, "Bot 4", fourthBotChips, fixedLast);
                    Winner(fifthBotType, fifthBotPower, "Bot 5", fifthBotChips, fixedLast);
                    restart = true;
                    playerTurn = true;
                    PFturn = false;
                    B1Fturn = false;
                    B2Fturn = false;
                    B3Fturn = false;
                    B4Fturn = false;
                    B5Fturn = false;
                    if (Chips <= 0)
                    {
                        AddChips f2 = new AddChips();
                        f2.ShowDialog();
                        if (f2.a != 0)
                        {
                            Chips = f2.a;
                            firstBotChips += f2.a;
                            secondBotChips += f2.a;
                            thirdBotChips += f2.a;
                            fourthBotChips += f2.a;
                            fifthBotChips += f2.a;
                            PFturn = false;
                            playerTurn = true;
                            raiseButton.Enabled = true;
                            foldButton.Enabled = true;
                            checkButton.Enabled = true;
                            raiseButton.Text = "raise";
                        }
                    }
                    playerPanel.Visible = false;
                    firstBotPanel.Visible = false;
                    secondBotPanel.Visible = false;
                    thirdBotPanel.Visible = false;
                    fourthBotPanel.Visible = false;
                    fifthBotPanel.Visible = false;

                    playerCall = 0;
                    playerRise = 0;
                    firstBotCall = 0;
                    firstBotRise = 0;
                    secondBotCall = 0;
                    secondBotRise = 0;
                    thirdBotCall = 0;
                    thirdBotRise = 0;
                    fourthBotCall = 0;
                    fourthBotRise = 0;
                    fifthBotCall = 0;
                    fifthBotRise = 0;

                    last = 0;
                    call = bb;
                    raise = 0;
                    ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly);
                    bools.Clear();

                    rounds = 0;
                    playerPower = 0;
                    playerType = -1;
                    type = 0;

                    firstBotPower = 0;
                    secondBotPower = 0;
                    thirdBotPower = 0;
                    fourthBotPower = 0;
                    fifthBotPower = 0;
                    firstBotType = -1;
                    secondBotType = -1;
                    thirdBotType = -1;
                    fourthBotType = -1;
                    fifthBotType = -1;

                    ints.Clear();
                    CheckWinners.Clear();
                    winners = 0;
                    Win.Clear();
                    sorted.Current = 0;
                    sorted.Power = 0;

                    for (int os = 0; os < 17; os++)
                    {
                        Holder[os].Image = null;
                        Holder[os].Invalidate();
                        Holder[os].Visible = false;
                    }
                    potChips.Text = "0";
                    playerStatus.Text = string.Empty;
                    await Shuffle();
                    await Turns();
                }
            }