コード例 #1
0
ファイル: Program.cs プロジェクト: Prandazzo42/public
        //---

        static void CreateInn()
        {
            XElement save   = SaveClass.LoadSave();
            XElement AddInn = save.Element("Inns");

            string name;

            Console.WriteLine("Créer une auberge");
            Console.WriteLine("Quel est le nom de votre auberge?");
            name = Console.ReadLine();
            int testing = 0;

            foreach (Inn i in ListInn)
            {
                if (name == i.Name)
                {
                    Console.WriteLine("Erreur, une autre auberge porte ce nom");
                    Console.ReadKey();
                    testing = 1;
                }
            }
            if (testing == 0)
            {
                Inn inn1 = new Inn(name);
                ListInn.Add(inn1);

                XElement NewInn = new XElement("Inn",
                                               new XAttribute("ID", name),
                                               new XElement("Name", name),
                                               new XElement("Heroes",
                                                            new XAttribute("ID", name)));
                AddInn.Add(NewInn);
                SaveClass.SaveFile(save);
            }
        }
コード例 #2
0
        public static void LoadGame(List <Inn> List)
        {
            XElement save = SaveClass.LoadSave();
            IEnumerable <XElement> LoadInn =
                save.XPathSelectElements("./Inns/Inn");

            foreach (XElement el in LoadInn)
            {
                XElement Inn     = el;
                string   innName = (string)Inn.Element("Name");

                Inn Inn1 = new Inn(innName);
                List.Add(Inn1);
            }
        }