Ejemplo n.º 1
0
        private void NewGameState(ConsoleKey key)
        {
            _input.clearInput();
            var mazeSize = _input.ToNumber(key);

            if (mazeSize == null)
            {
                _render.Message(MessageTypes.InvalidInput);
            }
            else if (mazeSize <= 1)
            {
                _render.Message(MessageTypes.InvalidInput);
            }
            else
            {
                //---------Build the maze and get the entrance room -----------
                _play          = new Play();
                _play.MazeSize = mazeSize.Value;
                _mazeIntegration.BuildMaze(_play.MazeSize);
                _play.CurrentRoom = _mazeIntegration.GetEntranceRoom();
                string desc = _mazeIntegration.GetDescription(_play.CurrentRoom);

                //---------Render the maze and the moves -----------
                _play.VisitedRooms.Add(new Room()
                {
                    Description = desc,
                    HasTrap     = false,
                    HasTreasure = false,
                    RoomId      = _play.CurrentRoom
                });
                _render.EntranceRoom(_play.CurrentRoom);
                _render.Message(MessageTypes.Instruction);
                _render.Moves(_play);
                _currentState = State.InProgress;
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
 public void GetRoomInformation(int roomId)
 {
     try
     {
         var roomDescription = _mazeIntegration.GetDescription(roomId);
         Console.WriteLine("Room is {0}", roomDescription);
         Console.WriteLine();
         Console.WriteLine();
     }
     catch (Exception e)
     {
         Console.WriteLine("Maze metadata is wrong, room description wasn't found!");
         Console.WriteLine(e.StackTrace.ToString());
         //TODO log e using NLog or whatever
         Console.ReadLine();
         Environment.Exit(0);
     }
 }