Beispiel #1
0
        // game looop STARTS HERE
        public void gameLoop(TournamentOne f)
        {
            if (gameCount > 1 && roundCount == 0)
            {
                board      = new List <Card>();
                smallBlind = smallBlind * gameCount;
            }

            // simulates every computer player one round
            if (roundCount <= 0)
            {
                players[blindCounter].setChips((players[0].getChips()) - smallBlind);
                players[blindCounter + 1].setChips((players[0].getChips()) - smallBlind * 2);
                players[blindCounter].setPlayerPot(smallBlind);
                players[blindCounter + 1].setPlayerPot(smallBlind * 2);
                blindCounter = blindCounter + 1;
                if (blindCounter > 9)
                {
                    blindCounter = 0;
                }
                for (int i = 1; i < 9; i++)
                {
                    if (players[i].checkIfActive())
                    {
                        computerPlayerTalk(players[i]);
                    }
                }
                roundCount = roundCount + 1;
                TournamentOne newForm = new TournamentOne();
                tourlist.Add(newForm);
                tourlist[tourlist.Count() - 1].Show();
                if ((tourlist.Count() - 2) < 0)
                {
                    f.Close();
                }
                else
                {
                    tourlist[tourlist.Count() - 2].Close();
                }
            }
            else if (roundCount == 1)
            {
                for (int i = 1; i < 9; i++)
                {
                    if (players[i].checkIfActive())
                    {
                        computerPlayerTalk(players[i]);
                    }
                }
                board       = deck.dealBoard();
                boardActive = true;
                roundCount  = roundCount + 1;
                TournamentOne newForm = new TournamentOne();
                tourlist.Add(newForm);
                tourlist[tourlist.Count() - 1].Show();
                if ((tourlist.Count() - 2) < 0)
                {
                    f.Hide();
                }
                else
                {
                    tourlist[tourlist.Count() - 2].Close();
                }
            }
            else if (roundCount == 2)
            {
                for (int i = 1; i < 9; i++)
                {
                    if (players[i].checkIfActive())
                    {
                        computerPlayerTalk(players[i]);
                    }
                }
                roundCount = roundCount + 1;
                TournamentOne newForm = new TournamentOne();
                tourlist.Add(newForm);
                tourlist[tourlist.Count() - 1].Show();
                if ((tourlist.Count() - 2) < 0)
                {
                    f.Hide();
                }
                else
                {
                    tourlist[tourlist.Count() - 2].Close();
                }
            }
            else if (roundCount == 3)
            {
                for (int i = 1; i < 9; i++)
                {
                    if (players[i].checkIfActive())
                    {
                        computerPlayerTalk(players[i]);
                    }
                }
                roundCount = roundCount + 1;
                TournamentOne newForm = new TournamentOne();
                tourlist.Add(newForm);
                tourlist[tourlist.Count() - 1].Show();
                if ((tourlist.Count() - 2) < 0)
                {
                    f.Hide();
                }
                else
                {
                    tourlist[tourlist.Count() - 2].Close();
                }
            }
            else if (roundCount == 4)
            {
                for (int i = 1; i < 9; i++)
                {
                    if (players[i].checkIfActive())
                    {
                        computerPlayerTalk(players[i]);
                    }
                }
                roundCount = roundCount + 1;
                TournamentOne newForm = new TournamentOne();
                tourlist.Add(newForm);
                tourlist[tourlist.Count() - 1].Show();
                if ((tourlist.Count() - 2) < 0)
                {
                    f.Hide();
                }
                else
                {
                    tourlist[tourlist.Count() - 2].Close();
                }
            }
            else if (roundCount > 4)
            {
                for (int i = 1; i < 9; i++)
                {
                    if (players[i].checkIfActive())
                    {
                        computerPlayerTalk(players[i]);
                    }
                    if (activePlayersNumber < 2)
                    {
                        roundCount = 0;
                    }
                }
                for (int j = 0; j < 9; j++)
                {
                    if (!players[j].checkIfActive())
                    {
                        activePlayersNumber = activePlayersNumber - 1;
                    }
                }
                if (activePlayersNumber == 0)
                {
                    if ((tourlist.Count() - 2) < 0)
                    {
                        f.Hide();
                    }
                    else
                    {
                        tourlist[tourlist.Count() - 2].Close();
                    }
                }
                for (int i = 0; i < 9; i++)
                {
                    players[i].setPlayerPot(players[i].getPlayerPot());
                }
                roundCount          = 0;
                activePlayersNumber = 9;
                gameCount           = gameCount + 1;
                boardActive         = false;
                TournamentOne newForm = new TournamentOne();
                tourlist.Add(newForm);
                tourlist[tourlist.Count() - 1].Show();
                if ((tourlist.Count() - 2) < 0)
                {
                    f.Close();
                }
                else
                {
                    tourlist[tourlist.Count() - 2].Close();
                }
            }
        }//end of gameLoop() method.