Пример #1
0
        public void load(string filename)
        {
            items       = new List <Item>();
            playthrough = new Playthrough();
            using (StreamReader sr = new StreamReader(filename)) {
                string ln = null;
                while ((ln = sr.ReadLine()) != null)
                {
                    if (ln.Contains("entrances"))
                    {
                        while ((ln = sr.ReadLine()) != null)
                        {
                            if (ln.Contains("]"))
                            {
                                goto outer;
                            }
                            if (ln.Contains('{') || ln.Contains('}'))
                            {
                                continue;
                            }
                            //read emtrances;
                        }
                    }
                    if (ln.Contains("playthrough"))
                    {
                        while ((ln = sr.ReadLine()) != null)
                        {
                            string[] t;
                            if (ln.Contains("meta"))
                            {
                                break;
                            }
                            if (ln.Contains("Defeat Ganon") ||
                                ln.Contains("Agahnim"))
                            {
                                continue;
                            }
                            if (ln.Contains("longest"))
                            {
                                t = getTokens(ln);
                                this.longest_item_chain = Convert.ToInt32(t[1]);
                                ln = sr.ReadLine();
                                t  = getTokens(ln);
                                this.regions_visited = Convert.ToInt32(t[1]);
                                goto outer;
                            }
                            if (ln.Contains('{') || ln.Contains('}'))
                            {
                                continue;
                            }
                            t = getTokens(ln);
                            playthrough.addObjective(t[0].Trim().Replace("'", ""), t[1].Trim());
                        }
                    }
                    if (ln.Contains("meta"))
                    {
                        while ((ln = sr.ReadLine()) != null)
                        {
                            if (sr.Peek() == -1)
                            {
                                goto outer;
                            }
                            if (ln.Contains('{') || ln.Contains('}'))
                            {
                                continue;
                            }

                            string[] t = getTokens(ln);
                            if (t[0].Equals("difficulty"))
                            {
                                this.difficulty = t[1];
                            }
                            else if (t[0].Equals("logic"))
                            {
                                this.logic = t[1];
                            }
                            else if (t[0].Equals("seed"))
                            {
                                this.seed = t[1];
                            }
                            else if (t[0].Equals("goal"))
                            {
                                this.goal = t[1];
                            }
                            else if (t[0].Equals("build"))
                            {
                                this.build = DateTime.Parse(t[1]);
                            }
                            else if (t[0].Equals("mode"))
                            {
                                this.mode = t[1];
                            }
                        }
                    }
                    if (ln.Contains('{') || ln.Contains('}'))
                    {
                        continue;
                    }
                    if (ln.Contains("Agahnim"))
                    {
                        continue;
                    }
                    string[] tokens = getTokens(ln);
                    addItem(tokens[0].Trim(), tokens[1].Trim());
                    outer :;
                }
            }
            fireSeedLoaded();
        }
Пример #2
0
 public Seed()
 {
     items       = new List <Item>();
     playthrough = new Playthrough();
 }