public Room(string roomName, string roomDesc, Inventory itemsHere, Exits exits) { this.roomName = roomName; this.roomDesc = roomDesc; this.itemsHere = itemsHere; this.ExitsHere = exits; }
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 Closet() : base("Closet", roomDesc_dark) { this.lightswitch = new LightSwitch(this); this.itemsHere_light = new Inventory( new List<Item>() { new Bucket(3), this.lightswitch, this.carpet, } ); this.itemsHere_dark = new Inventory( new List<Item>() { this.lightswitch, } ); this.DeIlluminate(); }
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 movementDemo() { Inventory plr = new Inventory(true, new List<Item>() { new Bucket(3), new Bucket(5), }); RoomLayout rms = new RoomLayout(); string[] cmds = new string[] { //"n", //"e", //"go n", //"look", //"search", //"pick", //"take", //"steal", "take small bucket", }; Console.WriteLine(rms.StartingPoint.ToString()); List<Item> it; string[] ve; foreach (string c in cmds) { ve = Commands.GetCommandVerb(c); it = Commands.GetCommandItems(c,rms.StartingPoint, plr); Console.WriteLine("in: {0}", c); if (ve != null) { Console.WriteLine(" verb: {0} ({1})", ve[0], ve[1]); } else { Console.WriteLine(" (unrecognized verb)"); } if (it.Count > 0) { Console.WriteLine(" item: {0}", it[0]); } else { Console.WriteLine(" (unrecognized item)"); } } }
private static void inventoryDemo() { /* INVENTORY TEST */ Inventory inv = new Inventory(true); Item s = new Item("sword", "shiny"); s.AutoGenSynonyms(); inv.AddItem(s); Bucket b = new Bucket(3); inv.AddItem(b); Console.WriteLine(inv); }
public Room(string roomName, string roomDesc, Inventory itemsHere) : this(roomName, roomDesc, itemsHere, new Exits()) { // Console.Error.WriteLine("FIXME: Room:Room(): Unexitable room!"); }
public Room(string roomName, Inventory itemsHere) : this(roomName, null, itemsHere) { Console.Error.WriteLine("FIXME: Room:Room(): Undescribed room!"); }
public Room(Inventory itemsHere) : this("Unknown", itemsHere) { Console.Error.WriteLine("FIXME: Room:Room(): Unnamed room!"); }