Count the number of player instructions
Revision as of 10:02, 18 December 2018 by OliverBriggs17 (talk | contribs)
Player instruction counter
in order to create a player instruction counter we will first need to define a variable to count this in an area of the program which does not loop e.g.
int instructions = 0;
you then need to increment and output it.
instructions++
and
Console.Writeline("you have used " + instructions + " moves")
I chose to put this in the PlayGame method of the program like this.
private static void PlayGame(List<Character> characters, List<Item> items, List<Place> places)
{
bool stopGame = false;
int instructions = 0;
string instruction, Command;
bool moved = true;
int resultOfOpenClose;
while (!stopGame)
{
if (moved)
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(places[characters[0].CurrentLocation - 1].Description);
DisplayGettableItemsInLocation(items, characters[0].CurrentLocation);
moved = false;
}
instruction = GetInstruction();
instructions++;
Console.WriteLine("you have used " + instructions + " moves");
Command = ExtractCommand(ref instruction);
switch (Command)