using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace TheSlimesJourney { public class Location { public string name = "Unknown"; public string description = "You have no idea where you are."; public List fullDeck; public List currentDeck; public List restDeck; public string[] updateScript = null; public Location(string filename) { StreamReader sr = new StreamReader("locations/" + filename + ".sjl"); while (!sr.EndOfStream) { string currentLine = Utils.Filter(sr.ReadLine()); switch (currentLine) { case "location": sr.ReadLine(); //Skip the { while (currentLine != "}") { currentLine = Utils.Filter(sr.ReadLine()); string[] split = currentLine.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); string baseCommand = ""; if (split.Length > 0) baseCommand = split[0]; switch (baseCommand) { case "name": this.name = Utils.RBQ(currentLine); break; case "description": StringBuilder sb = new StringBuilder(); sr.ReadLine(); //Skip the { while (currentLine != "}") { currentLine = Utils.Filter(sr.ReadLine()); if (currentLine != "}") sb.Append(currentLine); } description = sb.ToString(); currentLine = ""; //So as not to trigger other scope ends break; case "deck": { fullDeck = new List(); string[] fullScope = Utils.ReadScope(sr); for (int i = 0; i < fullScope.Length; i++) { fullDeck.Add(new Event(fullScope[i])); } } break; case "mutations": { Mutation.possibleMutations.Clear(); string[] fullScope = Utils.ReadScope(sr); for (int i = 0; i < fullScope.Length; i++) { string mutation = fullScope[i]; if (!Game.player.mutations.ContainsKey(mutation)) { Mutation.possibleMutations.Add(Mutation.GetMutation(mutation)); } } } break; case "rest": { restDeck = new List(); string[] fullScope = Utils.ReadScope(sr); for (int i = 0; i < fullScope.Length; i++) { restDeck.Add(new Event(fullScope[i])); } } break; case "updatescript": { updateScript = Utils.ReadScope(sr); } break; } } break; } } sr.Close(); } } }