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 = ""; } }
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(); }
/// <summary> /// Gets the next player in the list and sets the UI and scores /// to that players details and scores. /// </summary> private void GetNextPlayer() { currentPlayerIndex++; //if player index is greater than the list of players reset index to first player. if (currentPlayerIndex >= players.Count) { currentPlayerIndex = FIRST_PLAYER; } //set current player by player index and show their score. currentPlayer = players[currentPlayerIndex]; currentPlayer.ShowScores(); form.ShowPlayerName(currentPlayer.Name); }
}//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
}//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
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); }
public void NextTurn() { if (currentPlayer.IsFinished() == true) { // Runs a method that sets the Game Over GUI. gameOverControls(); } // If the current player index is larger than the // number of players on the binding list it loops back to 0. if (currentPlayerindex > form.numberofplayers() - 2) { currentPlayerindex = 0; } else { currentPlayerindex++; } currentPlayer = players[currentPlayerindex]; string name = Names[currentPlayerindex]; playersFinished++; string message = "Roll 1"; for (int i = 0; i < dice.Length; i++) { dieLabels[i].Text = ""; } numRolls = 0; currentPlayer.ShowScores(); form.DisableAllButtons(); form.DisableAndClearCheckBoxes(); form.EnableRollButtons(); form.ShowPlayerName(name); form.ShowMessage(message); form.HideOKButton(); }
/// <summary> /// Creates a new game and initiates the GUI desgin and starting buttons. /// </summary> /// <param name="form"></param> public Game(Form1 form) { form.clearScoreLabels(); players.ResetBindings(); players.Add(new Player(Names[0], form.GetScoreTotals())); string message = "Please Select the Number of Players"; currentPlayerindex = 0; playersFinished = 0; numRolls = 0; this.form = form; this.dieLabels = this.form.GetDice(); for (int i = 0; i < dice.Length; i++) { dice[i] = new Die(dieLabels[i]); } currentPlayer = players[currentPlayerindex]; for (int i = 0; i < dice.Length; i++) { dieLabels[i].Text = ""; } string name = Names[currentPlayerindex]; form.DisableAndClearCheckBoxes(); form.DisableAllButtons(); form.ShowPlayerName(name); form.EnableUpDown(); form.EnableRollButtons(); form.ShowMessage(message); form.HideOKButton(); form.enablesave(); form.disableload(); }
public Game(Form1 form1) { form = form1; playersFinished = 0; currentPlayerIndex = 0; players = new BindingList <Player>(); dieLabels = form.GetDice(); numRolls = 0; int numPlayers = form.NumberPlayers(); for (int i = 0; i < numPlayers; i++) { string name = "Player " + (i + 1); players.Add(new Player(name, form.GetScoresTotals())); } currentPlayer = players[currentPlayerIndex]; form.ShowPlayerName(currentPlayer.Name); form.ShowMessage(ROLLMESSAGES[numRolls]); for (int i = 0; i < dice.Length; i++) { dice[i] = new Die(dieLabels[i]); } }//END Game
//--------------------------------------------------------------------------------------------------------------------------------------------------- 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(); } }