2022 - When you start the game it automatically loads a saved game, adapt it to ask which game to load
Issue
When you currently start the game you are prompted "Enter L to load a game from a file, anything else to play a new game:> ". This can be found in the SetupGame method of the BreakThrough class. This is shown below:
private void SetupGame()
{
string Choice;
Console.Write("Enter L to load a game from a file, anything else to play a new game:> ");
Choice = Console.ReadLine().ToUpper();
if (Choice == "L")
{
if (!LoadGame("game1.txt"))
{
GameOver = true;
}
}
else
{
CreateStandardDeck();
Deck.Shuffle();
for (int Count = 1; Count <= 5; Count++)
{
MoveCard(Deck, Hand, Deck.GetCardNumberAt(0));
}
AddDifficultyCardsToDeck();
Deck.Shuffle();
CurrentLock = GetRandomLock();
}
}
When you choose to load a game, the program automatically loads "game1.txt".
What you need to do
- Add the code to ask for a file name
- test if the file name exists
- if it does, load that file
- if it doesn't, load "game1.txt"