package VGP;

public class World
	{
	public World()
		{
		Locations = new location[1];
		Locations[0] = new location();
		}
	public class location
		{
		String name;
		public lObject[] LocationObjects;
		public lNPC[] LocationNPCs;
		public location()
			{
			name = "unnamed location";
			LocationObjects = new lObject[1];
			LocationObjects[0] = new lObject("RNULL");
			LocationNPCs = new lNPC[1];
			LocationNPCs[0] = new lNPC("RNULL","");
			}
		public void SetName(String arg)
			{
			name = arg;
			}
		public String GetName()
			{
			return name;
			}
		public void AddNPC(String arg, String arg2)
			{
			if(LocationNPCs[0].GetName()!="RNULL")
				{
				int x = 0;
				lNPC[] newnpc = new lNPC[LocationNPCs.length+1];
				do {
				   newnpc[x] = LocationNPCs[x];
				   x++;
				   }
				while(x<LocationNPCs.length);
				LocationNPCs = newnpc;
				LocationNPCs[x] = new lNPC(arg, arg2);
				}
			else LocationNPCs[0]= new lNPC(arg, arg2);
				
			}
		public void AddObject(String arg)
			{
			if(LocationObjects[0].GetName()!="RNULL")
				{
				int x = 0;
				lObject[] newobj = new lObject[LocationObjects.length+1];
				do {
				   newobj[x] = LocationObjects[x];
				   x++;
				   }
				while(x<LocationObjects.length);
				LocationObjects = newobj;
				LocationObjects[x] = new lObject(arg);
				}
			else LocationObjects[0].SetName(arg);
			}
		public void DeleteNPC(int arg)
			{
			if(arg<LocationNPCs.length)
				{
				if(LocationNPCs.length!=1)
					{
					int x = 0;
					int y = 0;
					lNPC[] newnpc = new lNPC[LocationNPCs.length-1];
					do {
					   newnpc[x] = LocationNPCs[y];
					   if(y!=arg) x++;
					   y++;
					   }
					while(x<newnpc.length);
					LocationNPCs = newnpc;
					}
				else LocationNPCs[0].SetName("RNULL");
				}
			else System.out.printf("NPC ID out of range\n");
			}
		public void DeleteObject(int arg)
			{
			if(arg<LocationObjects.length)
				{
				if(LocationObjects.length!=1)
					{
					int x = 0;
					int y = 0;
					lObject[] newobj = new lObject[LocationObjects.length-1];
					do {
					   newobj[x] = LocationObjects[y];
					   if(y!=arg) x++;
					   y++;
					   }
					while(x<newobj.length);
					LocationObjects = newobj;
					}
				else LocationObjects[0].SetName("RNULL");
				}
			else System.out.printf("Object ID out of range\n");
			}
		public int GetNPCID(String arg) throws Exception
			{
			int x = 0;
			do {
			   if(LocationNPCs[x].GetName().toUpperCase().compareTo(arg.toUpperCase())==0) break;
			   x++;
			   }
			while(x<LocationNPCs.length);
			if(x==LocationNPCs.length) throw new Exception();
			return x;
			}
		public class lObject
			{
			String name;
			public lObject(String arg)
				{
				SetName(arg);
				}
			public String GetName()
				{
				return name;
				}
			public void SetName(String arg)
				{
				name = arg;
				}
			}
		public class lNPC
				{
				String name;
				String gender;
				public lNPC(String arg, String arg2)
					{
					SetName(arg);
					SetGender(arg2);
					}
				public String GetName()
					{
					return name;
					}
				public void SetName(String arg)
					{
					name = arg;
					}
				public String GetGender()
					{
					return gender;
					}
				public void SetGender(String arg)
					{
					gender = arg;
					}
				}
		}
	public location[] Locations;
	}
