Ejemplo n.º 1
0
        public void Open(string value)
        {
            foreach (var exit in _currentRoom.Exit)
            {
                if (!InputParse.CompareStrings(value, exit.ExitName))
                {
                    continue;
                }
                if (!exit.Locked && exit.EndPoint)
                {
                    _player.HasWon();
                    return;
                }
                if (!exit.Locked)
                {
                    _currentRoom = exit.LeadsTo;
                    _currentRoom?.ShowRoomDescription();
                    return;
                }
                exit.LockedDescription();
                return;
            }

            Console.WriteLine("I can't do that.");
        }
Ejemplo n.º 2
0
 public void Drop(string value)
 {
     foreach (var item in _player.PlayerInventory)
     {
         if (!InputParse.CompareStrings(value, item.Name))
         {
             continue;
         }
         _currentRoom.AddRoomItem(item);
         _player.DropItem(item);
         return;
     }
 }
Ejemplo n.º 3
0
 private void Read(string value)
 {
     foreach (var item in _player.PlayerInventory)
     {
         if (!InputParse.CompareStrings(value, item.Name))
         {
             continue;
         }
         item.ShowItemDescription();
         return;
     }
     Console.WriteLine("I can't do that.");
 }
Ejemplo n.º 4
0
        private void Move(string value)
        {
            foreach (var item in _currentRoom.RoomInventory)
            {
                if (!InputParse.CompareStrings(value, item.Name))
                {
                    continue;
                }
                item.Use(_player, _currentRoom);
                _currentRoom.RemoveRoomItem(item);
                return;
            }

            Console.WriteLine("I can't do that.");
        }
Ejemplo n.º 5
0
 public void Go(string value)
 {
     foreach (var exit in _currentRoom.Exit)
     {
         if (!InputParse.CompareStrings(value, exit.ExitName))
         {
             continue;
         }
         if (exit.Unlock(_player))
         {
             _currentRoom = exit.LeadsTo;
             _currentRoom.ShowRoomDescription();
             return;
         }
     }
     Console.WriteLine("I can't go that way.");
 }
Ejemplo n.º 6
0
 public void Take(string value)
 {
     foreach (var item in _currentRoom.RoomInventory)
     {
         if (!InputParse.CompareStrings(value, item.Name))
         {
             continue;
         }
         if (item.TakeAble)
         {
             _player.PickUpItem(item);
             _currentRoom.RemoveRoomItem(item);
             return;
         }
         else
         {
             Console.WriteLine("I can't take that.");
             return;
         }
     }
     Console.WriteLine("I can't take that.");
 }
Ejemplo n.º 7
0
        private void Examine(string value)
        {
            // Examine Room
            if (InputParse.CompareStrings(value, _currentRoom.Title))
            {
                _currentRoom.ExamineRoom();
                return;
            }

            // Examine Item in Room
            foreach (var item in _currentRoom.RoomInventory)
            {
                if (InputParse.CompareStrings(value, item.Name))
                {
                    Console.WriteLine(item.Examine);
                }
            }

            // Examine Item in PlayerInventory
            foreach (var item in _player.PlayerInventory)
            {
                if (!InputParse.CompareStrings(value, item.Name))
                {
                    continue;
                }
                item.ExamineItem();
                return;
            }

            // Examine Room Exits
            foreach (var exit in _currentRoom.Exit)
            {
                if (!InputParse.CompareStrings(value, exit.ExitName))
                {
                    continue;
                }
                exit.ExamineExit();
            }
        }
Ejemplo n.º 8
0
        public void Use(string value)
        {
            // Kolla om final door.
            var roomExit = _currentRoom.GetExitFromRoom("codelock");

            if (roomExit != null)
            {
                roomExit.Unlock(_player, value);
                return;
            }

            foreach (var exit in _currentRoom.Exit)
            {
                if (!InputParse.CompareStrings(value, exit.ExitName))
                {
                    continue;
                }
                foreach (var item in _player.PlayerInventory)
                {
                    if (!InputParse.CompareStrings(value, item.Name))
                    {
                        continue;
                    }
                    if (exit.ExitId == item.ItemId && InputParse.CompareStrings(value, exit.ExitName))
                    {
                        _player.PlayerInventory.Remove(item);
                        exit.Unlock();
                        return;
                    }
                }
            }


            // Kolla om användaren tar use på ett item i rummet
            var playerItem = _player.GetItemFromInventory(value);

            if (playerItem == null)
            {
                Console.WriteLine("I can't do that.");
                return;
            }
            foreach (var item in _currentRoom.RoomInventory)
            {
                if (!InputParse.CompareStrings(value, item.Name))
                {
                    continue;
                }
                playerItem.Use(_player, _currentRoom, playerItem);
                return;
            }

            // Kolla om användaren  tar use på ett item i sitt inventory
            var playerFirstItem = _player.GetItemFromInventory(value);

            if (playerFirstItem == null)
            {
                return;
            }
            playerFirstItem = playerFirstItem.Use(_player, playerFirstItem, value);
            if (playerFirstItem == null)
            {
                Console.WriteLine("I can't do that.");
                return;
            }
            _player.PlayerInventory.Add(playerFirstItem);
        }