2022 - Allow the player to choose either a random lock or a specific lock number
The game currently selects a random lock, find the SetupGame method of the BreakThrough class:
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();
}
}
The final line of code 'CurrentLock = GetRandomLock()' is what randomly chooses a lock.
What you need to do
- Ask the user if they want a random lock or choose a lock
- store the input from the keyboard
- if they want the random lock, then run the 'CurrentLock = GetRandomLock()' line
- if they want to choose a lock then display the number of locks
- then ask them to enter a number from 1 to the number of locks
- then set the current lock to the required lock