Skip to content

Commit

Permalink
Added Feature to be able to play game again.
Browse files Browse the repository at this point in the history
TODO: Reset player positions after reinitialisation and complete reinitialise portion of SetupGame method.
  • Loading branch information
redleek committed Dec 4, 2014
1 parent 60d62d3 commit 7977054
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions TacticalSpaceCheeseRacer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ static void SetupGame(bool reinitialise, bool use_old_names)
{
if (reinitialise)
{
bool player_nums_same = ReadYN("Use same number of players? [Y/n]: ");
/*
bool player_nums_same = ReadYN("Use same number of players?: ");
if (player_nums_same)
{
Console.WriteLine("WARNING: Incomplete method parameter, still in development.");
return;
}
*/
}
else
{
Expand Down Expand Up @@ -231,7 +233,6 @@ static void PlayerTurn(int playerno)
}
#endregion


static void Main(string[] args)
{
// Parse the command line arguments given to the program.
Expand All @@ -247,25 +248,40 @@ static void Main(string[] args)
// Set up the game for the first time. Reinitialise and use of old names will never need to be set on the first set up.
SetupGame(false, false);

// Enter main game loop while the game has not been won.
// Loop so we can ask if the players want to play again.
bool replay;
do
{
for (int playercount = 0; playercount < no_of_players; playercount++)

// Enter main game loop while the game has not been won.
do
{
PlayerTurn(playercount);
// Check if the current player has won.
if (players[playercount].position >= 64)
{
gamewon = true;
Console.WriteLine("{0} has won the game!", players[playercount].name);
break;
}
else
for (int playercount = 0; playercount < no_of_players; playercount++)
{
// Do tactical stuff later.
PlayerTurn(playercount);
// Check if the current player has won.
if (players[playercount].position >= 64)
{
gamewon = true;
Console.WriteLine("{0} has won the game!", players[playercount].name);
break;
}
else
{
// Do tactical stuff later.
}
}
} while (!gamewon);

// Ask if they want to play again and if they want to keep the same names.
replay = ReadYN("Do you want to play again?: ");
if (replay)
{
bool old_names = ReadYN("Do you want to use the same names for players?: ");
SetupGame(true, old_names);
}
} while (!gamewon);

} while (replay);

/* Testing functions
SetupGame(false, false);
Expand All @@ -275,7 +291,6 @@ static void Main(string[] args)
Console.WriteLine("{0} has a position of {1}", players[0].name, players[0].position);
*/

Console.ReadLine();
return;
}
}
Expand Down

0 comments on commit 7977054

Please sign in to comment.