private void CheckPlayerChipsAmount(IPlayer player) { if (player.Chips <= 0) { AddChips addChipsDialog = new AddChips(); addChipsDialog.ShowDialog(); if (addChipsDialog.Amount != 0) { this.AddChips(this.GetAllPlayers(), addChipsDialog.Amount); player.FoldedTurn = false; player.IsInTurn = true; } } }
private void LayoutChange(object sender, LayoutEventArgs e) { if (this.players != null) { if (this.players[0].Chips <= GlobalVariables.CurrentHighestBet * 2) { this.buttonRaise.Text = "All In"; // this.buttonRaise.Update(); } else { this.buttonRaise.Text = "Raise"; } if (this.players.Any(p => !p.IsInGame && p is Player)) { var form = new AddChips(); form.Activate(); form.Update(); } } }
async Task Finish(int n) { if (n == 2) { FixWinners(); } pPanel.Visible = false; botOnePanel.Visible = false; botTwoPanel.Visible = false; botThreePanel.Visible = false; botFourPanel.Visible = false; botFivePanel.Visible = false; callChipsValue = bb; raise = 0; foldedPlayers = 5; type = 0; rounds = 0; botOnePower = 0; botTwoPower = 0; botThreePower = 0; botFourPower = 0; botFivePower = 0; playerPower = 0; playerType = -1; raise = 0; botOneType = -1; botTwoType = -1; botThreeType = -1; botFourType = -1; botFiveType = -1; botOneTurn = false; botTwoTurn = false; botThreeTurn = false; botFourTurn = false; botFiveTurn = false; B1Fturn = false; B2Fturn = false; B3Fturn = false; B4Fturn = false; B5Fturn = false; pFolded = false; b1Folded = false; b2Folded = false; b3Folded = false; b4Folded = false; b5Folded = false; PFturn = false; playerTurn = true; restart = false; raising = false; playerCall = 0; botOneCall = 0; botTwoCall = 0; botThreeCall = 0; botFourCall = 0; botFiveCall = 0; playerRaise = 0; botOneRaise = 0; botTwoRaise = 0; botThreeRaise = 0; botFourRaise = 0; botFiveRaise = 0; height = 0; width = 0; winners = 0; //Flop = 1; //Turn = 2; //River = 3; //End = 4; maxLeft = 6; last = 123; raisedTurn = 1; listOfBooleans.Clear(); CheckWinners.Clear(); ints.Clear(); winner.Clear(); sorted.Current = 0; sorted.Power = 0; tbPot.Text = "0"; t = 60; up = 10000000; turnCount = 0; pStatus.Text = ""; b1Status.Text = ""; b2Status.Text = ""; b3Status.Text = ""; b4Status.Text = ""; b5Status.Text = ""; if (chips <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { chips = f2.a; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; PFturn = false; playerTurn = true; bRaise.Enabled = true; bFold.Enabled = true; bCheck.Enabled = true; bRaise.Text = "raise"; } } ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < 17; os++) { Holder[os].Image = null; Holder[os].Invalidate(); Holder[os].Visible = false; } await Shuffle(); //await Turns(); }
async Task CheckRaise(int currentTurn, int raiseTurn) { if (raising) { turnCount = 0; raising = 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) pStatus.Text = string.Empty; if (!B1Fturn) b1Status.Text = string.Empty; if (!B2Fturn) b2Status.Text = string.Empty; if (!B3Fturn) b3Status.Text = string.Empty; if (!B4Fturn) b4Status.Text = string.Empty; if (!B5Fturn) b5Status.Text = string.Empty; } } } if (rounds == Flop) { for (int j = 12; j <= 14; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; } } } if (rounds == Turn) { for (int j = 14; j <= 15; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; } } } if (rounds == River) { for (int j = 15; j <= 16; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; } } } if (rounds == End && maxLeft == 6) { string fixedLast = "qwerty"; if (!pStatus.Text.Contains("Fold")) { fixedLast = "Player"; Rules(0, 1, "Player", ref pType, ref pPower, PFturn); } if (!b1Status.Text.Contains("Fold")) { fixedLast = "Bot 1"; Rules(2, 3, "Bot 1", ref b1Type, ref b1Power, B1Fturn); } if (!b2Status.Text.Contains("Fold")) { fixedLast = "Bot 2"; Rules(4, 5, "Bot 2", ref b2Type, ref b2Power, B2Fturn); } if (!b3Status.Text.Contains("Fold")) { fixedLast = "Bot 3"; Rules(6, 7, "Bot 3", ref b3Type, ref b3Power, B3Fturn); } if (!b4Status.Text.Contains("Fold")) { fixedLast = "Bot 4"; Rules(8, 9, "Bot 4", ref b4Type, ref b4Power, B4Fturn); } if (!b5Status.Text.Contains("Fold")) { fixedLast = "Bot 5"; Rules(10, 11, "Bot 5", ref b5Type, ref b5Power, B5Fturn); } Winner(pType, pPower, "Player", chips, fixedLast); Winner(b1Type, b1Power, "Bot 1", bot1Chips, fixedLast); Winner(b2Type, b2Power, "Bot 2", bot2Chips, fixedLast); Winner(b3Type, b3Power, "Bot 3", bot3Chips, fixedLast); Winner(b4Type, b4Power, "Bot 4", bot4Chips, fixedLast); Winner(b5Type, b5Power, "Bot 5", bot5Chips, fixedLast); restart = true; Pturn = 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; bot1Chips += f2.a; bot2Chips += f2.a; bot3Chips += f2.a; bot4Chips += f2.a; bot5Chips += f2.a; PFturn = false; Pturn = true; bRaise.Enabled = true; bFold.Enabled = true; bCheck.Enabled = true; bRaise.Text = "Raise"; } } playerPanel.Visible = false; firstBotPanel.Visible = false; secondBotPanel.Visible = false; thirdBotPanel.Visible = false; fourthBotPanel.Visible = false; fifthBotPlayer.Visible = false; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; last = 0; call = bb; Raise = 0; ImgLocation = Directory.GetFiles(AssetsPath + @"Cards", "*.png", SearchOption.TopDirectoryOnly); bools.Clear(); rounds = 0; pPower = 0; pType = -1; type = 0; b1Power = 0; b2Power = 0; b3Power = 0; b4Power = 0; b5Power = 0; b1Type = -1; b2Type = -1; b3Type = -1; b4Type = -1; b5Type = -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; } tbPot.Text = "0"; pStatus.Text = string.Empty; await Shuffle(); await Turns(); } }
async Task CheckRaise(int currentTurn) { // TODO: currentTurn or raisedTurn bool hasBotRised = gameBots.Count(bot => bot.RaiseTurn == true) > 0; bool hasPlayerRised = player.RaiseTurn; if (hasPlayerRised || hasBotRised) { this.turnCount = 0; //GameParticipant.raising = false; player.RaiseTurn = false; for (int i = 0; i < NumberOfBots; i++) { gameBots[i].RaiseTurn = false; } this.raisedTurn = currentTurn; this.changed = true; } else { 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++; if (!this.player.FoldTurn) { this.player.ParticipantPanel.StatusButton.Text = string.Empty; this.player.Raise = 0; } for (int bot = 0; bot < NumberOfBots; bot++) { if (!this.gameBots[bot].FoldTurn) { this.gameBots[bot].ParticipantPanel.StatusButton.Text = string.Empty; this.gameBots[bot].Raise = 0; } } } } } if (this.rounds == (int)PokerStages.Flop) { for (int j = 12; j <= 14; j++) { if (this.cardImages[j].Image != this.deck[j]) { this.cardImages[j].Image = this.deck[j]; this.player.Call = 0; this.player.Raise = 0; for (int bot = 0; bot < NumberOfBots; bot++) { this.gameBots[bot].Call = 0; this.gameBots[bot].Raise = 0; } } } } if (this.rounds == (int)PokerStages.Turn) { for (int j = 14; j <= 15; j++) { if (this.cardImages[j].Image != this.deck[j]) { this.cardImages[j].Image = this.deck[j]; this.player.Call = 0; this.player.Raise = 0; for (int bot = 0; bot < NumberOfBots; bot++) { this.gameBots[bot].Call = 0; this.gameBots[bot].Raise = 0; } } } } if (this.rounds == (int)PokerStages.River) { for (int j = 15; j <= 16; j++) { if (this.cardImages[j].Image != this.deck[j]) { this.cardImages[j].Image = this.deck[j]; this.player.Call = 0; this.player.Raise = 0; for (int bot = 0; bot < NumberOfBots; bot++) { this.gameBots[bot].Call = 0; this.gameBots[bot].Raise = 0; } } } } if (this.rounds == (int)PokerStages.End && this.maxLeft == 6) { string fixedLast = string.Empty; if (!this.player.ParticipantPanel.StatusButton.Text.Contains("Fold")) { fixedLast = "Player"; this.Rules(0, 1, this.player); } for (int bot = 0; bot < NumberOfBots; bot++) { IBot currentBot = this.gameBots[bot]; int botIndex = bot + 1; int firstCard = botIndex * 2; int seconCard = botIndex * 2 + 1; if (!currentBot.ParticipantPanel.StatusButton.Text.Contains("Fold")) { fixedLast = $"Bot {botIndex}"; this.Rules(firstCard, seconCard, currentBot); } } this.ValidateWinner(this.player, "Player", fixedLast); for (int bot = 0; bot < NumberOfBots; bot++) { IBot currentBot = this.gameBots[bot]; this.ValidateWinner(currentBot, $"Bot {bot + 1}", fixedLast); currentBot.FoldTurn = false; } this.restart = true; this.player.Turn = true; this.player.FoldTurn = false; if (this.player.Chips <= 0) { AddChips addMoreChipsForm = new AddChips(); addMoreChipsForm.ShowDialog(); if (addMoreChipsForm.NewChips != 0) { this.player.Chips = addMoreChipsForm.NewChips; for (int bot = 0; bot < NumberOfBots; bot++) { this.gameBots[bot].Chips = addMoreChipsForm.NewChips; } this.player.FoldTurn = false; this.player.Turn = true; this.raiseButton.Enabled = true; this.foldButton.Enabled = true; this.checkButton.Enabled = true; this.raiseButton.Text = "Raise"; } } this.player.ParticipantPanel.Visible = false; this.player.Call = 0; this.player.Raise = 0; this.player.Power = 0; this.player.Type = -1; for (int bot = 0; bot < NumberOfBots; bot++) { IBot currentBot = this.gameBots[bot]; currentBot.ParticipantPanel.Visible = false; currentBot.Call = 0; currentBot.Raise = 0; // Moved up (they were below the variable type) currentBot.Power = 0; currentBot.Type = -1; } this.last = 0; this.call = this.bigBlind; //this.raise = 0; this.imageLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); //bools.Clear(); this.rounds = 0; this.type = 0; this.ints.Clear(); this.winnersChecker.Clear(); this.winners = 0; this.win.Clear(); this.winningHand.Current = 0; this.winningHand.Power = 0; for (int os = 0; os < 17; os++) { this.cardImages[os].Image = null; this.cardImages[os].Invalidate(); this.cardImages[os].Visible = false; } this.potTextBox.Text = "0"; this.player.ParticipantPanel.StatusButton.Text = string.Empty; await this.Shuffle(); await this.Turns(); } }
/// <summary> /// /// </summary> /// <param name="currentTurn"></param> /// <param name="raiseTurn"></param> /// <returns></returns> 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(); } }
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.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++; if (!this.PFturn) { this.playerChipsStatus.Text = string.Empty; } if (!this.isBotOneFirstTurn) { this.botOneActionStatus.Text = string.Empty; } if (!this.isBotTwoFirstTurn) { this.botTwoActionStatus.Text = string.Empty; } if (!this.isBotThreeFirstTurn) { this.botThreeActionStatus.Text = string.Empty; } if (!this.isBotFourFirstTurn) { this.botFourActionStatus.Text = string.Empty; } if (!this.isBotFiveFirstTurn) { this.botFiveActionStatus.Text = string.Empty; } } } } if (this.rounds == this.flop) { for (int j = 12; j <= 14; j++) { if (this.CardsPicturesHolder[j].Image != this.deckImages[j]) { this.CardsPicturesHolder[j].Image = this.deckImages[j]; this.playerCall = 0; this.playerRaise = 0; this.botOneCall = 0; this.botOneRaise = 0; this.botTwoCall = 0; this.botTwoRaise = 0; this.botThreeCall = 0; this.botThreeRaise = 0; this.botFourCall = 0; this.botFourRaise = 0; this.botFiveCall = 0; this.b5Raise = 0; } } } if (this.rounds == this.turn) { for (int j = 14; j <= 15; j++) { if (this.CardsPicturesHolder[j].Image != this.deckImages[j]) { this.CardsPicturesHolder[j].Image = this.deckImages[j]; this.playerCall = 0; this.playerRaise = 0; this.botOneCall = 0; this.botOneRaise = 0; this.botTwoCall = 0; this.botTwoRaise = 0; this.botThreeCall = 0; this.botThreeRaise = 0; this.botFourCall = 0; this.botFourRaise = 0; this.botFiveCall = 0; this.b5Raise = 0; } } } if (this.rounds == this.river) { for (int j = 15; j <= 16; j++) { if (this.CardsPicturesHolder[j].Image != this.deckImages[j]) { this.CardsPicturesHolder[j].Image = this.deckImages[j]; this.playerCall = 0; this.playerRaise = 0; this.botOneCall = 0; this.botOneRaise = 0; this.botTwoCall = 0; this.botTwoRaise = 0; this.botThreeCall = 0; this.botThreeRaise = 0; this.botFourCall = 0; this.botFourRaise = 0; this.botFiveCall = 0; this.b5Raise = 0; } } } if (this.rounds == this.end && this.maxLeft == 6) { string fixedLast = "qwerty"; if (!this.playerChipsStatus.Text.Contains(Resources.FoldStr)) { fixedLast = Resources.PlayerStr; this.Rules(0, 1, ref this.playerType, ref this.playerPower, this.PFturn); } if (!this.botOneActionStatus.Text.Contains(Resources.FoldStr)) { fixedLast = Resources.BotOneStr; this.Rules(2, 3, ref this.botOneType, ref this.botOnePower, this.isBotOneFirstTurn); } if (!this.botTwoActionStatus.Text.Contains(Resources.FoldStr)) { fixedLast = Resources.BotTwoStr; this.Rules(4, 5, ref this.botTwoType, ref this.botTwoPower, this.isBotTwoFirstTurn); } if (!this.botThreeActionStatus.Text.Contains(Resources.FoldStr)) { fixedLast = Resources.BotThreeStr; this.Rules(6, 7, ref this.botThreeType, ref this.botThreePower, this.isBotThreeFirstTurn); } if (!this.botFourActionStatus.Text.Contains(Resources.FoldStr)) { fixedLast = Resources.BotFourStr; this.Rules(8, 9, ref this.botFourType, ref this.botFourPower, this.isBotFourFirstTurn); } if (!this.botFiveActionStatus.Text.Contains(Resources.FoldStr)) { fixedLast = Resources.BotFiveStr; this.Rules(10, 11, ref this.b5Type, ref this.botFivePower, this.isBotFiveFirstTurn); } this.Winner(this.playerType, this.playerPower, Resources.PlayerStr, fixedLast); this.Winner(this.botOneType, this.botOnePower, Resources.BotOneStr, fixedLast); this.Winner(this.botTwoType, this.botTwoPower, Resources.BotTwoStr, fixedLast); this.Winner(this.botThreeType, this.botThreePower, Resources.BotThreeStr, fixedLast); this.Winner(this.botFourType, this.botFourPower, Resources.BotFourStr, fixedLast); this.Winner(this.b5Type, this.botFivePower, Resources.BotFiveStr, fixedLast); this.restart = true; this.Pturn = true; this.PFturn = false; this.isBotOneFirstTurn = false; this.isBotTwoFirstTurn = false; this.isBotThreeFirstTurn = false; this.isBotFourFirstTurn = false; this.isBotFiveFirstTurn = false; if (this.startingChipsDefault <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { this.startingChipsDefault = f2.a; this.bot1Chips += f2.a; this.bot2Chips += f2.a; this.bot3Chips += f2.a; this.bot4Chips += f2.a; this.bot5Chips += f2.a; this.PFturn = false; this.Pturn = true; this.bRaise.Enabled = true; this.bFold.Enabled = true; this.bCheck.Enabled = true; this.bRaise.Text = "raise"; } } this.pPanel.Visible = false; this.botOnePanel.Visible = false; this.botTwoPanel.Visible = false; this.botThreePanel.Visible = false; this.botFourPanel.Visible = false; this.b5Panel.Visible = false; this.playerCall = 0; this.playerRaise = 0; this.botOneCall = 0; this.botOneRaise = 0; this.botTwoCall = 0; this.botTwoRaise = 0; this.botThreeCall = 0; this.botThreeRaise = 0; this.botFourCall = 0; this.botFourRaise = 0; this.botFiveCall = 0; this.b5Raise = 0; this.call = this.bb; this.raise = 0; this.cardsImageLocations = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); this.bools.Clear(); this.rounds = 0; this.playerPower = 0; this.playerType = -1; this.type = 0; this.botOnePower = 0; this.botTwoPower = 0; this.botThreePower = 0; this.botFourPower = 0; this.botFivePower = 0; this.botOneType = -1; this.botTwoType = -1; this.botThreeType = -1; this.botFourType = -1; this.b5Type = -1; this.ints.Clear(); this.CheckWinners.Clear(); this.winners = 0; this.Win.Clear(); this.sorted.Current = 0; this.sorted.Power = 0; for (int os = 0; os < TotalCardsDealedPerHand; os++) { this.CardsPicturesHolder[os].Image = null; this.CardsPicturesHolder[os].Invalidate(); this.CardsPicturesHolder[os].Visible = false; } this.tbTotalPot.Text = "0"; this.playerChipsStatus.Text = string.Empty; await this.Shuffle(); await this.Turns(); } }
async Task Finish(int n) { if (n == 2) { FixWinners(); } // TODO : extract in method Reset or something like that this.player.Panel.Visible = false; this.firstBot.Panel.Visible = false; this.secondBot.Panel.Visible = false; this.thirdBot.Panel.Visible = false; this.fourthBot.Panel.Visible = false; this.fifthBoth.Panel.Visible = false; call = this.bigBlind; raise = 0; foldedPlayers = 5; type = 0; rounds = 0; this.firstBot.Power = 0; this.secondBot.Power = 0; this.thirdBot.Power = 0; this.fourthBot.Power = 0; this.fifthBoth.Power = 0; this.player.Power = 0; this.player.Type = -1; this.firstBot.Type = -1; this.secondBot.Type = -1; this.thirdBot.Type = -1; this.fourthBot.Type = -1; this.fifthBoth.Type = -1; this.playerTurn = true; this.firstBot.Turn = false; this.secondBot.Turn = false; this.thirdBot.Turn = false; this.fourthBot.Turn = false; this.fifthBoth.Turn = false; this.playerFoldTurn = false; this.firstBot.FoldedTurn = false; this.secondBot.FoldedTurn = false; this.thirdBot.FoldedTurn = false; this.fourthBot.FoldedTurn = false; this.fifthBoth.FoldedTurn = false; this.player.Folded = false; this.firstBot.Folded = false; this.secondBot.Folded = false; this.thirdBot.Folded = false; this.fourthBot.Folded = false; this.fifthBoth.Folded = false; this.restart = false; this.raising = false; this.player.Call = 0; this.firstBot.Call = 0; this.secondBot.Call = 0; this.thirdBot.Call = 0; this.fourthBot.Call = 0; this.fifthBoth.Call = 0; this.player.Raise = 0; this.firstBot.Raise = 0; this.secondBot.Raise = 0; this.thirdBot.Raise = 0; this.fourthBot.Raise = 0; this.fifthBoth.Raise = 0; // height = 0; // width = 0; winners = 0; Flop = 1; Turn = 2; River = 3; End = 4; maxLeft = 6; raisedTurn = 1; bools.Clear(); CheckWinners.Clear(); ints.Clear(); Win.Clear(); sorted.Current = 0; sorted.Power = 0; potStatus.Text = "0"; t = 60; turnCount = 0; this.playerStatus.Text = string.Empty; this.botOneStatus.Text = string.Empty; botTwoStatus.Text = string.Empty; botThreeStatus.Text = string.Empty; botFourStatus.Text = string.Empty; botFiveStatus.Text = string.Empty; // TODO: Here add chips, duplicate. if (player.Chips <= 0) { AddChips addChips = new AddChips(); addChips.ShowDialog(); if (addChips.AddedChips != 0) { player.Chips = addChips.AddedChips; firstBot.Chips += addChips.AddedChips; secondBot.Chips += addChips.AddedChips; thirdBot.Chips += addChips.AddedChips; fourthBot.Chips += addChips.AddedChips; fifthBoth.Chips += addChips.AddedChips; this.playerFoldTurn = false; this.playerTurn = true; raiseButton.Enabled = true; foldButton.Enabled = true; checkButton.Enabled = true; raiseButton.Text = "Raise"; } } ImgLocation = Directory.GetFiles(@"..\..\Resources\Assets\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < 17; os++) { holder[os].Image = null; holder[os].Invalidate(); holder[os].Visible = false; } await Shuffle(); //await Turns(); }
async Task CheckRaise(int currentTurn, int raiseTurn) { if (raising) { turnCount = 0; raising = 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 (!this.playerFoldTurn) { this.playerStatus.Text = string.Empty; } if (!this.firstBot.FoldedTurn) { this.botOneStatus.Text = string.Empty; } if (!this.secondBot.FoldedTurn) { botTwoStatus.Text = string.Empty; } if (!this.thirdBot.FoldedTurn) { botThreeStatus.Text = string.Empty; } if (!this.fourthBot.FoldedTurn) { botFourStatus.Text = string.Empty; } if (!this.fifthBoth.FoldedTurn) { botFiveStatus.Text = string.Empty; } } } } if (rounds == Flop) { for (int j = 12; j <= 14; j++) { if (holder[j].Image != deck[j]) { holder[j].Image = deck[j]; this.player.Call = 0; this.player.Raise = 0; this.firstBot.Call = 0; this.firstBot.Raise = 0; this.secondBot.Call = 0; this.secondBot.Raise = 0; this.thirdBot.Call = 0; this.thirdBot.Raise = 0; this.fourthBot.Call = 0; this.fourthBot.Raise = 0; this.fifthBoth.Call = 0; this.fifthBoth.Raise = 0; } } } if (rounds == Turn) { for (int j = 14; j <= 15; j++) { if (holder[j].Image != deck[j]) { holder[j].Image = deck[j]; this.player.Call = 0; this.player.Raise = 0; this.firstBot.Call = 0; this.firstBot.Raise = 0; this.secondBot.Call = 0; this.secondBot.Raise = 0; this.thirdBot.Call = 0; this.thirdBot.Raise = 0; this.fourthBot.Call = 0; this.fourthBot.Raise = 0; this.fifthBoth.Call = 0; this.fifthBoth.Raise = 0; } } } if (rounds == River) { for (int j = 15; j <= 16; j++) { if (holder[j].Image != deck[j]) { holder[j].Image = deck[j]; this.player.Call = 0; this.player.Raise = 0; this.firstBot.Call = 0; this.firstBot.Raise = 0; this.secondBot.Call = 0; this.secondBot.Raise = 0; this.thirdBot.Call = 0; this.thirdBot.Raise = 0; this.fourthBot.Call = 0; this.fourthBot.Raise = 0; this.fifthBoth.Call = 0; this.fifthBoth.Raise = 0; } } } if (rounds == End && maxLeft == 6) { string fixedLast = string.Empty; if (!this.playerStatus.Text.Contains("Fold")) { fixedLast = "Player"; Rules(0, 1, "Player", this.player); } if (!this.botOneStatus.Text.Contains("Fold")) { fixedLast = "Bot 1"; Rules(2, 3, "Bot 1", this.firstBot); } if (!botTwoStatus.Text.Contains("Fold")) { fixedLast = "Bot 2"; Rules(4, 5, "Bot 2", this.secondBot); } if (!botThreeStatus.Text.Contains("Fold")) { fixedLast = "Bot 3"; Rules(6, 7, "Bot 3", this.thirdBot); } if (!botFourStatus.Text.Contains("Fold")) { fixedLast = "Bot 4"; Rules(8, 9, "Bot 4", this.fourthBot); } if (!botFiveStatus.Text.Contains("Fold")) { fixedLast = "Bot 5"; Rules(10, 11, "Bot 5", this.fifthBoth); } Winner(player.Type, this.player.Power, "Player", player.Chips, fixedLast); Winner(this.firstBot.Type, this.firstBot.Power, "Bot 1", firstBot.Chips, fixedLast); Winner(this.secondBot.Type, this.secondBot.Power, "Bot 2", secondBot.Chips, fixedLast); Winner(this.thirdBot.Type, this.thirdBot.Power, "Bot 3", thirdBot.Chips, fixedLast); Winner(this.fourthBot.Type, this.fourthBot.Power, "Bot 4", fourthBot.Chips, fixedLast); Winner(this.fifthBoth.Type, this.fifthBoth.Power, "Bot 5", fifthBoth.Chips, fixedLast); restart = true; this.playerTurn = true; this.playerFoldTurn = false; this.firstBot.FoldedTurn = false; this.secondBot.FoldedTurn = false; this.thirdBot.FoldedTurn = false; this.fourthBot.FoldedTurn = false; this.fifthBoth.FoldedTurn = false; // TODO: Add chips on two place. if (player.Chips <= 0) { AddChips addChips = new AddChips(); addChips.ShowDialog(); if (addChips.AddedChips != 0) { player.Chips = addChips.AddedChips; firstBot.Chips += addChips.AddedChips; secondBot.Chips += addChips.AddedChips; thirdBot.Chips += addChips.AddedChips; fourthBot.Chips += addChips.AddedChips; fifthBoth.Chips += addChips.AddedChips; this.playerFoldTurn = false; this.playerTurn = true; raiseButton.Enabled = true; foldButton.Enabled = true; checkButton.Enabled = true; raiseButton.Text = "Raise"; } } this.player.Panel.Visible = false; this.firstBot.Panel.Visible = false; this.secondBot.Panel.Visible = false; this.thirdBot.Panel.Visible = false; this.fourthBot.Panel.Visible = false; this.fifthBoth.Panel.Visible = false; this.player.Call = 0; this.player.Raise = 0; this.firstBot.Call = 0; this.firstBot.Raise = 0; this.secondBot.Call = 0; this.secondBot.Raise = 0; this.thirdBot.Call = 0; this.thirdBot.Raise = 0; this.fourthBot.Call = 0; this.fourthBot.Raise = 0; this.fifthBoth.Call = 0; this.fifthBoth.Raise = 0; call = this.bigBlind; raise = 0; ImgLocation = Directory.GetFiles(@"..\..\Resources\Assets\Cards", "*.png", SearchOption.TopDirectoryOnly); bools.Clear(); rounds = 0; this.player.Power = 0; player.Type = -1; type = 0; this.firstBot.Power = 0; this.secondBot.Power = 0; this.thirdBot.Power = 0; this.fourthBot.Power = 0; this.fifthBoth.Power = 0; this.firstBot.Type = -1; this.secondBot.Type = -1; this.thirdBot.Type = -1; this.fourthBot.Type = -1; this.fifthBoth.Type = -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; } potStatus.Text = "0"; this.playerStatus.Text = string.Empty; await Shuffle(); await Turns(); } }
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.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 (IPlayer player in this.players) { if (!player.FTurn) { player.Label.Text = ""; } } } } } if (this.rounds == this.Flop) { for (var j = 12; j <= 14; j++) { if (this.Holder[j].Image != this.Deck[j]) { this.Holder[j].Image = this.Deck[j]; this.ResetCallRaise(); } } } if (this.rounds == this.Turn) { for (var j = 14; j <= 15; j++) { if (this.Holder[j].Image != this.Deck[j]) { this.Holder[j].Image = this.Deck[j]; this.ResetCallRaise(); } } } if (this.rounds == this.River) { for (var j = 15; j <= 16; j++) { if (this.Holder[j].Image != this.Deck[j]) { this.Holder[j].Image = this.Deck[j]; this.ResetCallRaise(); } } if (this.rounds == this.End && this.maxLeft == 6) { string last = "qwerty"; foreach (IPlayer player in this.players) { if (!player.Label.Text.Contains("Fold")) { last = player.Name; this.Rules(0, 1, player); } } foreach (IPlayer player in this.players) { this.Winner(player, last); } this.restart = true; this.players[0].Turn = true; this.players[0].FTurn = false; this.players[1].FTurn = false; this.players[2].FTurn = false; this.players[3].FTurn = false; this.players[4].FTurn = false; this.players[5].FTurn = false; if (this.players[0].Chips <= 0) { var f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { this.players[0].Chips = f2.a; this.players[1].Chips += f2.a; this.players[2].Chips += f2.a; this.players[3].Chips += f2.a; this.players[4].Chips += f2.a; this.players[5].Chips += f2.a; this.players[0].FTurn = false; this.players[0].Turn = true; this.bRaise.Enabled = true; this.buttonFold.Enabled = true; this.buttonCheck.Enabled = true; this.bRaise.Text = "Raise"; } } foreach (IPlayer player in this.players) { player.Power = 0; player.PokerHandMultiplier = -1; } this.playerPanel.Visible = false; this.bot1Panel.Visible = false; this.bot2Panel.Visible = false; this.bot3Panel.Visible = false; this.bot4Panel.Visible = false; this.bot5Panel.Visible = false; this.ResetCallRaise(); this.last = 0; this.call = this.bigBlind; this.raise = 0; this.ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); this.bools.Clear(); this.rounds = 0; this.type = 0; this.Pot.Clear(); this.CheckWinners.Clear(); this.winners = 0; this.Win.Clear(); this.Sorted.Current = 0; this.Sorted.Power = 0; for (var os = 0; os < 17; os++) { this.Holder[os].Image = null; this.Holder[os].Invalidate(); this.Holder[os].Visible = false; } this.textBoxPot.Text = "0"; this.players[0].Label.Text = ""; await this.Shuffle(); await this.Turns(); } } }
private async Task Finish(int n) { if (n == 2) { this.FixWinners(); } foreach (IPlayer player in this.players) { player.CardsPanel.Visible = false; player.Power = 0; player.PokerHandMultiplier = -1; player.Turn = false; player.Folded = false; player.Call = 0; player.Raise = 0; player.Label.Text = ""; } this.players[0].FTurn = false; this.players[0].Turn = true; this.call = this.bigBlind; this.raise = 0; this.foldedPlayers = 5; this.type = 0; this.rounds = 0; this.restart = false; this.raising = false; this.playerCall = 0; this.height = 0; this.width = 0; this.winners = 0; this.Flop = 1; this.Turn = 2; this.River = 3; this.End = 4; this.maxLeft = 6; this.last = 123; this.raisedTurn = 1; this.bools.Clear(); this.CheckWinners.Clear(); this.Pot.Clear(); this.Win.Clear(); this.Sorted.Current = 0; this.Sorted.Power = 0; this.textBoxPot.Text = "0"; this.time = 60; this.maxBlind = 10000000; this.turnCount = 0; if (this.players[0].Chips <= 0) { var f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { this.players[0].Chips = f2.a; this.players[1].Chips += f2.a; this.players[2].Chips += f2.a; this.players[3].Chips += f2.a; this.players[4].Chips += f2.a; this.players[5].Chips += f2.a; this.players[0].FTurn = false; this.players[0].Turn = true; this.bRaise.Enabled = true; this.buttonFold.Enabled = true; this.buttonCheck.Enabled = true; this.bRaise.Text = "Raise"; } } this.ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (var os = 0; os < 17; os++) { this.Holder[os].Image = null; this.Holder[os].Invalidate(); this.Holder[os].Visible = false; } await this.Shuffle(); }
async Task CheckRaise(int currentTurn, int raiseTurn) { if (raising) { turnCount = 0; raising = 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) bot1Status.Text = ""; if (!B2Fturn) bot2Status.Text = ""; if (!B3Fturn) bot3Status.Text = ""; if (!B4Fturn) bot4Status.Text = ""; if (!B5Fturn) bot5Status.Text = ""; } } } if (rounds == Flop) { for (int j = 12; j <= 14; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; } } } if (rounds == Turn) { for (int j = 14; j <= 15; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; } } } if (rounds == River) { for (int j = 15; j <= 16; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; } } } if (rounds == End && maxLeft == 6) { string fixedLast = "qwerty"; if (!playerStatus.Text.Contains("Fold")) { fixedLast = "Player"; Rules(0, 1, "Player", ref pType, ref pPower, PFturn); } if (!bot1Status.Text.Contains("Fold")) { fixedLast = "Bot 1"; Rules(2, 3, "Bot 1", ref bot1Type, ref bot1Power, B1Fturn); } if (!bot2Status.Text.Contains("Fold")) { fixedLast = "Bot 2"; Rules(4, 5, "Bot 2", ref bot2Type, ref bot2Power, B2Fturn); } if (!bot3Status.Text.Contains("Fold")) { fixedLast = "Bot 3"; Rules(6, 7, "Bot 3", ref bot3Type, ref bot3Power, B3Fturn); } if (!bot4Status.Text.Contains("Fold")) { fixedLast = "Bot 4"; Rules(8, 9, "Bot 4", ref bot4Type, ref bot4Power, B4Fturn); } if (!bot5Status.Text.Contains("Fold")) { fixedLast = "Bot 5"; Rules(10, 11, "Bot 5", ref bot5Type, ref bot5Power, B5Fturn); } Winner(pType, pPower, "Player", Chips, fixedLast); Winner(bot1Type, bot1Power, "Bot 1", bot1Chips, fixedLast); Winner(bot2Type, bot2Power, "Bot 2", bot2Chips, fixedLast); Winner(bot3Type, bot3Power, "Bot 3", bot3Chips, fixedLast); Winner(bot4Type, bot4Power, "Bot 4", bot4Chips, fixedLast); Winner(bot5Type, bot5Power, "Bot 5", bot5Chips, fixedLast); restart = true; Pturn = true; PFturn = false; B1Fturn = false; B2Fturn = false; B3Fturn = false; B4Fturn = false; B5Fturn = false; if (Chips <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.ChipsValue != 0) { Chips = f2.ChipsValue; bot1Chips += f2.ChipsValue; bot2Chips += f2.ChipsValue; bot3Chips += f2.ChipsValue; bot4Chips += f2.ChipsValue; bot5Chips += f2.ChipsValue; PFturn = false; Pturn = true; buttonRaise.Enabled = true; buttonFold.Enabled = true; buttonCheck.Enabled = true; buttonRaise.Text = "Raise"; } } playerPanel.Visible = false; bot1Panel.Visible = false; bot2Panel.Visible = false; bot3Panel.Visible = false; bot4Panel.Visible = false; bot5Panel.Visible = false; pCall = 0; pRaise = 0; b1Call = 0; b1Raise = 0; b2Call = 0; b2Raise = 0; b3Call = 0; b3Raise = 0; b4Call = 0; b4Raise = 0; b5Call = 0; b5Raise = 0; last = 0; call = bb; Raise = 0; ImgLocation = Directory.GetFiles(GameConstants.ImagePath, GameConstants.AllImageFileExtension, SearchOption.TopDirectoryOnly); bools.Clear(); rounds = 0; pPower = 0; pType = -1; type = 0; bot1Power = 0; bot2Power = 0; bot3Power = 0; bot4Power = 0; bot5Power = 0; bot1Type = -1; bot2Type = -1; bot3Type = -1; bot4Type = -1; bot5Type = -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; } textBoxGamePot.Text = "0"; playerStatus.Text = ""; await Shuffle(); await Turns(); } }
async Task CheckRaise(int currentTurn, int raiseTurn) { if (raising) { turnCount = 0; raising = 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 (!playerFinishedTurn) playerStatus.Text = ""; if (!botOneFinishedTurn) botOneStatus.Text = ""; if (!botTwoFinishedTurn) botTwoStatus.Text = ""; if (!botThreeFinishedTurn) botThreeStatus.Text = ""; if (!botFourFinishedTurn) botFourStatus.Text = ""; if (!botFiveFinishedTurn) botFiveStatus.Text = ""; } } } if (rounds == FLOP) { for (int j = 12; j <= 14; j++) { if (cardHolder[j].Image != deck[j]) { cardHolder[j].Image = deck[j]; playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; } } } if (rounds == TURN) { for (int j = 14; j <= 15; j++) { if (cardHolder[j].Image != deck[j]) { cardHolder[j].Image = deck[j]; playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; } } } if (rounds == RIVER) { for (int j = 15; j <= 16; j++) { if (cardHolder[j].Image != deck[j]) { cardHolder[j].Image = deck[j]; playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; } } } if (rounds == END && maxLeft == 6) { string fixedLast = "qwerty"; if (!playerStatus.Text.Contains("Fold")) { fixedLast = "Player"; Rules(0, 1, "Player", ref playerType, ref playerPower, playerFinishedTurn); } if (!botOneStatus.Text.Contains("Fold")) { fixedLast = "Bot 1"; Rules(2, 3, "Bot 1", ref botOneType, ref botOnePower, botOneFinishedTurn); } if (!botTwoStatus.Text.Contains("Fold")) { fixedLast = "Bot 2"; Rules(4, 5, "Bot 2", ref botTwoType, ref botTwoPower, botTwoFinishedTurn); } if (!botThreeStatus.Text.Contains("Fold")) { fixedLast = "Bot 3"; Rules(6, 7, "Bot 3", ref botThreeType, ref botThreePower, botThreeFinishedTurn); } if (!botFourStatus.Text.Contains("Fold")) { fixedLast = "Bot 4"; Rules(8, 9, "Bot 4", ref botFourType, ref botFourPower, botFourFinishedTurn); } if (!botFiveStatus.Text.Contains("Fold")) { fixedLast = "Bot 5"; Rules(10, 11, "Bot 5", ref botFiveType, ref botFivePower, botFiveFinishedTurn); } Winner(playerType, playerPower, "Player", Chips, fixedLast); Winner(botOneType, botOnePower, "Bot 1", botOneChips, fixedLast); Winner(botTwoType, botTwoPower, "Bot 2", botTwoChips, fixedLast); Winner(botThreeType, botThreePower, "Bot 3", botThreeChips, fixedLast); Winner(botFourType, botFourPower, "Bot 4", botFourChips, fixedLast); Winner(botFiveType, botFivePower, "Bot 5", botFiveChips, fixedLast); restart = true; playerTurn = true; playerFinishedTurn = false; botOneFinishedTurn = false; botTwoFinishedTurn = false; botThreeFinishedTurn = false; botFourFinishedTurn = false; botFiveFinishedTurn = false; if (Chips <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.chips != 0) { Chips = f2.chips; botOneChips += f2.chips; botTwoChips += f2.chips; botThreeChips += f2.chips; botFourChips += f2.chips; botFiveChips += f2.chips; playerFinishedTurn = false; playerTurn = true; bRaise.Enabled = true; bFold.Enabled = true; bCheck.Enabled = true; bRaise.Text = "Raise"; } } DisablePanels(); playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; lastPlayerPlayed = 0; call = bigBlind; Raise = 0; ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); bools.Clear(); rounds = 0; playerPower = 0; playerType = -1; type = 0; botOnePower = 0; botTwoPower = 0; botThreePower = 0; botFourPower = 0; botFivePower = 0; botOneType = -1; botTwoType = -1; botThreeType = -1; botFourType = -1; botFiveType = -1; ints.Clear(); CheckWinners.Clear(); winners = 0; Win.Clear(); sorted.Current = 0; sorted.Power = 0; for (int os = 0; os < 17; os++) { cardHolder[os].Image = null; cardHolder[os].Invalidate(); cardHolder[os].Visible = false; } tbPot.Text = "0"; playerStatus.Text = ""; await Shuffle(); await Turns(); } }
async Task Finish(int n) { if (n == 2) { FixWinners(); } playerPanel.Visible = false; bot1Panel.Visible = false; bot2Panel.Visible = false; bot3Panel.Visible = false; bot4Panel.Visible = false; bot5Panel.Visible = false; call = bb; Raise = 0; foldedPlayers = 5; type = 0; rounds = 0; bot1Power = 0; bot2Power = 0; bot3Power = 0; bot4Power = 0; bot5Power = 0; pPower = 0; pType = -1; Raise = 0; bot1Type = -1; bot2Type = -1; bot3Type = -1; bot4Type = -1; bot5Type = -1; B1turn = false; B2turn = false; B3turn = false; B4turn = false; B5turn = false; B1Fturn = false; B2Fturn = false; B3Fturn = false; B4Fturn = false; B5Fturn = false; pFolded = false; b1Folded = false; b2Folded = false; b3Folded = false; b4Folded = false; b5Folded = false; PFturn = false; Pturn = true; restart = false; raising = false; pCall = 0; b1Call = 0; b2Call = 0; b3Call = 0; b4Call = 0; b5Call = 0; pRaise = 0; b1Raise = 0; b2Raise = 0; b3Raise = 0; b4Raise = 0; b5Raise = 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; textBoxGamePot.Text = "0"; t = 60; up = 10000000; turnCount = 0; playerStatus.Text = ""; bot1Status.Text = ""; bot2Status.Text = ""; bot3Status.Text = ""; bot4Status.Text = ""; bot5Status.Text = ""; if (Chips <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.ChipsValue != 0) { Chips = f2.ChipsValue; bot1Chips += f2.ChipsValue; bot2Chips += f2.ChipsValue; bot3Chips += f2.ChipsValue; bot4Chips += f2.ChipsValue; bot5Chips += f2.ChipsValue; PFturn = false; Pturn = true; buttonRaise.Enabled = true; buttonFold.Enabled = true; buttonCheck.Enabled = true; buttonRaise.Text = "Raise"; } } ImgLocation = Directory.GetFiles(GameConstants.ImagePath, GameConstants.AllImageFileExtension, SearchOption.TopDirectoryOnly); for (int os = 0; os < 17; os++) { Holder[os].Image = null; Holder[os].Invalidate(); Holder[os].Visible = false; } await Shuffle(); //await Turns(); }
async Task Finish(int n) { if (n == 2) { FixWinners(); } playerPanel.Visible = false; botOnePanel.Visible = false; botTwoPanel.Visible = false; botThreePanel.Visible = false; botFourPanel.Visible = false; botFivePanel.Visible = false; call = bigBlind; Raise = 0; foldedPlayers = 5; type = 0; rounds = 0; botOnePower = 0; botTwoPower = 0; botThreePower = 0; botFourPower = 0; botFivePower = 0; playerPower = 0; playerType = -1; Raise = 0; botOneType = -1; botTwoType = -1; botThreeType = -1; botFourType = -1; botFiveType = -1; botOneTurn = false; botTwoTurn = false; botThreeTurn = false; botFourTurn = false; botFiveTurn = false; botOneFinishedTurn = false; botTwoFinishedTurn = false; botThreeFinishedTurn = false; botFourFinishedTurn = false; botFiveFinishedTurn = false; playerFolded = false; botOneFolded = false; botTwoFolded = false; botThreeFolded = false; botFourFolded = false; botFiveFolded = false; playerFinishedTurn = false; playerTurn = true; restart = false; raising = false; playerCall = 0; botOneCall = 0; botTwoCall = 0; botThreeCall = 0; botFourCall = 0; botFiveCall = 0; playerRaise = 0; botOneRaise = 0; botTwoRaise = 0; botThreeRaise = 0; botFourRaise = 0; botFiveRaise = 0; height = 0; width = 0; winners = 0; //Flop = 1; //Turn = 2; //River = 3; //End = 4; maxLeft = 6; lastPlayerPlayed = -1; raisedTurn = 1; bools.Clear(); CheckWinners.Clear(); ints.Clear(); Win.Clear(); sorted.Current = 0; sorted.Power = 0; tbPot.Text = "0"; turnTimer = 60; up = 10000000; turnCount = 0; playerStatus.Text = ""; botOneStatus.Text = ""; botTwoStatus.Text = ""; botThreeStatus.Text = ""; botFourStatus.Text = ""; botFiveStatus.Text = ""; if (Chips <= 0) { AddChips AddChipsWindow = new AddChips(); AddChipsWindow.ShowDialog(); if (AddChipsWindow.chips != 0) { Chips = AddChipsWindow.chips; botOneChips += AddChipsWindow.chips; botTwoChips += AddChipsWindow.chips; botThreeChips += AddChipsWindow.chips; botFourChips += AddChipsWindow.chips; botFiveChips += AddChipsWindow.chips; playerFinishedTurn = false; playerTurn = true; bRaise.Enabled = true; bFold.Enabled = true; bCheck.Enabled = true; bRaise.Text = "Raise"; } } ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < 17; os++) { cardHolder[os].Image = null; cardHolder[os].Invalidate(); cardHolder[os].Visible = false; } await Shuffle(); //await Turns(); }
private async Task Finish(int n) { if (n == 2) { this.FixWinners(); } this.pPanel.Visible = false; this.botOnePanel.Visible = false; this.botTwoPanel.Visible = false; this.botThreePanel.Visible = false; this.botFourPanel.Visible = false; this.b5Panel.Visible = false; this.call = this.bb; this.raise = 0; this.foldedPlayers = 5; this.type = 0; this.rounds = 0; this.botOnePower = 0; this.botTwoPower = 0; this.botThreePower = 0; this.botFourPower = 0; this.botFivePower = 0; this.playerPower = 0; this.playerType = -1; this.raise = 0; this.botOneType = -1; this.botTwoType = -1; this.botThreeType = -1; this.botFourType = -1; this.b5Type = -1; this.isBotOneTurn = false; this.isBotTwoTurn = false; this.isBotThreeTurn = false; this.isBotFourTurn = false; this.isFiveTwoTurn = false; this.isBotOneFirstTurn = false; this.isBotTwoFirstTurn = false; this.isBotThreeFirstTurn = false; this.isBotFourFirstTurn = false; this.isBotFiveFirstTurn = false; this.isPlayerFolded = false; this.isBotOneFolded = false; this.isBotTwoFolded = false; this.isBotThreeFolded = false; this.isBotFourFolded = false; this.isBotFiveFolded = false; this.PFturn = false; this.Pturn = true; this.restart = false; this.raising = false; this.playerCall = 0; this.botOneCall = 0; this.botTwoCall = 0; this.botThreeCall = 0; this.botFourCall = 0; this.botFiveCall = 0; this.playerRaise = 0; this.botOneRaise = 0; this.botTwoRaise = 0; this.botThreeRaise = 0; this.botFourRaise = 0; this.b5Raise = 0; this.height = 0; this.width = 0; this.winners = 0; this.flop = 1; this.turn = 2; this.river = 3; this.end = 4; this.maxLeft = 6; this.raisedTurn = 1; this.bools.Clear(); this.CheckWinners.Clear(); this.ints.Clear(); this.Win.Clear(); this.sorted.Current = 0; this.sorted.Power = 0; this.tbTotalPot.Text = "0"; this.t = 60; this.up = 10000000; this.turnCount = 0; this.playerChipsStatus.Text = string.Empty; this.botOneActionStatus.Text = string.Empty; this.botTwoActionStatus.Text = string.Empty; this.botThreeActionStatus.Text = string.Empty; this.botFourActionStatus.Text = string.Empty; this.botFiveActionStatus.Text = string.Empty; if (this.startingChipsDefault <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { this.startingChipsDefault = f2.a; this.bot1Chips += f2.a; this.bot2Chips += f2.a; this.bot3Chips += f2.a; this.bot4Chips += f2.a; this.bot5Chips += f2.a; this.PFturn = false; this.Pturn = true; this.bRaise.Enabled = true; this.bFold.Enabled = true; this.bCheck.Enabled = true; this.bRaise.Text = Resources.RaiseStr; } } this.cardsImageLocations = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < TotalCardsDealedPerHand; os++) { this.CardsPicturesHolder[os].Image = null; this.CardsPicturesHolder[os].Invalidate(); this.CardsPicturesHolder[os].Visible = false; } await this.Shuffle(); // await Turns(); }
private void AddChips() { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { playerChips = f2.a; firstBotChips += f2.a; secondBotChips += f2.a; thirdBotChips += f2.a; fourthBotChips += f2.a; fifthBotChips += f2.a; playerFoldedTurn = false; playerTurn = true; this.EnableFormButtons(); buttonRaise.Text = "Raise"; } }
/// <summary> /// /// </summary> /// <param name="n"></param> /// <returns></returns> async 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 = bb; 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; B1Fturn = false; B2Fturn = false; B3Fturn = false; B4Fturn = false; B5Fturn = false; pFolded = false; b1Folded = false; b2Folded = false; b3Folded = false; b4Folded = false; b5Folded = false; PFturn = 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) { 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"; } } ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < 17; os++) { Holder[os].Image = null; Holder[os].Invalidate(); Holder[os].Visible = false; } await Shuffle(); //await Turns(); }
private async Task CheckRaise(int currentTurn, int raiseTurn) { if (this.IsRaisingActivated) { this.turnCount = 0; this.IsRaisingActivated = false; this.raisedTurn = currentTurn; this.changed = true; } else { if (this.turnCount >= this.maxPlayersLeft - 1 || !this.changed && this.turnCount == this.maxPlayersLeft) { if (currentTurn == raisedTurn - 1 || !this.changed && this.turnCount == this.maxPlayersLeft || this.raisedTurn == 0 && currentTurn == 5) { this.changed = false; this.turnCount = 0; this.GlobalRaise = 0; this.GlobalCall = 0; this.raisedTurn = 123; this.GlobalRounds++; if (!this.Player.OutOfChips) { this.playerStatus.Text = ""; } for (int botIndex = 0; botIndex < PokerGameConstants.NumberOfBots; botIndex++) { IPlayer currentBot = this.PokerDatabase.TakeBotByIndex(botIndex); if (!currentBot.OutOfChips) { currentBot.Status.Text = ""; } } } } } if (this.GlobalRounds == (int)PokerEnum.Flop) { for (int j = 12; j <= 14; j++) { if (this.Holder[j].Image != this.Deck[j]) { this.Holder[j].Image = this.Deck[j]; this.Player.Call = 0; this.Player.Raise = 0; this.BotEraser.EraseBotCall(this.PokerDatabase); this.BotEraser.EraseBotRaise(this.PokerDatabase); } } } if (this.GlobalRounds == (int)PokerEnum.Turn) { for (int j = 14; j <= 15; j++) { if (this.Holder[j].Image != this.Deck[j]) { this.Holder[j].Image = this.Deck[j]; this.Player.Call = 0; this.Player.Raise = 0; this.BotEraser.EraseBotCall(this.PokerDatabase); this.BotEraser.EraseBotRaise(this.PokerDatabase); } } } if (this.GlobalRounds == (int)PokerEnum.River) { for (int j = 15; j <= 16; j++) { if (this.Holder[j].Image != this.Deck[j]) { this.Holder[j].Image = this.Deck[j]; this.Player.Call = 0; this.Player.Raise = 0; this.BotEraser.EraseBotRaise(this.PokerDatabase); this.BotEraser.EraseBotCall(this.PokerDatabase); } } } if (this.GlobalRounds == (int)PokerEnum.End && this.maxPlayersLeft == 6) { string fixedLast = "qwerty"; if (!this.playerStatus.Text.Contains("Fold")) { fixedLast = PokerGameConstants.DefaultPlayerName; this.Rules(this.Player); } for (int botIndex = 0; botIndex < this.PokerDatabase.BotsOnTable.Count(); botIndex++) { IPlayer currentBot = this.PokerDatabase.TakeBotByIndex(botIndex); if (!currentBot.Status.Text.Contains("Fold")) { fixedLast = currentBot.Name; this.Rules(currentBot); } } this.Winner(this.Player.Type, this.Player.Power, PokerGameConstants.DefaultPlayerName, this.GlobalChips, fixedLast); for (int i = 0; i < PokerGameConstants.NumberOfBots; i++) { IPlayer currentBot = this.PokerDatabase.TakeBotByIndex(i); this.Winner(currentBot.Type, currentBot.Power, currentBot.Name, currentBot.Chips, fixedLast); } this.IsRestartRequested = true; this.Player.CanPlay = true; this.Player.OutOfChips = false; this.BotEraser.EnableBotChips(this.PokerDatabase); if (this.GlobalChips <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { this.GlobalChips = f2.a; for (int botIndex = 0; botIndex < PokerGameConstants.NumberOfBots; botIndex++) { IPlayer currentBot = this.PokerDatabase.TakeBotByIndex(botIndex); currentBot.Chips += f2.a; } this.Player.OutOfChips = false; this.Player.CanPlay = true; this.raiseButton.Enabled = true; this.foldButton.Enabled = true; this.checkButton.Enabled = true; this.raiseButton.Text = "Raise"; } } this.BotEraser.DisableBotPanel(this.PokerDatabase); this.BotEraser.EraseBotCall(this.PokerDatabase); this.BotEraser.EraseBotRaise(this.PokerDatabase); this.BotEraser.EraseBotPower(this.PokerDatabase); this.BotEraser.EraseBotType(this.PokerDatabase); this.playerPanel.Visible = false; this.Player.Call = 0; this.Player.Raise = 0; this.Player.Power = 0; this.Player.Type = -1; this.playerStatus.Text = ""; this.GlobalCall = bigBlind; this.GlobalRaise = 0; this.ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int i = 0; i < PokerGameConstants.MaximalPlayers; i++) { this.disabledPlayers[i] = null; } this.GlobalRounds = 0; this.GlobalType = 0; this.winnersCount = 0; this.sorted.Current = 0; this.sorted.Power = 0; this.potTextBox.Text = "0"; this.winList.Clear(); this.ints.Clear(); this.CheckWinners.Clear(); for (int os = 0; os < PokerGameConstants.CardsOnTable; os++) { this.Holder[os].Image = null; this.Holder[os].Invalidate(); this.Holder[os].Visible = false; } await Shuffle(); await Turns(); } }
async Task Finish(int n) { if (n == 2) { this.FixWinners(); } this.player.ParticipantPanel.Visible = false; this.call = this.bigBlind; //this.raise = 0; //this.foldedPlayers = 5; this.type = 0; this.rounds = 0; for (int bot = 0; bot < NumberOfBots; bot++) { IBot currentBot = this.gameBots[bot]; currentBot.ParticipantPanel.Visible = false; currentBot.Power = 0; // Moved up (they were below variable raise) currentBot.Type = -1; currentBot.Turn = false; currentBot.FoldTurn = false; //currentBot.IsFolded = false; currentBot.Call = 0; currentBot.Raise = 0; } this.player.Power = 0; this.player.Type = -1; this.player.Raise = 0; this.player.Call = 0; //this.player.IsFolded = false; this.player.FoldTurn = false; this.player.Turn = true; this.player.RaiseTurn = false; this.restart = false; //GameParticipant.raising = false; //height = 0; //width = 0; this.winners = 0; //Flop = 1; //Turn = 2; //River = 3; //End = 4; this.maxLeft = 6; this.last = 123; //this.raisedTurn = 1; //bools.Clear(); this.winnersChecker.Clear(); this.ints.Clear(); this.win.Clear(); this.winningHand.Current = 0; this.winningHand.Power = 0; this.potTextBox.Text = "0"; this.timeForTurn = 60; //this.maxUp = 10000000; this.turnCount = 0; this.player.ParticipantPanel.StatusButton.Text = string.Empty; for (int bot = 0; bot < NumberOfBots; bot++) { this.gameBots[bot].ParticipantPanel.StatusButton.Text = string.Empty; } if (this.player.Chips <= 0) { AddChips chipsAdder = new AddChips(); chipsAdder.ShowDialog(); if (chipsAdder.NewChips != 0) { this.player.Chips = chipsAdder.NewChips; for (int bot = 0; bot < NumberOfBots; bot++) { this.gameBots[bot].Chips = chipsAdder.NewChips; } this.player.FoldTurn = false; this.player.Turn = true; this.raiseButton.Enabled = true; this.foldButton.Enabled = true; this.checkButton.Enabled = true; this.raiseButton.Text = "Raise"; } } this.imageLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < 17; os++) { this.cardImages[os].Image = null; this.cardImages[os].Invalidate(); this.cardImages[os].Visible = false; } await this.Shuffle(); //await Turns(); }
/// <summary> /// Finishes the current game on the poker table and brings the /// game stats and the stats of all players to their default values. /// </summary> /// <param name="n"></param> /// <returns></returns> private async Task Finish(int n) { if (n == 2) { FixWinners(); } this.BotEraser.DisableBots(this.PokerDatabase); this.BotEraser.EraseBotCall(this.PokerDatabase); this.BotEraser.EraseBotRaise(this.PokerDatabase); this.BotEraser.DisableBotPanel(this.PokerDatabase); this.BotEraser.EraseBotPower(this.PokerDatabase); this.BotEraser.EraseBotType(this.PokerDatabase); this.BotEraser.EraseBotStatusText(this.PokerDatabase); this.BotEraser.UnFoldBots(this.PokerDatabase); this.BotEraser.EnableBotChips(this.PokerDatabase); this.ErasePlayerStats(); this.EnablePlayer(); this.EraseGameStats(); if (this.GlobalChips <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { this.GlobalChips = f2.a; for (int botIndex = 0; botIndex < PokerGameConstants.NumberOfBots; botIndex++) { this.PokerDatabase.TakeBotByIndex(botIndex).Chips += f2.a; } this.Player.OutOfChips = false; this.Player.CanPlay = true; this.raiseButton.Enabled = true; this.foldButton.Enabled = true; this.checkButton.Enabled = true; this.raiseButton.Text = "Raise"; } } this.ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < PokerGameConstants.CardsOnTable; os++) { this.Holder[os].Image = null; this.Holder[os].Invalidate(); this.Holder[os].Visible = false; } await this.Shuffle(); await this.Turns(); }
async Task Finish(int n) { if (n == 2) { FixWinners(); } playerPanel.Visible = false; firstBotPanel.Visible = false; secondBotPanel.Visible = false; thirdBotPanel.Visible = false; fourthBotPanel.Visible = false; fifthBotPlayer.Visible = false; call = bb; Raise = 0; foldedPlayers = 5; type = 0; rounds = 0; b1Power = 0; b2Power = 0; b3Power = 0; b4Power = 0; b5Power = 0; pPower = 0; pType = -1; Raise = 0; b1Type = -1; b2Type = -1; b3Type = -1; b4Type = -1; b5Type = -1; B1turn = false; B2turn = false; B3turn = false; B4turn = false; B5turn = false; B1Fturn = false; B2Fturn = false; B3Fturn = false; B4Fturn = false; B5Fturn = false; pFolded = false; b1Folded = false; b2Folded = false; b3Folded = false; b4Folded = false; b5Folded = false; PFturn = false; Pturn = true; restart = false; raising = false; pCall = 0; b1Call = 0; b2Call = 0; b3Call = 0; b4Call = 0; b5Call = 0; pRaise = 0; b1Raise = 0; b2Raise = 0; b3Raise = 0; b4Raise = 0; b5Raise = 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; tbPot.Text = "0"; t = 60; up = 10000000; turnCount = 0; pStatus.Text = string.Empty; b1Status.Text = string.Empty; b2Status.Text = string.Empty; b3Status.Text = string.Empty; b4Status.Text = string.Empty; b5Status.Text = string.Empty; if (chips <= 0) { AddChips f2 = new AddChips(); f2.ShowDialog(); if (f2.a != 0) { chips = f2.a; bot1Chips += f2.a; bot2Chips += f2.a; bot3Chips += f2.a; bot4Chips += f2.a; bot5Chips += f2.a; PFturn = false; Pturn = true; bRaise.Enabled = true; bFold.Enabled = true; bCheck.Enabled = true; bRaise.Text = "Raise"; } } ImgLocation = Directory.GetFiles(AssetsPath + @"Cards", "*.png", SearchOption.TopDirectoryOnly); for (int os = 0; os < 17; os++) { Holder[os].Image = null; Holder[os].Invalidate(); Holder[os].Visible = false; } await Shuffle(); // await Turns(); }
async Task CheckRaise(int currentTurn, int raiseTurn) { if (raising) { turnCount = 0; raising = 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; callChipsValue = 0; raisedTurn = 123; rounds++; if (!PFturn) pStatus.Text = ""; if (!B1Fturn) b1Status.Text = ""; if (!B2Fturn) b2Status.Text = ""; if (!B3Fturn) b3Status.Text = ""; if (!B4Fturn) b4Status.Text = ""; if (!B5Fturn) b5Status.Text = ""; } } } if (rounds == Flop) { for (int j = 12; j <= 14; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; } } } if (rounds == Turn) { for (int j = 14; j <= 15; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; } } } if (rounds == River) { for (int j = 15; j <= 16; j++) { if (Holder[j].Image != Deck[j]) { Holder[j].Image = Deck[j]; playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; } } } if (rounds == End && maxLeft == 6) { string fixedLast = "qwerty"; if (!pStatus.Text.Contains("Fold")) { fixedLast = "Player"; Rules(0, 1, ref playerType, ref playerPower, PFturn); } if (!b1Status.Text.Contains("Fold")) { fixedLast = "Bot 1"; Rules(2, 3, ref botOneType, ref botOnePower, B1Fturn); } if (!b2Status.Text.Contains("Fold")) { fixedLast = "Bot 2"; Rules(4, 5, ref botTwoType, ref botTwoPower, B2Fturn); } if (!b3Status.Text.Contains("Fold")) { fixedLast = "Bot 3"; Rules(6, 7, ref botThreeType, ref botThreePower, B3Fturn); } if (!b4Status.Text.Contains("Fold")) { fixedLast = "Bot 4"; Rules(8, 9, ref botFourType, ref botFourPower, B4Fturn); } if (!b5Status.Text.Contains("Fold")) { fixedLast = "Bot 5"; Rules(10, 11, ref botFiveType, ref botFivePower, B5Fturn); } Winner(playerType, playerPower, "Player", chips, fixedLast); Winner(botOneType, botOnePower, "Bot 1", DefaultStartingChips, fixedLast); Winner(botTwoType, botTwoPower, "Bot 2", DefaultStartingChips, fixedLast); Winner(botThreeType, botThreePower, "Bot 3", DefaultStartingChips, fixedLast); Winner(botFourType, botFourPower, "Bot 4", DefaultStartingChips, fixedLast); Winner(botFiveType, botFivePower, "Bot 5", DefaultStartingChips, 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; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; DefaultStartingChips += f2.a; PFturn = false; playerTurn = true; bRaise.Enabled = true; bFold.Enabled = true; bCheck.Enabled = true; bRaise.Text = "raise"; } } pPanel.Visible = false; botOnePanel.Visible = false; botTwoPanel.Visible = false; botThreePanel.Visible = false; botFourPanel.Visible = false; botFivePanel.Visible = false; playerCall = 0; playerRaise = 0; botOneCall = 0; botOneRaise = 0; botTwoCall = 0; botTwoRaise = 0; botThreeCall = 0; botThreeRaise = 0; botFourCall = 0; botFourRaise = 0; botFiveCall = 0; botFiveRaise = 0; last = 0; callChipsValue = bb; raise = 0; ImgLocation = Directory.GetFiles("Assets\\Cards", "*.png", SearchOption.TopDirectoryOnly); listOfBooleans.Clear(); rounds = 0; playerPower = 0; playerType = -1; type = 0; botOnePower = 0; botTwoPower = 0; botThreePower = 0; botFourPower = 0; botFivePower = 0; botOneType = -1; botTwoType = -1; botThreeType = -1; botFourType = -1; botFiveType = -1; ints.Clear(); CheckWinners.Clear(); winners = 0; winner.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; } tbPot.Text = "0"; pStatus.Text = ""; await Shuffle(); await Turns(); } }