// this method loads a whole world from a txt file. public static World LoadWorld(string file) { World BRAVENEWWORLD = new World(); // debuging ????? try { using (StreamReader rd = new StreamReader(file)) // streamreader { string WORLDNAME = rd.ReadLine(); int locationNumber = Convert.ToInt32(rd.ReadLine()); int increment = 0; List<string> superList = new List<string>(); List<string> itemList = new List<string>(); //loads the locations I think???? while (locationNumber != increment) { string Line = rd.ReadLine(); bool test = true; while (test == true) { superList.Add(Line); test = false; } increment++; } string itemReader = ""; // reads items into the list while (itemReader != null) { itemReader = rd.ReadLine(); if (itemReader != null) { itemList.Add(itemReader); } } List<Item> itemslocList = new List<Item>(); int listLength = itemList.Count; int i = 0; // this while loop does strange things // mostly converting input to strings? not sure why its been a while // converts strings into an ITEM class its interesting while (listLength > 0) { string item = itemList[i]; string[] oneItem = new string[4]; string[] lineSplitter = item.Split(new char[] { '|' }); int o = -1; foreach (string s in lineSplitter) { o++; if (s != "") { oneItem[o] = s; } } string itemName = oneItem[0]; string itemDesc = oneItem[1]; string itemMove = oneItem[2]; bool itemMover; if (itemMove == "Y") { itemMover = true; } else { itemMover = false; } string blah = oneItem[3]; int itemLoc = Convert.ToInt32(oneItem[3]); Item newItem = new Item(itemName, itemDesc, itemMover, itemLoc); itemslocList.Add(newItem); listLength--; i++; } int locationtester = locationNumber; int supercounter = 0; string[] oneLocation = new string[4]; //SO MUCH CONFUSION //but its ok //appears to make a list of locations and calls it super list //makes it a location //also adds it to the world. while (supercounter != locationtester) { string Line = superList[supercounter]; string[] linesplitter = Line.Split(new char[] { '|' }); i = -1; foreach (string s in linesplitter) { i++; if (i != 4) { oneLocation[i] = s; } } int location = Convert.ToInt32(oneLocation[0]); string desc = oneLocation[1]; string image = oneLocation[2]; string exitMess = oneLocation[3]; int[] exitArray = new int[6]; string[] exitSplit = exitMess.Split(new char[] { ',' }); i = 0; foreach (string x in exitSplit) { exitArray[i] = Convert.ToInt32(x.Trim()); i++; } int countList = itemslocList.Count; int u = 0; List<Item> FinalItemList = new List<Item>(); while (u != countList - 1) { Item mess = itemslocList[u]; int locator = mess.getLoc(); u++; if (locator == location) { FinalItemList.Add(mess); } } Location newloc = new Location(location, desc, FinalItemList, image, exitArray); BRAVENEWWORLD.AddLocation(newloc); supercounter++; } BRAVENEWWORLD.MakeAlive(); } } catch { } return BRAVENEWWORLD; }