public void RollDice() { for (int i = 0; i < dieLabels.Length; i++) { if (dice[i].Active) { if (numRolls == 1) { scoreLabels = form.GetScoreLabels(); 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; }
public Game(Form1 formOneObj) { this.form = formOneObj; currentPlayerIndex = DEFAULT_INDEX; playersFinished = DEFAULT_FINISH; scoreLabels = form.GetScoreLabels(); players = new BindingList <Player>() { new Player("Player 1", scoreLabels) }; dice = new Die[NUM_OF_DICE]; initialize(); numRolls = DEFAULT_NUM_ROLL; form.playerBindingSource.DataSource = players; currentPlayer = Players[currentPlayerIndex]; }
public void RollDice() { for (int i = 0; i < dieLabels.Length; i++) { if (dice[i].Active) { if (numRolls == 1) { //foreach (ScoreType scoretype in Enum.GetValues(typeof(ScoreType))) //{ // if (currentPlayer.IsAvailable(scoretype)) // { // form.EnableScoreButton(scoretype); // } // else // { // form.DisableScoreButton(scoretype); // } // form.EnableScoreButton(scoretype); // if (!currentPlayer.IsAvailable(scoretype)) // { // form.DisableScoreButton(scoretype); // } //} 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.GetScoreLabels(); 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; }