public static List<Item> GetCommandItems(string[] words, Room currentRoom, Inventory playerInventory) { List<string> tryWordCombinations = allWordCombinations(words); tryWordCombinations.Sort( delegate(string a, string b) { //return a.Length.CompareTo(b.Length); // longest first return b.Length.CompareTo(a.Length); } ); List<Item> matches = new List<Item>(); foreach (string phrase in tryWordCombinations) { //Console.WriteLine("trying combination: {0}", phrase); Item foundItem = playerInventory.GetItem(phrase); if (foundItem != null && !matches.Contains(foundItem)) { matches.Add(foundItem); } if (currentRoom != null) { foundItem = currentRoom.GetItem(phrase); if (foundItem != null && !matches.Contains(foundItem)) { matches.Add(foundItem); } } } return matches; }
public LockedDoor(Room whereAmI, string doorDirection, string inventoryNeededToLockUnlock) : base(null) { this.whereAmI = whereAmI; this.doorDirection = doorDirection; this.inventoryNeededToLockUnLock = inventoryNeededToLockUnlock; }
private void secondFloor(out Room hallwayWest, out Room hallwayEast) { Room myroom = new MyHotelRoom(); Room myBathroom = new MyHotelRoomBathroom(); Room myCloset = new Closet(); this.StartingPoint = myroom; // connect room to bathroom myroom.ExitsHere.AddExit("e", "door", "leading to a small bathroom {0}", myBathroom); myBathroom.ExitsHere.AddExit("w", "door", "leading back into your hotel room {0}", myroom); // connect room to closet myroom.ExitsHere.AddExit("ne", "doorway", "leading to a small closet {0}", myCloset); myCloset.ExitsHere.AddExit("sw", "doorway", "leading back into your hotel room {0}", myroom); Room hallwayMid = new HallwayFloorTwoMid(); // connect room to hallway myroom.ExitsHere.AddExit("n", "door", hallwayMid); hallwayMid.ExitsHere.AddExit("s", "door", myroom); hallwayWest = new HallwayFloorTwoWest(); // connect mid <=> west hallways hallwayWest.ExitsHere.AddExit("e", null, "From here the hallway continues east.", hallwayMid); hallwayMid.ExitsHere.AddExit("w", null, "From here the hallway continues east and west.", hallwayWest); hallwayEast = new HallwayFloorTwoEast(); // connect mid <=> east hallways hallwayMid.ExitsHere.AddExit("e", null, "From here the hallway continues east and west.", hallwayEast); hallwayEast.ExitsHere.AddExit("w", null, "From here the hallway continues west.", hallwayMid); }
private void firstFloor(out Room hallwayWest, out Room hallwayEast) { Room hallwayMid = new HallwayFloorOneMid(); hallwayWest = new HallwayFloorOneWest(); // connect mid <=> west hallways hallwayWest.ExitsHere.AddExit("e", null, "From here the hallway continues east.", hallwayMid); hallwayMid.ExitsHere.AddExit("w", null, "From here the hallway continues east and west.", hallwayWest); hallwayEast = new HallwayFloorOneEast(); // connect mid <=> east hallways hallwayMid.ExitsHere.AddExit("e", null, "From here the hallway continues east and west.", hallwayEast); hallwayEast.ExitsHere.AddExit("w", null, "From here the hallway continues west.", hallwayMid); Room janitorsCloset = new JanitorCloset(); // connect west hallway <=> janitor's closet hallwayWest.ExitsHere.AddExit("ne", "door", "There is a door to the {0} leading to a janitor's closet", janitorsCloset); janitorsCloset.ExitsHere.AddExit("sw", "door", "There is a door to the {0} leading back out into the hallway.", hallwayWest); }
public void AddExit(string dir, string method, string verbose, Room dest) { // create structures if they don't exist if (this.exits == null) { this.exits = new Dictionary<string, Room>(); } if (this.exitMethod == null) { this.exitMethod = new Dictionary<string, string>(); } // associate exit, direction and method this.exits.Add(dir, dest); this.exitMethod.Add(dir, method); // add grouping by method for pretty English if (verbose != null) { if (this.exitVerbose == null) { this.exitVerbose = new Dictionary<string, string>(); } this.exitVerbose.Add(dir, verbose); } else { if (this.exitGroups == null) { this.exitGroups = new Dictionary<string, List<string>>(); } // similar exits List<string> similarExits; if (this.exitGroups.TryGetValue(method, out similarExits)) { similarExits.Add(dir); } else { similarExits = new List<string>() { dir }; this.exitGroups.Add(method, similarExits); } } }
public void AddExit(string dir, string method, Room dest) { this.AddExit(dir, method, null, dest); }
public void AddExit(string dir, Room dest) { this.AddExit(dir, "exit", null, dest); }
public MyRoomDoor(Room whereAmI, string doorDirection) : base(whereAmI, doorDirection, needsToLockUnlock) { }
private void connectSections(Room fl1westhall, Room fl1easthall, Room fl2westhall, Room fl2easthall) { // connect staircase fl1easthall.ExitsHere.AddExit("u", "staircase", fl2easthall); fl2easthall.ExitsHere.AddExit("d", "staircase", fl1easthall); }
public static List<Item> GetCommandItems(string cmd, Room currentRoom, Inventory playerInventory) { return GetCommandItems(splitCommand(cmd), currentRoom, playerInventory); }
private static void roomDemo() { /* ROOM TEST */ Inventory inv = new Inventory(false); Item f; f = new Item("flask", "blue"); inv.AddItem(f); f = new Item("eel", "electric"); inv.AddItem(f); f = new Item("sword"); inv.AddItem(f); Inventory invb = new Inventory(false); f = new Item("broom"); invb.AddItem(f); f = new Item("bucket"); invb.AddItem(f); Room foo = new Room("Test Chamber", "This is a small chamber. In the dim light you can see the walls "+ "expand and contract as if they were unstable. If you strain your "+ "ears you can just barely hear someone typing furiously on a keyboard.", inv ); Closet bar = new Closet("Test Closet", "It is too dark to see.", "You are standing in a small broom closet.", invb ); foo.Exits.AddExit("n", "doorway", bar); foo.Exits.AddExit("u", "ladder", foo); foo.Exits.AddExit("d", "ladder", foo); foo.Exits.AddExit("s", foo); Console.WriteLine("Entering room..."); Console.WriteLine(foo.EnterRoom()); Console.WriteLine("Entering room again..."); Console.WriteLine(foo.EnterRoom()); Console.WriteLine("Entering closet..."); Console.WriteLine(bar.EnterRoom()); Console.WriteLine("Let there be light..."); Console.WriteLine(bar.TurnOnLight()); Console.WriteLine(bar.Look()); }
private static void verboseRoomDemo() { Room foo = new Room("Test Chamber", "This is a small chamber. In the dim light you can see the walls "+ "expand and contract as if they were unstable. If you strain your "+ "ears you can just barely hear someone typing furiously on a keyboard." ); foo.ExitsHere.AddExit("ne", "doorway", foo); foo.ExitsHere.AddExit("nw", "doorway", foo); foo.ExitsHere.AddExit("se", "doorway", "leading to a small closet", foo); Console.WriteLine(foo.Look(true)); }