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); }
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(); }
public void StartGame() { Setup(); CurrentRoom.GetDescription(); while (playing) { GetUserInput(); } }
public void DontUseItem(string itemName) { var item = CurrentPlayer.Inventory.Find(i => i.Name == itemName); if (item == null) { CurrentRoom.GetDescription(); // item.ItemUsed = false; AlterRoomItemNotUsed(); } }
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..."); } }
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."); }
public void Reset() { Setup(); CurrentRoom.GetDescription(); }
// method to show current room description //.... public static void DisplayCurrentRoomDescription() { IO.OutputNewLine(CurrentRoom.GetDescription()); }
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; } }
public void Look() { CurrentRoom.GetDescription(); }