public Door(DStatus stat, INames opener, RNames leadsToRoom) { // Position = pos; Status = stat; CanBeOpenWith = opener; this.LeadsToRoom = leadsToRoom; }
public string Drop(INames item) { // need to check if the item is in my bag first // then I can do all the actions and messages var roomItems = LoadGame.rooms[CurRoom].RoomItems; // just to make the names shorter in the code.. Item itemInBag = new Item(); bool found = false; for (int i = 0; i < inventory.Count(); i++) { if (inventory[i].Name.ToUpper() == item.ToString()) { found = true; itemInBag = inventory[i]; break; } } if (found) { // need to move the item from inventory in the room itemInBag.BelongsTo = ItemPos.Room; var tmp1 = new Item(itemInBag); // Using the copy constructor roomItems.Add(tmp1); inventory.Remove(itemInBag); return($"You have just dropped [{tmp1.Name}] and now you have {inventory.Count()} objects in your rucksack"); } else { return($"I am sorry but you don't have {item.ToString()} in your rucksack"); } }
public Identities(IIdentityStore source, INames alias, ITypeFormatter formatter, IIdentifiers identifiers) { _source = source; _alias = alias; _formatter = formatter; _identifiers = identifiers; }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="metadata">The metadata specification used to create a <see cref="AllowedMembersExtension"/>.</param> /// <param name="defaultNames">The default names selector for element and attribute names.</param> /// <param name="defaultMemberOrder">The order selector to use when a <see cref="MemberInfo"/> is encountered and /// selected.</param> public DefaultExtensions(IMetadataSpecification metadata, INames defaultNames, IParameterizedSource <MemberInfo, int> defaultMemberOrder) { _metadata = metadata; _defaultNames = defaultNames; _defaultMemberOrder = defaultMemberOrder; }
public string Inspect(INames item) { // Here I need to check first if it is a door // or a item to be inspected. return($" return a message to the Game Handler"); }
// ReSharper disable once TooManyDependencies /// <summary> /// Initializes a new instance of the <see cref="T:ExtendedXmlSerializer.ExtensionModel.Content.Members.MemberPropertiesExtension"/> class. /// </summary> /// <param name="names">The names.</param> /// <param name="order">The order.</param> /// <param name="defaultNames">The default names.</param> /// <param name="defaultMemberOrder">The default member order.</param> public MemberPropertiesExtension(IDictionary <MemberInfo, string> names, IDictionary <MemberInfo, int> order, INames defaultNames, IParameterizedSource <MemberInfo, int> defaultMemberOrder) { _defaultNames = defaultNames; _defaultMemberOrder = defaultMemberOrder; Order = order; Names = names; }
public string Get(INames item) { var roomItems = LoadGame.rooms[CurRoom].roomItems; for (int i = 0; i < roomItems.Count(); i++) { // I search for the item in the list within the current room if (roomItems[i].Name.ToUpper() == item.ToString() && roomItems[i].Pickup) // item is enum! need conversion to string { // Do I have space in the bag? if (inventory.Count() < bagSize && inventory.Count() >= 0) { // Update the item location in Room object. I do not touch the object in the room! roomItems[i].BelongsTo = ItemPos.Inventory; // I need to test which of the following works ! // Both following ways are OK. tested. // Commented out tmp // If both Torch and Ivy are in the room... if (roomItems[i].Name.ToUpper() == "TORCH") { for (int j = 0; j < roomItems.Count; j++) { if (roomItems[j].Name.ToUpper() == "IVY") { roomItems[j].Description = "You stick your head out the window and find nothing more hidden in the ivy."; } } } // var tmp = new Item(roomItems[i].Name, roomItems[i].Description, roomItems[i].CombWith, roomItems[i].BelongsTo); var tmp1 = new Item(roomItems[i]); // Using the copy constructor inventory.Add(tmp1); // Can ADD the item from room to Player Inventory roomItems.Remove(roomItems[i]); // Now I can finally remove the Object from Room List return($"You have just collected [{tmp1.Name}] and now you have {inventory.Count()} objects of {bagSize} in your bag."); } else { return($"Sorry! Your bag is Full and you have {bagSize} objects."); } } else if (roomItems[i].Name.ToUpper() == item.ToString() && !roomItems[i].Pickup) // item exists but cannot be picked up { return($"Cannot pickup {item}."); } } // The User tries to GET an object which is NOT in the room if (item.ToString() == "DOOR") { return("The door is too heavy to pickup!"); } return($"The {item} is not in this room."); }
public string Get(INames item) { var roomItems = LoadGame.rooms[CurRoom].RoomItems; for (int i = 0; i < roomItems.Count(); i++) { // I search for the item in the list within the current room if (roomItems[i].Name.ToUpper() == item.ToString()) // item is enum! need conversion to string { // Do I have space in the bag? if (inventory.Count() < bagSize && inventory.Count() >= 0) { // Update the item location in Room object. I do not touch the object in the room! roomItems[i].BelongsTo = ItemPos.Inventory; // I need to test which of the following works ! // Both following ways are OK. tested. // Commented out tmp // var tmp = new Item(roomItems[i].Name, roomItems[i].Description, roomItems[i].CombWith, roomItems[i].BelongsTo); var tmp1 = new Item(roomItems[i]); // Using the copy constructor inventory.Add(tmp1); // Can ADD the item from room to Player Inventory roomItems.Remove(roomItems[i]); // Now I can finally remove the Object from Room List return($"You have just collected [{tmp1.Name}] and now you have {inventory.Count()} objects of {bagSize} in your bag"); } else { return($"Sorry! Your bag is Full and you have {bagSize} objects"); } } } // The User tries to GET an object which is NOT in the room return($"The {item} is not in this room. Please try again"); }
// arg[0] = Command // arg[1] = Direction or Item/Door // arg[2] = ON // arg[3] = Item public void InvokeAction(string[] arg) { switch (arg[0].ToUpper()) { case nameof(Action.GO): // Tested Ok // I need to retrieve the matching Enum value for arg[1] Dir newDir; if (arg[1].ToUpper() == "LEFT") { newDir = (Dir)Enum.Parse(typeof(Dir), "WEST"); } else if (arg[1].ToUpper() == "RIGHT") { newDir = (Dir)Enum.Parse(typeof(Dir), "EAST"); } else if (arg[1].ToUpper() == "FORWARD") { newDir = (Dir)Enum.Parse(typeof(Dir), "NORTH"); } else if (arg[1].ToUpper() == "BACK") { newDir = (Dir)Enum.Parse(typeof(Dir), "SOUTH"); } else { newDir = (Dir)Enum.Parse(typeof(Dir), arg[1].ToUpper()); } Console.WriteLine(player.Go(newDir)); break; case nameof(Action.GET): // TESTED Ok // I need to retrieve the matching Enum value for arg[1] INames getItem = (INames)Enum.Parse(typeof(INames), arg[1].ToUpper()); Console.Clear(); GFXText.PrintTextWithHighlights(player.Get(getItem), 1, 1, false); Console.Write("\n\n"); break; case nameof(Action.DROP): // Tested Ok // I need to retrieve the matching Enum value for arg[1] INames dropItem = (INames)Enum.Parse(typeof(INames), arg[1].ToUpper()); // The Drop methods will do all the checks and return the output messages Console.Clear(); GFXText.PrintTextWithHighlights(player.Drop(dropItem), 1, 1, false); Console.WriteLine("\n"); break; case nameof(Action.USE): // I need to retrieve the matching Enum value for arg[1] // USE with 1 more arg equals the player is trying to use an item by itself if (arg.Length == 2) { INames useItem1 = (INames)Enum.Parse(typeof(INames), arg[1].ToUpper()); Console.Clear(); player.Use(useItem1); } // USE with more args equals the player is trying to use an item with another item else { INames useItem1 = (INames)Enum.Parse(typeof(INames), arg[1].ToUpper()); INames onItem2 = (INames)Enum.Parse(typeof(INames), arg[3].ToUpper()); Console.WriteLine(player.Use(useItem1, onItem2)); } break; // case nameof(Action.ON): // I do not need this because it is part of the command USE...ON... // break; case nameof(Action.LOOK): Console.Clear(); if (arg.Length == 1) { player.Look(); } else { GFXText.PrintTextWithHighlights(player.Look(arg[1]), 1, 2, false); Console.Write("\n\n"); } break; // Removed Inspect() /*case nameof(Action.INSPECT): * * INames inspItem = (INames)Enum.Parse(typeof(INames).Name, arg[1].ToUpper()); * player.Inspect(inspItem); * * break;*/ case nameof(Action.SHOW): // Tested Ok Console.WriteLine(player.Show()); break; default: break; } }
public Identities(IIdentifiers identifiers, IIdentityStore source, INames names) : this(source, names, TypeNameFormatter, identifiers) { }
public string Use(INames item1, INames item2) { // Check if item1/2 is door also // DOOR OPENER // This code should be able to use any key named 'key' to unlock any door // Either make sure the player only can carry 1 key at a time, or change this/add more code to allow multiple simultaneously key usage if (item1 == INames.KEY && item2 == INames.DOOR) { Console.Clear(); for (int i = 0; i < LoadGame.rooms[CurRoom].exitDoors.Count(); i++) { if (LoadGame.rooms[CurRoom].exitDoors[i].CanBeOpenWith == INames.KEY && LoadGame.rooms[CurRoom].exitDoors[i].Status != DStatus.Open) { for (int inv = 0; inv < inventory.Count(); inv++) { if (inventory[inv].Name.ToUpper() == INames.KEY.ToString()) { LoadGame.rooms[CurRoom].exitDoors[i].Status = DStatus.Open; inventory.Remove(inventory[inv]); return("You opened the door."); } } return("You do not have the key."); } } return("There is no closed door."); } // END OF DOOR OPENER // USE matches on torch and gain a flaming torch if (item1 == INames.MATCHES && item2 == INames.TORCH) { foreach (var i in inventory) { if (i.Name.ToUpper() == INames.MATCHES.ToString()) { foreach (var j in inventory) { if (j.Name.ToUpper() == INames.TORCH.ToString()) { inventory.Remove(i); inventory.Remove(j); var flamingtorch = new Item("Flamingtorch", "A flaming torch. This should light up even the darkest of places.", INames.EMPTY, ItemPos.Room, true); inventory.Add(flamingtorch); Console.Clear(); GFXText.PrintTextWithHighlights("You use the matches on the torch and now have a [flamingtorch].", 2, 2, true); Console.Write("\n\n"); return(""); } } } } return("You don't have the required items."); } // END of Use matches on torch // Use flamingtorch on brazier to make cellar visible. if (item1 == INames.FLAMINGTORCH && item2 == INames.BRAZIER && CurRoom == RNames.Cellar) { // Check if Player have a flaming torch foreach (var k in inventory) { if (k.Name.ToUpper() == INames.FLAMINGTORCH.ToString()) { //inventory.Remove(k); //Change cellar room description unveil painting string cellardescription = "The cellar is now lit and you find that its covered with large kegs that are covered in moss. On top of some kegs a large [painting] appears."; LoadGame.rooms[CurRoom].Description = cellardescription; LoadGame.rooms[CurRoom].Visited = false; Console.Clear(); GFXText.PrintTextWithHighlights("You use the flaming torch and flames start to spark across the room.", 2, 2, true); return(""); } } return("You don't have the required item."); } // MEDALLION ON PANEL if (CurRoom == RNames.Entrance) { if (item1 == INames.MEDALLION && item2 == INames.PANEL) { foreach (var i in inventory) { if (i.Name.ToUpper() == INames.MEDALLION.ToString()) { LoadGame.rooms[RNames.Entrance].exitDoors[(int)Dir.SOUTH].Status = DStatus.Open; LoadGame.rooms[RNames.Entrance].Description = "You have entered what seems to be an old abandoned mansion. There is a [note] next to you on the cold marble floor. To the left there is a wooden door behind a bookshelf. Above you is a large [chandelier] covered in cobweb hanging from the ceiling. Behind you there's also a [panel], and now also an opening next to it."; inventory.Remove(i); Console.Clear(); GFXText.PrintTextWithHighlights("You insert the medallion into the panel, it seems like a perfect match. After a brief moment the wall next to it creaks open and a bright lights shines through...", 2, 2, true); Console.Write("\n\n"); return(""); } } } return("You don't have the required items."); } // END BLOCK MEDALLION ON PANEL return($"You don't have the required items."); }
public Item(string name, string description, INames combWith, ItemPos location, bool pickUp) : base(name, description) { this.CombWith = combWith; BelongsTo = location; this.Pickup = pickUp; }
public Item(string name, string description, INames combWith, bool pickUp) : base(name, description) { this.CombWith = combWith; this.Pickup = pickUp; }
public TypeFormatter(INames names) : base(names.Or(TypeNameFormatter.Default)) { }
public ValuesController(IHttpClientFactory clientFactory, INames names) { _clientFactory = clientFactory; _names = names; }
// Use() is overloaded // Use(arg) is currently used to let the user interact with objects (items) in the game // For example the first block lets the user "use" the chain and a key drops (spawns) in the room public void Use(INames item) { // Logic for using items in rooms var roomItems = LoadGame.rooms[CurRoom].roomItems; for (int i = 0; i < roomItems.Count(); i++) { if (roomItems[i].Name.ToUpper() == item.ToString() && !roomItems[i].IsUsed) { // BLOCK CHAIN if (roomItems[i].Name.ToUpper() == "CHAIN") { roomItems[i].IsUsed = true; var key = new Item("Key", "A rusty bronze key.", INames.EMPTY, ItemPos.Room, true); roomItems.Add(key); Console.Clear(); GFXText.PrintTextWithHighlights("A [key] falls down.", 2, 2, true); Console.Write("\n\n"); return; } // END OF BLOCK CHAIN // BLOCK REMAINS if (roomItems[i].Name.ToUpper() == "REMAINS") { roomItems[i].IsUsed = true; //var hand = new Item("Hand", "It smells really foul. Carved into the hand is a number: 42.", INames.EMPTY, ItemPos.Inventory, true); // If there's space in players inventory, add it there. Else add it to room inventory if (inventory.Count() < bagSize) { inventory.Add(new Item("Hand", "It smells really foul. Carved into the hand is a message: 42 is next to 21", INames.EMPTY, ItemPos.Inventory, true)); } else { roomItems.Add(new Item("Hand", "It smells really foul. Carved into the hand is a message: 42 is next to 21.", INames.EMPTY, ItemPos.Room, true)); } Console.Clear(); GFXText.PrintTextWithHighlights("Among the remains you find and pick up an [hand].", 2, 2, true); Console.Write("\n\n"); return; } // END OF BLOCK REMAINS // BLOCK PANTRY if (roomItems[i].Name.ToUpper() == "PANTRY") { roomItems[i].IsUsed = true; //var bread = new Item("Bread", "A fresh loaf of bread. Looks and smells really good.", INames.EMPTY, ItemPos.Inventory, true); // I collect the bread if I have space in the inventory, otherwise I leave it in the room. if (inventory.Count() < bagSize) { // roomItems[i].IsUsed = true; inventory.Add(new Item("Bread", "A fresh loaf of bread. Looks and smells really good.", INames.EMPTY, ItemPos.Inventory, true)); Console.Clear(); GFXText.PrintTextWithHighlights("You open the pantry and find a loaf of [bread] which you pick up.", 2, 2, true); } else { if (roomItems.FirstOrDefault(c => c.Name.ToUpper() == "BREAD") == null) // the bread has not yet been placed in the room { roomItems.Add(new Item("Bread", "A fresh loaf of bread. Looks and smells really good.", INames.EMPTY, ItemPos.Room, true)); } Console.Clear(); GFXText.PrintTextWithHighlights("You open the pantry and find a loaf of [bread] which you might pick up.", 2, 2, true); } Console.Write("\n\n"); return; } // END OF BLOCK PANTRY // BLOCK THRONE if (roomItems[i].Name.ToUpper() == "THRONE") { Console.Clear(); GFXText.PrintTxt(-1, 5, Globals.TextTrail, Globals.TextDelay, "For some reason you decide to drink the vile contents of the toilet...", true, false); System.Threading.Thread.Sleep(Globals.SleepTime); GFXText.PrintTxt(-1, 10, Globals.TextTrail, Globals.TextDelay, "You die...", false, false); Console.ReadKey(); Environment.Exit(0); } // END OF BLOCK THRONE // BLOCK IVY if (roomItems[i].Name.ToUpper() == "IVY") { Console.Clear(); GFXText.PrintTxt(-1, 5, Globals.TextTrail, Globals.TextDelay, "You touch the poison ivy and suddenly become paralyzed...", true, false); System.Threading.Thread.Sleep(Globals.SleepTime); GFXText.PrintTxt(-1, 10, Globals.TextTrail, Globals.TextDelay, "You die...", false, false); Console.ReadKey(); Environment.Exit(0); } // END OF BLOCK IVY // Add more blocks of code here for more item uses } else if (roomItems[i].Name.ToUpper() == item.ToString() && roomItems[i].IsUsed) { Console.WriteLine("\n{0} already used...", item); return; } } // Logic for using items in inventory for (int i = 0; i < inventory.Count; i++) { if (inventory[i].Name.ToUpper() == item.ToString().ToUpper()) { // BLOCK HAND if (item.ToString().ToUpper() == "HAND") { Console.Clear(); GFXText.PrintTxt(-1, 5, Globals.TextTrail, Globals.TextDelay, "For some reason you decide to consume the half-rotten hand...", true, false); System.Threading.Thread.Sleep(Globals.SleepTime); GFXText.PrintTxt(-1, 10, Globals.TextTrail, Globals.TextDelay, "You die...", false, false); Console.ReadKey(); Environment.Exit(0); } // END OF BLOCK HAND // BLOCK BREAD if (item.ToString().ToUpper() == "BREAD") { Console.Clear(); GFXText.PrintTextWithHighlights("The bread tastes delicious. Argh, but what is this? Inside you find a [goldpiece]!", Globals.RoomDescriptionXPos, Globals.RoomDescriptionYPos, true); var goldpiece = new Item("Goldpiece", "A golden piece of something bigger. What can it be?", INames.EMPTY, ItemPos.Inventory, true); inventory.Remove(inventory[i]); // REMOVE OLD ITEM inventory.Add(goldpiece); // ADD NEW ITEM return; } // END OF BLOCK BREAD // Player tries to combine the pieces. If the player got all pieces a medallion is created and the game is completed. if (item == INames.BRONZEPIECE || item == INames.SILVERPIECE || item == INames.GOLDPIECE) { // if (inventory.Contains(new Item("Bronzepiece", "", false)) && inventory.Contains(new Item("Silverpiece", "", false)) && inventory.Contains(new Item("Goldpiece", "", false))) if ((inventory.FirstOrDefault(c => c.Name.ToUpper() == "BRONZEPIECE")) != null && (inventory.FirstOrDefault(c => c.Name.ToUpper() == "SILVERPIECE")) != null && (inventory.FirstOrDefault(c => c.Name.ToUpper() == "GOLDPIECE")) != null) { Item tmpItem = inventory.FirstOrDefault(x => x.Name == "Bronzepiece"); if (tmpItem != null) { inventory.Remove(tmpItem); } tmpItem = inventory.FirstOrDefault(x => x.Name == "Silverpiece"); if (tmpItem != null) { inventory.Remove(tmpItem); } tmpItem = inventory.FirstOrDefault(x => x.Name == "Goldpiece"); if (tmpItem != null) { inventory.Remove(tmpItem); } tmpItem = null; var medallion = new Item("Medallion", "A magnificent medallion. Looks ancient and infused with magic.", INames.EMPTY, ItemPos.Room, true); inventory.Add(medallion); Console.Clear(); GFXText.PrintTextWithHighlights("You combine the pieces into a magnificent medallion.", 2, 2, true); Console.Write("\n\n"); return; } else { Console.Clear(); GFXText.PrintTextWithHighlights("You are missing a piece.", 2, 2, true); return; } } } } var breadInRoom = LoadGame.rooms[CurRoom].roomItems.FirstOrDefault(c => c.Name.ToUpper() == "BREAD"); if (breadInRoom != null) // I have exposed the bread, but I could not USE it because I had no space in the inventory { Console.Clear(); GFXText.PrintTextWithHighlights("Try to pickup [Bread] before using it.\n\n", 2, 2, true); } else { Console.WriteLine("Cannot use {0}", item); } // End of logic for using items in inventory }
// Use() is overloaded //public void Use(INames item, Door door) //{ //} public string Use(INames item1, INames item2) { // Check if item1/2 is door also return($" return a message to the Game Handler"); }
} // A door show a description when INSPECTED // Constructor // the values in the param list must be constrained to the enum above public Door(DStatus stat, INames opener) { // Position = pos; Status = stat; CanBeOpenWith = opener; }
public Members(INames names, IMemberOrder order) { _names = names; _order = order; }
/// <summary> /// Initializes a new instance of the <see cref="JHopkinsRowProcessor"/> class. /// </summary> /// <param name="namesService">Names service to translate name and abbreviations.</param> /// <param name="statsProvider">Statistical provider to generate key.</param> /// <param name="logger">A <see cref="ILogger"/> instance.</param> public JHopkinsRowProcessor(INames namesService, IStatsProvider statsProvider, ILogger logger) : base(statsProvider, logger) { _namesService = namesService; }
/// <summary> /// Initializes a new instance of the <see cref="T:ExtendedXmlSerializer.ExtensionModel.Content.Members.MemberPropertiesExtension"/> class. /// </summary> /// <param name="defaultNames">The default names.</param> /// <param name="defaultMemberOrder">The default member order.</param> public MemberPropertiesExtension(INames defaultNames, IParameterizedSource <MemberInfo, int> defaultMemberOrder) : this(new Dictionary <MemberInfo, string>(), new Dictionary <MemberInfo, int>(), defaultNames, defaultMemberOrder) { }