Example #1
0
        public void UseItem(string itemName)
        {
            var item = CurrentPlayer.Inventory.Find(i => i.Name == itemName);

            item = item == null?CurrentRoom.UseItem(itemName) : item;

            if (item == null)
            {
                System.Console.WriteLine("sorry there is no " + itemName);
                return;
            }
            if (item.ItemUsed)
            {
                System.Console.WriteLine($@"
          Sorry, this item, the {item.Name},  has already been used...
        ");
            }
            else
            {
                System.Console.WriteLine($@"
          You decide to use the item {item.Name}.
          Action:  
        ");
                CurrentPlayer.Inventory.Add(item);
                CurrentRoom.GetDescription();
                item.ItemUsed = false;
            }
            AlterRoom(item);
        }
Example #2
0
        public void DrawHelp()
        {
            System.Console.WriteLine($@"
                    /~~~~~~~~~~~~~~~~~~~~~/
                   / Surviving Vanuatu!  /
                  /~~~~~~~~~~~~~~~~~~~~~/ 

    Commands available and their options:
    - 'go' <direction>` Moves the player from room to room, e.g. Go Down, type 'gd'
          Directions: 'north', 'south', 'east', 'west', 'down', 'up'
				Available directions are shown in game play.
				
    -  'use <itemName>' Uses an item in a room or from your inventory
		    Possible items: 'egg', 'red_rag', 'doughnut'
    -  'drop <itemName>' Don't use or ignore the item in the room.
		    Example: 'use egg' 
	      Generally use items as they are presented.
    -  'quit' ...  Quits the Game
    -  'help' -  List of commands. Redraws this screen
    -  'look' -  Re-prints the room description
    -  'inventory' prints a list of the items in the players inventory
 
      When the player enters a room they get the room description
  ");
            CurrentRoom.GetDescription();
        }
Example #3
0
        public void StartGame()
        {
            Setup();
            CurrentRoom.GetDescription();

            while (playing)
            {
                GetUserInput();
            }
        }
Example #4
0
        public void DontUseItem(string itemName)
        {
            var item = CurrentPlayer.Inventory.Find(i => i.Name == itemName);

            if (item == null)
            {
                CurrentRoom.GetDescription();
                // item.ItemUsed = false;
                AlterRoomItemNotUsed();
            }
        }
Example #5
0
 public void Go(string direction)
 {
     if (CurrentRoom.directions.ContainsKey(direction))
     {
         CurrentRoom = CurrentRoom.directions[direction];
         CurrentRoom.GetDescription();
     }
     else
     {
         System.Console.WriteLine("you cant go that way...");
     }
 }
Example #6
0
 public void Go(string direction)
 {
     if (CurrentRoom.Locked == true)
     {
         System.Console.WriteLine("The exit is locked. I'd recommend you figure that out.");
         return;
     }
     if (CurrentRoom.Exits.ContainsKey(direction))
     {
         CurrentRoom = CurrentRoom.Exits[direction];
         CurrentRoom.GetDescription();
         return;
     }
     System.Console.WriteLine("It appears you tried going that way, but then had a radical moment of disphoria. You blink and you're in the exact position you were at before you tried going the apparently wrong way.");
 }
Example #7
0
 public void Reset()
 {
     Setup();
     CurrentRoom.GetDescription();
 }
Example #8
0
 // method to show current room description
 //....
 public static void DisplayCurrentRoomDescription()
 {
     IO.OutputNewLine(CurrentRoom.GetDescription());
 }
Example #9
0
        public void GetUserInput()
        {
            CurrentRoom.GetDescription();
            System.Console.WriteLine("What will you do?");
            string input = Console.ReadLine();

            input = input.ToLower();
            string[] inputArr = input.Split(" ");
            switch (inputArr[0])
            {
            case "quit":
                playing = false;
                break;

            case "go":
                if (inputArr[1] != "north" && inputArr[1] != "south" && inputArr[1] != "west" && inputArr[1] != "east")
                {
                    System.Console.WriteLine("I don't know what kind of compass you have, but that isn't a direction...");
                    break;
                }
                if (CurrentRoom.Name == "Room 3" && room3locked == true && inputArr[1] == "east")
                {
                    System.Console.WriteLine("You cannot proceed while the door is locked.");
                    break;
                }
                if (CurrentRoom.Exits.Count == 0)
                {
                    Look();
                    Quit();
                }
                Go(inputArr[1]);
                if (CurrentRoom.Name == "Room 4")
                {
                    CurrentRoom.GetDescription();
                    Quit();
                }
                else if (CurrentRoom.Name == "Bottomless Pit")
                {
                    CurrentRoom.GetDescription();
                    Quit();
                }
                break;

            case "take":
                TakeItem(inputArr[1]);
                if (CurrentRoom.Name == "Room 2")
                {
                    CurrentRoom.Description = "You are in a dimly lit room with rooms to your east and west.";
                }
                break;

            case "inventory":
                Inventory();
                break;

            case "help":
                Help();
                break;

            case "reset":
                Reset();
                break;

            case "use":
                if (CurrentRoom.Name == "Room 3" && inputArr[1] == "key")
                {
                    UseItem(inputArr[1]);
                    room3locked = false;
                    System.Console.WriteLine("You have unlocked the door! You may now proceed east.");
                    CurrentRoom.Description = "To your east is an unlocked door.";
                    System.Console.WriteLine("");
                }
                else if (inputArr[1] == "key")
                {
                    System.Console.WriteLine("Now is not the time to use that!");
                }
                break;

            case "look":
                break;

            default:
                System.Console.WriteLine("Maybe you should type help...");
                System.Console.WriteLine("");
                break;
            }
        }
Example #10
0
 public void Look()
 {
     CurrentRoom.GetDescription();
 }