public Game() { _parser = new Parser(); _help = new Help(_parser); _player = new Player("John Doe"); World.Instance.Create(); _player.EnterRoom(World.Instance.Rooms .Where(r => r.Start) .Single()); }
private void _goRoom(Command cmd) { if (!cmd.HasSecondWord()) { // if there is no second word, we don't know where to go.. Console.WriteLine("Go where? I wander.. in circles... ..."); return; } // this should be checked if it is an unrecognized param or not. string secondWord = cmd.GetSecondWord(); Directions direction = _getDirectionFromString(secondWord); if (direction == Directions.NONE) { Console.WriteLine("Only the directions (N/E/S/W/U/D) exists. Try again."); return; } // try to leave current room. Room nextRoom = _player.GetCurrentRoom().GetExit(direction)?.Room; Exit nextExit = _player.GetCurrentRoom().GetExit(direction); if (nextExit.Locked) { // add auto unlock door here if player has key Console.WriteLine($"Door to the {nextRoom.Name} is locked. You need a key to open it."); return; } // if (_player.CanMoveInDirection(direction)) // this is better... if (nextRoom == null) { Console.WriteLine($"{_player.GetCurrentRoom().ShortDescription}"); Console.WriteLine("There is no door!"); } else { // int currentHealth = _player.Health; // _player.DoDamage(1); _player.EnterRoom(nextRoom); Console.WriteLine(_player.Room.LongDescription); // Console.WriteLine("Health: " + _player.Health); // should be in player long description Console.WriteLine(_player.LongDescription); } }