public Model.MazeResult StartNavigation(Model.Hunter hunter) { var entranceRoomId = -1; System.Console.WriteLine("Starting maze navigation."); System.Console.WriteLine("Parsing maze metadata.."); System.Console.WriteLine("Getting entrance room..."); try { entranceRoomId = _mazeGenerator.GetEntranceRoom(); } catch (System.Exception ex) { System.Console.WriteLine("Maze metadata is wrong, no entrance room was found!"); System.Console.WriteLine(ex.Message); //TODO log e using NLog or whatever System.Console.ReadLine(); System.Environment.Exit(0); } System.Console.WriteLine("Initialize entrance room...."); return(EmulateMaze(hunter, entranceRoomId)); }
public void OfferCondelonces(Model.Hunter hunter) { System.Console.Clear(); System.Console.WriteLine("{0}, Ooooooooooooops!"); System.Console.WriteLine("You stepped on so many traps and didn't find the treasure.."); System.Console.WriteLine("Good luck next time!"); System.Console.WriteLine(); }
public void Celebrate(Model.Hunter hunter) { System.Console.Clear(); System.Console.WriteLine("Congratulations {0}!"); System.Console.WriteLine("You made it to the treasure with {0} steps and {1} health points and proved you are a lucky person..", hunter.StepsCount, hunter.HealthPoint); System.Console.WriteLine(); PlayRandomMusic(); }
public void DisplayHunterStatus(Model.Hunter hunter) { if (hunter == null) { throw new System.ArgumentNullException(nameof(hunter)); } System.Console.WriteLine("Dear Player: HP:{0} Steps:{1}", hunter.HealthPoint, hunter.StepsCount); System.Console.WriteLine(); System.Console.WriteLine(); }
public void EmulateMain() { Initialize(); var hunter = new Model.Hunter { StepsCount = 0, HealthPoint = ApplicationSettings.HealthPoint, }; while (System.Console.KeyAvailable == false) { // Load dll dynamically // Temporarily use a dummy object to draw the skeleton // IMazeIntegration mazeGenerator; var menuChoice = System.Console.ReadKey(true).Key; switch (menuChoice) { case System.ConsoleKey.D1: { NewGame(); StartNavigation(hunter); break; } case System.ConsoleKey.D2: { NewGame(true); StartNavigation(hunter); break; } default: { System.Console.WriteLine("Not a valid choice!"); continue; } } ShowMenu(); } }
public Model.MazeResult EmulateMaze(Model.Hunter hunter, int roomId) { while (true) { System.Console.Clear(); hunter.StepsCount++; // Check if treasure found if (_mazeGenerator.HasTreasure(roomId)) { Celebrate(hunter); return(Model.MazeResult.TreasureFound); } // Check if room has a trap if (_mazeGenerator.CausesInjury(roomId)) { if (hunter.HealthPoint <= 1) { OfferCondelonces(hunter); return(Model.MazeResult.HunterDied); } System.Console.WriteLine("Oj! You have been injured.."); System.Console.WriteLine("You suffered a loss of 1 HP"); hunter.HealthPoint--; } // Display some information DisplayRoomInformation(roomId); DisplayHunterStatus(hunter); // Draw a static room var roomProperties = GetRoomProperties(roomId); DrawRoom(roomProperties.CanGoNorth, roomProperties.CanGoSouth, roomProperties.CanGoWest, roomProperties.CanGoEast); // Allow hunter to move //TODO Refactor this? System.Console.WriteLine("Choose your destiny.."); var menuChoice = System.Console.ReadKey(true).Key; switch (menuChoice) { case System.ConsoleKey.UpArrow: { if (roomProperties.CanGoNorth) { System.Console.WriteLine("Going North!"); roomId = (int)roomProperties.NorthRoom; } else { System.Console.WriteLine("No Way! The treasure is important, come on!"); } continue; } case System.ConsoleKey.DownArrow: { if (roomProperties.CanGoSouth) { System.Console.WriteLine("Going South!"); roomId = (int)roomProperties.SouthRoom; } else { System.Console.WriteLine("No Way! The treasure is important, come on!"); } continue; } case System.ConsoleKey.LeftArrow: { if (roomProperties.CanGoWest) { System.Console.WriteLine("Going West!"); roomId = (int)roomProperties.WestRoom; } else { System.Console.WriteLine("No Way! The treasure is important, come on!"); } continue; } case System.ConsoleKey.RightArrow: { if (roomProperties.CanGoEast) { System.Console.WriteLine("Going East!"); roomId = (int)roomProperties.EastRoom; } else { System.Console.WriteLine("No Way! The treasure is important, come on!"); } continue; } default: { System.Console.WriteLine("Invalid direction. The treasure is important, come on!"); continue; } } } }