Hello. My issue is that the if statement with the contains is not responding. It simply goes to the else statement. Is there a way to fix this code or a different way to do this? Thank you in advance.
using System.Linq;
*I do have this using option. Is this the reason that this way is of finding an item in the Array is not working?
#region class rooms
class Room
{
public string Title;
public string Description;
public string map_location;
public Room Close;
public Room Open;
public Room Warn;
public Room Dwarn;
public Room Swarn;
public Room Awarn;
public Items[] roomitems = new Items[10000];
public Challenge RoomChallange;
public Challenge RoomChallange2;
public Challenge RoomChallange3;
public Room(string title, string description, string maplocation)
{
Title = title;
Description = description;
map_location = maplocation;
}
}
*I placed the array in here. I have seen other people with examples of Arrays have put the Array in the Main(string[] args). I tried putting it in the Main(string[] args) but that did nothing to help the situation. This next part is in the Main(string[] args)
Items Orcics_200 = new Items("Orcics_200", "A pile of two hundred Orcics.", 0, .2, 0, 200);
<pre>
Room administrativeoffice21 = new Room("Administrative Office", "The shops are to Dwarn, the entrance to Orcinium is to the Warn, the inns inside the wall are to the Awarn, and the entrance back into Aldoria is to the Swarn. This is the administrative office. Hundreds of Orcs and adventures are lined behind you. You can feel hope, joy, and tension of these people. The administrative officers are franticly filling in the administrative papers of the new immigrants; as soon as your papers are filled up you may as well be invisible.", "Your location is (2,1)");
<pre>
administrativeoffice21.roomitems[1] = Orcics_200;
*Whenever I fire up this code I get the else section. Why is this?
case "take two hundred orcics":
if (currentRoom.roomitems.Contains(Orcics_200))
{
Console.WriteLine("You have taken {0}.", Orcics_200.Name);
playeritems.Add(Orcics_200);
playerwieght = playerwieght + Orcics_200.Wieght;
currentRoom.Description += " You have taken the 200 Orcics.";
}
else
{
Console.WriteLine("The Orcics are not here / you have already taken it.");
goto fix;
}
break;
*Thank you in advance for all of your answers.