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(); }
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 = ""; } }
}//END NextTurn public void RollDice() { //Used to check the number of players on the first roll and adjusts to the value of numericUpDown1 CheckNumPlayers(); for (int i = 0; i < dice.Length; i++) { if (dice[i].Active) { dice[i].Roll(); } } numRolls++; if (numRolls == 1) { form.ShowMessage(ROLLMESSAGES[numRolls]); form.EnableCheckBoxes(); EnableScoreButtons(); DisableUsedButtons(); } else if (numRolls == 2) { form.ShowMessage(ROLLMESSAGES[numRolls]); } else if (numRolls == 3) { form.ShowMessage(ROLLMESSAGES[numRolls]); form.DisableRollButton(); } }//END RollDice
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(); }
public void RollDice() { //Once the first roll has been made no more players can be added. form.DisableUpDown(); for (int i = 0; i < dice.Length; i++) { dice[i].Roll(); dieLabels[i].Text = dice[i].FaceValue.ToString(); } if (numRolls == 0) { string message = "Roll 1"; form.EnableAllButtons(); // Turns off the already used scorebuttons. form.checkScoreButton(); form.EnableCheckBoxes(); form.ShowMessage(message); } if (numRolls == 1) { string message = "Roll 2 or choose a combination to score"; form.ShowMessage(message); } if (numRolls == 2) { string message = "Roll 3, Your turn has ended - click OK"; form.ShowMessage(message); form.DisableRollButtons(); form.ShowOKButton(); } numRolls++; }
}//end Save /// <summary> /// Continue the game after loading a saved game /// /// Assumes game was saved at the start of a player's turn before they had rolled dice. /// </summary> 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("Roll 1"); currentPlayer.ShowScores(); }//end ContinueGame
//--------------------------------------------------------------------------------------------------------------------------------------------------- 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(); } }