Esempio n. 1
0
        }//END IsGameFinished

        /// <summary>
        /// Enables all the score buttons
        /// </summary>
        private void EnableScoreButtons()
        {
            for (ScoreType i = ScoreType.Ones; i < ScoreType.YahtzeeBonus; i++)
            {
                form.EnableScoreButton(i);
            }
        }//END EnableScoreButtons
Esempio n. 2
0
        }//end NextTurn

        /// <summary>
        /// This method will roll all of the active dice
        /// and show unscored buttons
        /// </summary>
        public void RollDice()
        {
            string[] messages = new string[4] {
                "Roll 1", "Roll 2 or choose a combination to score",
                "Roll 3 or choose a combination to score", "Choose a combination to score"
            };
            for (int index = 0; index < 5; index++)
            {
                if (dice[index].Active)
                {
                    dice[index].Roll();
                }
            }

            form.ShowMessage(messages[numRolls]);
            numRolls++;
            if (numRolls > 3)
            {
                form.DisableRollButton();
            }

            //enable unscored buttons
            for (int index = (int)ScoreType.Ones; index <= (int)ScoreType.Sixes; index++)
            {
                if (currentPlayer.IsAvailable((ScoreType)index))
                {
                    form.EnableScoreButton((ScoreType)index);
                }
            }

            for (int index = (int)ScoreType.ThreeOfAKind; index <= (int)ScoreType.Yahtzee; index++)
            {
                if (currentPlayer.IsAvailable((ScoreType)index))
                {
                    form.EnableScoreButton((ScoreType)index);
                }
            }
        }//end RollDice
Esempio n. 3
0
 /// <summary>
 /// Sets the score buttons depending on the current player's available scorings.
 /// </summary>
 private void SetScoreButtonStatus()
 {
     for (ScoreType i = ScoreType.Ones; i < ScoreType.YahtzeeBonus; i++)
     {
         if (currentPlayer.IsAvailable(i))
         {
             form.EnableScoreButton(i);
         }
         else
         {
             form.DisableScoreButton(i);
         }
     }
 }
Esempio n. 4
0
        public void RollDice()
        {
            playersFinished = 0;
            foreach (Player player in players)
            {
                playersFinished += (player.IsFinished()) ? 1 : 0;
            }
            if (playersFinished >= players.Count())
            {
                NextTurn();
            }
            numRolls++;
            form.ShowPlayerName(players[currentPlayerIndex].Name);
            form.EnableCheckBoxes();
            foreach (Die die in dice)
            {
                if (die.Active)
                {
                    die.Roll();
                }
            }
            switch (numRolls)
            {
            case 0:
                form.ShowMessage("First Roll");
                break;

            case 1:
                form.ShowMessage("Roll Again or Choose a Score Bellow");
                break;

            case 2:
                form.ShowMessage("Final Roll, Please Choose a Score");
                break;
            }
            for (int i = 0; i < Form1.NUM_BUTTONS + Form1.NUM_TOTALS; i++)
            {
                if (players[currentPlayerIndex].IsAvailable((ScoreType)i))
                {
                    form.EnableScoreButton((ScoreType)i);
                }
                else
                {
                    form.DisableScoreButton((ScoreType)i);
                }
            }
            players[currentPlayerIndex].IsFinished();
        }
Esempio n. 5
0
        public void RollDice()
        {
            for (int i = 0; i < dieLabels.Length; i++)
            {
                if (dice[i].Active)
                {
                    if (numRolls == 1)
                    {
                        foreach (Button scorebutton in scoreButtons)
                        {
                            if (scorebutton != null)
                            {
                                if (currentPlayer.IsAvailable((ScoreType)Array.IndexOf(scoreButtons, scorebutton)))
                                {
                                    form.EnableScoreButton((ScoreType)Array.IndexOf(scoreButtons, scorebutton));
                                }
                                else
                                {
                                    form.DisableScoreButton((ScoreType)Array.IndexOf(scoreButtons, scorebutton));
                                }
                            }
                        }
                        scoreLabels = form.GetScoresTotals();
                        foreach (Label scorelabel in scoreLabels)
                        {
                            scorelabel.Text = "";
                        }
                        form.message_label.Text = "Roll 2 or choose a combination to score";
                    }
                    else if (numRolls == 2)
                    {
                        form.message_label.Text = "Roll 3 or choose a combination to score";
                    }
                    else if (numRolls == 3)
                    {
                        form.message_label.Text      = @"Choose a combination to score. 
Your turn has ended - click OK";
                        form.rollDice_button.Enabled = false;
                    }
                    dice[i].Roll();
                    dieLabels[i].Text = dice[i].FaceValue.ToString();
                }
            }

            numRolls = numRolls + 1;
        }
Esempio n. 6
0
        //---------------------------------------------------------------------------------------------------------------------------------------------------

        public void RollDice()
        {
            currentPlayer = players[currentPlayerIndex];
            for (int i = 0; i < NUMBER_OF_DICE; i++)
            {
                if (dice[i].Active)
                {
                    dice[i].Roll();
                    faceValues[i] = dice[i].FaceValue;
                }
                else
                {
                }
            }
            numRolls += 1;

            if (numRolls == 1)
            {
                form.ShowMessage(messages[numRolls - 1]);
                form.EnableCheckBoxes();

                //If a scoring combination is available for currentPlayer, enable it.
                if (currentPlayer.IsAvailable(ScoreType.Ones))
                {
                    form.EnableScoreButton(ScoreType.Ones);
                }
                if (currentPlayer.IsAvailable(ScoreType.Twos))
                {
                    form.EnableScoreButton(ScoreType.Twos);
                }
                if (currentPlayer.IsAvailable(ScoreType.Threes))
                {
                    form.EnableScoreButton(ScoreType.Threes);
                }
                if (currentPlayer.IsAvailable(ScoreType.Fours))
                {
                    form.EnableScoreButton(ScoreType.Fours);
                }
                if (currentPlayer.IsAvailable(ScoreType.Fives))
                {
                    form.EnableScoreButton(ScoreType.Fives);
                }
                if (currentPlayer.IsAvailable(ScoreType.Sixes))
                {
                    form.EnableScoreButton(ScoreType.Sixes);
                }
                if (currentPlayer.IsAvailable(ScoreType.ThreeOfAKind))
                {
                    form.EnableScoreButton(ScoreType.ThreeOfAKind);
                }
                if (currentPlayer.IsAvailable(ScoreType.FourOfAKind))
                {
                    form.EnableScoreButton(ScoreType.FourOfAKind);
                }
                if (currentPlayer.IsAvailable(ScoreType.FullHouse))
                {
                    form.EnableScoreButton(ScoreType.FullHouse);
                }
                if (currentPlayer.IsAvailable(ScoreType.SmallStraight))
                {
                    form.EnableScoreButton(ScoreType.SmallStraight);
                }
                if (currentPlayer.IsAvailable(ScoreType.LargeStraight))
                {
                    form.EnableScoreButton(ScoreType.LargeStraight);
                }
                if (currentPlayer.IsAvailable(ScoreType.Chance))
                {
                    form.EnableScoreButton(ScoreType.Chance);
                }
                if (currentPlayer.IsAvailable(ScoreType.Yahtzee))
                {
                    form.EnableScoreButton(ScoreType.Yahtzee);
                }
            }
            else if (numRolls == 2)
            {
                form.ShowMessage(messages[numRolls - 1]);
            }
            else if (numRolls == 3)
            {
                form.ShowMessage(messages[numRolls - 1]);
                form.DisableRollButton();
                form.DisableAndClearCheckBoxes();
            }
        }