/// <summary> /// GetRoomInfo is getting all the room info and making the changes according to the room type ///- get all room information /// - add steps +1 /// - check whether Treasure or Trap and take the actions for HP. /// - add to visited rooms /// - render the new maze and moves /// </summary> /// <param name="roomId"></param> private void GetRoomInfo(int roomId) { _play.Steps = _play.Steps + 1; bool hasTrap = false; bool hasTreasure = false; _play.CurrentRoomDescription = _mazeIntegration.GetDescription(roomId); if (_mazeIntegration.CausesInjury(roomId)) { hasTrap = true; _play.HP = _play.HP - 1; if (_play.HP <= 0) { GameOverState(); return; } } if (_mazeIntegration.HasTreasure(roomId)) { hasTreasure = true; CongratulationsState(); return; } AddToVisitedRooms(roomId, _play.CurrentRoomDescription, hasTrap, hasTreasure); _render.Moves(_play); }
public void CheckCurrentRoom() { Console.WriteLine(Constants.RoomConstants.CheckForTreasure); Console.WriteLine(_mazeIntegration.GetDescription(_loadPlayer.GetPlayerInstance().CurrentRoom.Id)); if (_mazeIntegration.CausesInjury(_loadPlayer.GetPlayerInstance().CurrentRoom.Id)) { Console.WriteLine(Constants.RoomConstants.TrapRoomEvent); } if (_mazeIntegration.HasTreasure(_loadPlayer.GetPlayerInstance().CurrentRoom.Id)) { Console.WriteLine($"{Constants.RoomConstants.TreasureRoomEvent} {_loadPlayer.GetPlayerInstance().StepsMade}"); _loadPlayer.GetPlayerInstance().FoundTreasure = true; } }
public Maze.MazeProperties EmulateMaze(Player player, int roomId) { char[,] MazeVisited = new char[_mazeLayout.Size, _mazeLayout.Size]; while (true) { Console.Clear(); // Check if treasure found if (_mazeIntegration.HasTreasure(roomId)) { FinnishWithParty(player); return(Maze.MazeProperties.FoundTreasure); } // Check if room has a trap if (_mazeIntegration.CausesInjury(roomId)) { if (player.HealthPoint <= 1) { Console.Clear(); Console.WriteLine("Good luck next time!" + player.Name); Console.WriteLine(); return(Maze.MazeProperties.PlayerHasDied); } Console.WriteLine("You have been injured.."); Console.WriteLine("You suffered a loss of 1 HP, you now have " + player.HealthPoint + " HP left"); player.HealthPoint--; } // Display game information GetRoomInformation(roomId); GetPlayerInformation(player); // Draw a static room var roomProperties = GetRoomProperties(roomId); DrawRoom(_mazeLayout.Size, roomId, MazeVisited); // Allow hunter to move //TODO Refactor this? Console.WriteLine("Choose your destiny... Use keys (N, S, W, E) Exit: (Esc)"); var menuChoice = Console.ReadKey(true).Key; switch (menuChoice) { case ConsoleKey.N: if (roomProperties.GoNorth) { player.StepsCount++; Console.WriteLine("Going North!"); roomId = (int)roomProperties.NorthRoom; } else { Console.WriteLine("You hit the wall"); } continue; case ConsoleKey.S: if (roomProperties.GoSouth) { player.StepsCount++; Console.WriteLine("Going South!"); roomId = (int)roomProperties.SouthRoom; } else { Console.WriteLine("You hit the wall"); } continue; case ConsoleKey.W: if (roomProperties.GoWest) { player.StepsCount++; Console.WriteLine("Going West!"); roomId = (int)roomProperties.WestRoom; } else { Console.WriteLine("You hit the wall"); } continue; case ConsoleKey.E: if (roomProperties.GoEast) { Console.WriteLine("Going East!"); player.StepsCount++; roomId = (int)roomProperties.EastRoom; } else { Console.WriteLine("You hit the wall"); } continue; case ConsoleKey.Escape: Environment.Exit(0); break; default: // Console.WriteLine("Invalid direction. The treasure is important, come on!"); continue; } } }