Exemple #1
0
        public void NextTurn()
        {
            if (currentPlayer.IsFinished())
            {
                Winner();
            }
            form.EnableCheckBoxes();
            if (currentPlayerIndex < players.Count - 1)
            {
                currentPlayerIndex += DEFAULT_INCREMENT;
            }
            else if (currentPlayerIndex == players.Count - 1)
            {
                currentPlayerIndex = DEFAULT_INDEX;
            }
            currentPlayer = players[currentPlayerIndex];

            form.ShowPlayerName(currentPlayer.Name);

            //form.playerScoreLabel.Text = "";
            form.message_label.Text = "Roll 1";

            numRolls = DEFAULT_NUM_ROLL;
            form.rollDice_button.Enabled = true;
            foreach (Label die in dieLabels)
            {
                die.Text = "";
            }
            form.EnableRollButton();
            currentPlayer.ShowScores();
        }
Exemple #2
0
 public void NextTurn()
 {
     form.EnableCheckBoxes();
     if (currentPlayerIndex < players.Count - 1)
     {
         currentPlayerIndex += DEFAULT_INCREMENT;
     }
     else if (currentPlayerIndex == players.Count - 1)
     {
         currentPlayerIndex = DEFAULT_INDEX;
     }
     currentPlayer = players[currentPlayerIndex];
     //form.playerName_label.Text = currentPlayer.ToString();
     form.ShowPlayerName(currentPlayer.Name);
     //Could not figure it out in Part C... See you in Part D
     form.playerScoreLabel.Text = "";
     form.message_label.Text    = "Roll 1";
     //Later we might need to enable or disable some buttons or labels
     numRolls = DEFAULT_NUM_ROLL;
     form.rollDice_button.Enabled = true;
     foreach (Label die in dieLabels)
     {
         die.Text = "";
     }
     form.EnableRollButton();
     foreach (Label scorelabel in scoreLabels)
     {
         scorelabel.Text = "";
     }
 }
Exemple #3
0
        }//END Save

        private void ContinueGame()
        {
            LoadLabels(form);
            for (int i = 0; i < dice.Length; i++)
            {
                //uncomment one of the following depending how you implmented Active of Die
                // dice[i].SetActive(true);
                dice[i].Active = true;
            }

            form.ShowPlayerName(currentPlayer.Name);
            form.EnableRollButton();
            form.EnableCheckBoxes();
            // can replace string with whatever you used
            form.ShowMessage(ROLLMESSAGES[numRolls]);
            currentPlayer.ShowScores();
        }//END ContinueGame
Exemple #4
0
        }//end Game

        /// <summary>
        /// This method updates currentPlayer and CurrentPlayerIndex
        /// and end game is all player finished all combinations
        /// </summary>
        public void NexTurn()
        {
            currentPlayer   = players[(currentPlayerIndex) % players.Count];
            playersFinished = 0;

            form.ShowPlayerName(currentPlayer.Name);
            form.DisableAndClearCheckBoxes();
            form.EnableRollButton();
            numRolls = 1;

            currentPlayer.ShowScores();

            //check end game and finish the game
            foreach (Player player in players)
            {
                if (player.IsFinished())
                {
                    playersFinished++;
                }
            }
            if (playersFinished == players.Count)
            {
                string name       = "";
                int    grandTotal = 0;
                foreach (Player player in players)
                {
                    if (player.GrandTotal > grandTotal)
                    {
                        grandTotal = player.GrandTotal;
                        name       = player.Name;
                    }
                }
                DialogResult newGame = MessageBox.Show("Game has ended and the winner is " + name + ".\nDo you want to start a new game?", "Game finished",
                                                       MessageBoxButtons.YesNo);
                if (newGame == DialogResult.Yes)
                {
                    form.StartNewGame();
                }
                else
                {
                    form.Close();
                }
            }
            currentPlayerIndex++;
        }//end NextTurn
Exemple #5
0
 public Game(Form1 form)
 {
     this.form          = form;
     players            = new BindingList <Player>();
     currentPlayerIndex = 0;
     dieLabels          = this.form.GetDice();
     dice = new Die[Form1.NUM_DICE];
     for (int i = 0; i < 5; i++)
     {
         dice[i] = new Die(dieLabels[i]);
     }
     players.Add(new Player("player1", form.GetScoresTotals()));
     currentPlayer   = players[currentPlayerIndex];
     playersFinished = 0;
     numRolls        = 0;
     form.EnableRollButton();
     for (int i = 0; i < Form1.NUM_BUTTONS + Form1.NUM_TOTALS; i++)
     {
         form.DisableScoreButton((ScoreType)i);
     }
     players[currentPlayerIndex].ShowScores();
 }
Exemple #6
0
        //---------------------------------------------------------------------------------------------------------------------------------------------------

        public void NextTurn()
        {
            //If game is finished display the winner and handle the start of a new game
            if (playersFinished == players.Count)
            {
                if (timesOKButtonClicked == 0)
                {
                    DisplayWinner(DetermineWinner());
                }
                else
                {
                    form.StartNewGame();
                }

                timesOKButtonClicked += 1;

                //Else, iterate through players as appropriate
            }
            else
            {
                switch (currentPlayerIndex)
                {
                case 0:
                    if (players.Count == 1)
                    {
                        currentPlayerIndex = 0;
                    }
                    else
                    {
                        currentPlayerIndex = 1;
                    }
                    break;

                case 1:
                    if (players.Count == 2)
                    {
                        currentPlayerIndex = 0;
                    }
                    else
                    {
                        currentPlayerIndex = 2;
                    }
                    break;

                case 2:
                    if (players.Count == 3)
                    {
                        currentPlayerIndex = 0;
                    }
                    else
                    {
                        currentPlayerIndex = 3;
                    }
                    break;

                case 3:
                    if (players.Count == 4)
                    {
                        currentPlayerIndex = 0;
                    }
                    else
                    {
                        currentPlayerIndex = 4;
                    }
                    break;

                case 4:
                    if (players.Count == 5)
                    {
                        currentPlayerIndex = 0;
                    }
                    else
                    {
                        currentPlayerIndex = 5;
                    }
                    break;

                default:
                    currentPlayerIndex = 0;
                    break;
                }

                currentPlayer = players[currentPlayerIndex];
                numRolls      = 0;
                currentPlayer.ShowScores();
                form.ShowPlayerName(players[currentPlayerIndex].Name);
                form.ShowMessage(messages[3]);
                form.EnableRollButton();
            }
        }