コード例 #1
0
ファイル: GameForm.cs プロジェクト: pieiscool32/CIS-279
        private void callButton_Click(object sender, EventArgs e)
        {
            if (Wager.bankrupt(round))
            {
                showMessage("Insufficient Funds");
            }
            else if (busy)
            {
                showMessage("Please Wait");
            }
            else if (round.playerHand == null)
            {
                showMessage("Place Bet First");
            }
            else
            {
                setInfo(gameInfo, "Dealer Calls");
                Debug.WriteLine("Dealer Calls");
                placeBet(bet, 0); //dealer is always 0

                round.Call();
                setInfo(dealerInfo, $"Win Odds: {round.player[0].winOdds * 100}%\n{round.player[0].handType}\nCards: {round.deck.Count}");
                busy = true; //the system is now busy
                doCall();
            }
        }
コード例 #2
0
ファイル: GameForm.cs プロジェクト: pieiscool32/CIS-279
 private void Bet(int index)
 {
     //Used by the bots only
     Debug.WriteLine($"Computer{index} has {round.player[index].bestScore} @ {round.player[index].winOdds * 100}%");
     //If the odds of winning are above the threshold
     if (round.player[index].winOdds >= betFold)
     {
         setInfo(gameInfo, $"Computer{index} Raises");
         Debug.WriteLine($"Computer{index} Raises ${bet}");
         placeBet(bet, index);
     }
     else
     {
         setInfo(gameInfo, $"Computer{index} Folds");
         Debug.WriteLine($"Computer{index} Folds");
         round.player[index].canPlay = false;
     }
     if (!Wager.canPlay(round, autopilot))
     {
         Task.Delay(delay).ContinueWith(t => payWinner(Wager.winner(round)));
     }
     else if (Wager.IsLast(round, index))
     {
         busy = false;
     }
 }
コード例 #3
0
ファイル: GameForm.cs プロジェクト: pieiscool32/CIS-279
        private void betButton_Click(object sender, EventArgs e)
        {
            if (Wager.bankrupt(round))
            {
                showMessage("Insufficient Funds");
            }
            else if (round.turn > 0)
            {
                showMessage("Finish Round First");
            }
            else if (busy)
            {
                showMessage("Please Wait");
            }
            else if (round.deck.Count < 5 + 2 * round.numPlayers)
            {
                showMessage("Insufficient Cards");
            }
            else
            {
                //cleans up the board
                Clean(false);
                setInfo(gameInfo, $"Dealer Bets ${bet}");
                Debug.WriteLine($"Dealer Bets ${bet}");

                //everyone makes an inital bet and can play
                for (int index = 0; index < round.numPlayers; index++)
                {
                    placeBet(bet, index);
                    round.player[index].canPlay = true;
                }

                dealerInfo.Visible = true;
                potMoney.Visible   = true;

                round.Bet(); //does a betting round
                if (debugWindow != null)
                {
                    updateTelemetry();
                }
                setInfo(dealerInfo, $"Win Odds: {round.player[0].winOdds * 100}%\n{round.player[0].handType}\nCards: {round.deck.Count}");

                updateTable();

                busy = true; //the system is now busy
                int num = 1; //used to keep track of delays
                foreach (var player in round.player)
                {
                    if (player.canPlay && player.index > 0)
                    {
                        Task.Delay(num * delay).ContinueWith(t => Bet(player.index));
                        num++;
                    }
                }
            }
        }
コード例 #4
0
ファイル: GameForm.cs プロジェクト: pieiscool32/CIS-279
        private void Call(int index)
        {
            //Used by the bots only
            if (round.player[index].canPlay)
            {
                Debug.WriteLine($"Computer{index} has {round.player[index].bestScore} @ {round.player[index].winOdds * 100}%");
                //If the odds of winning are above the threshold
                if (round.player[index].winOdds >= callFold)
                {
                    setInfo(gameInfo, $"Computer{index} Raises");
                    Debug.WriteLine($"Computer{index} Raises ${bet}");
                    placeBet(bet, index);
                }
                else
                {
                    setInfo(gameInfo, $"Computer{index} Folds");
                    Debug.WriteLine($"Computer{index} Folds");
                    round.player[index].canPlay = false;
                    if (!Wager.canPlay(round, autopilot) && autopilot)
                    {
                        Task.Delay(delay).ContinueWith(t => payWinner(new List <int>()
                        {
                            index
                        }));
                    }
                }
            }
            bool last = Wager.IsLast(round, index);

            if (!Wager.canPlay(round, autopilot) && !autopilot)
            {
                Task.Delay(delay).ContinueWith(t => payWinner(Wager.winner(round)));
            }
            else if (round.turn == 3 && last)
            {
                Task.Delay(delay).ContinueWith(t => payWinner(Wager.winner(round)));
            }
            else if (autopilot && last)
            {
                if (Wager.canPlay(round, autopilot))
                {
                    round.player[index].canPlay = false;
                    if (!Wager.canPlay(round, autopilot))
                    {
                        Task.Delay(delay).ContinueWith(t => payWinner(new List <int>()
                        {
                            index
                        }));
                    }
                    else
                    {
                        round.player[index].canPlay = true;
                        Debug.WriteLine("Autopilot Advances");
                        round.Call();
                        updateTable();
                        updateTelemetry();
                        setInfo(gameInfo, "River Revealed");
                        Debug.WriteLine("River Revealed");
                        Task.Delay(delay).ContinueWith(t => doCall());
                    }
                }
            }
            else if (last)
            {
                busy = false;
            }
        }