Example #1
0
 /// <summary>
 /// Disables all of the score buttons.
 /// </summary>
 private void DisableAllScoreButtons()
 {
     for (ScoreType i = ScoreType.Ones; i < ScoreType.YahtzeeBonus; i++)
     {
         form.DisableScoreButton(i);
     }
 }
Example #2
0
 /// <summary>
 /// Passes the clicked ScoreType to the method in Player,
 /// disabeling the label for this players future turns.
 /// Then if the label is disabled it returns the ScoreType that
 /// then disabels the Button corresponding to label.
 /// </summary>
 /// <param name="done"></param>
 /// <returns></returns>
 public void IsNotAvailable(ScoreType done)
 {
     if (currentPlayer.IsAvailable(done) == true)
     {
         form.DisableScoreButton(done);
     }
 }
Example #3
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;
        }
Example #4
0
 public void NextTurn()
 {
     if (playersFinished >= players.Count())
     {
         FinishGame();
         return;
     }
     numRolls            = 0;
     currentPlayerIndex += (currentPlayerIndex + 1 == players.Count + 1)?0:1;
     currentPlayerIndex *= (currentPlayerIndex + 1 == players.Count + 1)?0:1;
     form.ShowPlayerName(players[currentPlayerIndex].Name);
     form.DisableAndClearCheckBoxes();
     for (int i = 0; i < Form1.NUM_BUTTONS + Form1.NUM_TOTALS; i++)
     {
         form.DisableScoreButton((ScoreType)i);
     }
     players[currentPlayerIndex].ShowScores();
     form.ShowPlayerName(players[currentPlayerIndex].Name);
 }
Example #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();
 }