/// <summary> /// Algorithm below currently plays only one game /// /// when have this working correctly, add the abilty for the user to /// play more than 1 game if they choose to do so. /// </summary> /// <param name="args"></param> static void Main(string[] args) { DisplayIntroductionMessage(); /* * Set up the board in Board class (Board.SetUpBoard) * Determine number of players - initally play with 2 for testing purposes * Create the required players in Game Logic class * and initialize players for start of a game * loop until game is finished * call PlayGame in Game Logic class to play one round * Output each player's details at end of round * end loop * Determine if anyone has won * Output each player's details at end of the game */ // INPUT CODE BELOW int game_state = 10; while (game_state != 0) { if (game_state == 10) //First Round { DisplayNumOfPlayerQuery(); Board.SetUpBoard(); SpaceRaceGame.Players.Clear(); SpaceRaceGame.SetUpPlayers(); DisplayFirstRoundMessage(); //First Round Message SpaceRaceGame.PlayOneRound(); DisplayRoundDetails(); game_state = 1; } else if (game_state == 1) //Next Round { DisplayNextRoundMessage(); SpaceRaceGame.PlayOneRound(); if (SpaceRaceGame.GameFinish()) { game_state = 2; } else { DisplayRoundDetails(); } } else if (game_state == 2) { DisplayRoundDetailsWithWinner(); game_state = 3; } else if (game_state == 3) // Prompt asking to play again { DisplayPromptToPlayAgain(); char x = Char.Parse(Console.ReadLine()); if (x == 'Y' || x == 'y') { game_state = 10; //Console.Write(game_state); } else if (x == 'N' || x == 'n') { game_state = 0; } } } PressEnter(); }//end Main
} //end UpdatePlayersGuiLocations private void rolldiceButton_Click(object sender, EventArgs e) { // c) if (noRadioButton.Checked == true) { rolldiceButton.Enabled = false; playersDataGridView.Enabled = false; exitButton.Enabled = false; numOfPlayersComboBox.Enabled = false; UpdatePlayersGuiLocations(TypeOfGuiUpdate.RemovePlayer); SpaceRaceGame.PlayOneRound(); UpdatePlayersGuiLocations(TypeOfGuiUpdate.AddPlayer); UpdatesPlayersDataGridView(); // After round numOfPlayersComboBox.Enabled = false; gameresetButton.Enabled = true; //Enable resetButton end of every round including game end exitButton.Enabled = true; // Enable Exit button after the game is end string winner = ""; if (SpaceRaceGame.GameFinish() == false) { rolldiceButton.Enabled = true; //enable rollDice button after a round. } else { foreach (Player player in SpaceRaceGame.Players) { if (player.AtFinish) { winner += player.Name + ", "; } } MessageBox.Show("The following player(s) finished the game\n\t" + winner, "", MessageBoxButtons.OK); } } else if (yesRadioButton.Checked == true) { rolldiceButton.Enabled = false; playersDataGridView.Enabled = false; exitButton.Enabled = false; numOfPlayersComboBox.Enabled = false; UpdatePlayersGuiLocationsSingleSteps(TypeOfGuiUpdate.RemovePlayer, counter); SpaceRaceGame.PlayOneRoundSingleSteps(counter); UpdatePlayersGuiLocationsSingleSteps(TypeOfGuiUpdate.AddPlayer, counter); UpdatesPlayersDataGridView(); counter++; if (counter == SpaceRaceGame.NumberOfPlayers) { counter = 0; } // after round numOfPlayersComboBox.Enabled = false; gameresetButton.Enabled = true; //Enable resetButton end of every round including game end exitButton.Enabled = true; // Enable Exit button after the game is end if (SpaceRaceGame.GameFinish() == false) { rolldiceButton.Enabled = true; //enable rollDice button after a round. } else { foreach (Player player in SpaceRaceGame.Players) { if (player.AtFinish) { MessageBox.Show("The following player(s) finished the game\n\t" + player.Name, "", MessageBoxButtons.OK); } } } } }