Exemple #1
0
        //---

        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);
            }
        }
Exemple #2
0
        public static void DelHero(string nameHero, string nameInn, List <Hero> list)
        {
            XElement save = SaveClass.LoadSave();
            IEnumerable <XElement> DelHeroes =
                save.XPathSelectElements("./Inns/Inn[@ID='" + nameInn + "']/Heroes");

            foreach (XElement el in DelHeroes)
            {
                el.RemoveAll();
            }

            foreach (Hero h in list)
            {
                XElement NewHero = new XElement("Hero",
                                                new XAttribute("ID", h.Name),
                                                new XElement("Name", h.Name),
                                                new XElement("Hp", h.StatHero.Hp),
                                                new XElement("Strenght", h.StatHero.Strenght),
                                                new XElement("Stamina", h.StatHero.Stamina),
                                                new XElement("Agility", h.StatHero.Agility),
                                                new XElement("Speed", h.StatHero.Speed),
                                                new XElement("Lvl", h.Lvl),
                                                new XElement("Xp", h.Xp)
                                                );
                IEnumerable <XElement> SaveHeroes =
                    save.XPathSelectElements("./Inns/Inn[@ID='" + nameInn + "']/Heroes");
                foreach (XElement el in SaveHeroes)
                {
                    el.Add(NewHero);
                }
            }


            SaveClass.SaveFile(save);
        }
Exemple #3
0
        public void LvlUP()
        {
            XElement save = SaveClass.LoadSave();

            Console.WriteLine(" ");
            Console.WriteLine("{0} a augmenté de niveau!", this.Name);
            Console.WriteLine(" ");
            Random rng = new Random();

            Lvl += 1;
            int dice;

            dice = rng.Next(1, 101);
            Console.WriteLine("Force {0} + {1}", StatHero.Strenght, statTable(dice));
            StatHero.Strenght += statTable(dice);

            dice = rng.Next(1, 101);
            Console.WriteLine("Endurance {0} + {1}", StatHero.Stamina, statTable(dice));
            StatHero.Stamina += statTable(dice);

            dice = rng.Next(1, 101);
            Console.WriteLine("Agilité {0} + {1}", StatHero.Agility, statTable(dice));
            StatHero.Agility += statTable(dice);

            dice = rng.Next(1, 101);
            Console.WriteLine("Vitesse {0} + {1}", StatHero.Speed, statTable(dice));
            StatHero.Speed += statTable(dice);

            dice = rng.Next(1, 101);
            Console.WriteLine("Point de vie {0} + {1}", StatHero.Hp, 5 + statTable(dice));
            StatHero.Hp += 5 + statTable(dice);

            IEnumerable <XElement> SaveHeroes =
                save.XPathSelectElements("./Inns/Inn/Heroes/Hero[@ID='" + Name + "']");

            foreach (XElement el in SaveHeroes)
            {
                el.SetElementValue("Strenght", StatHero.Strenght);
                el.SetElementValue("Stamina", StatHero.Stamina);
                el.SetElementValue("Agility", StatHero.Agility);
                el.SetElementValue("Speed", StatHero.Speed);
                el.SetElementValue("Hp", StatHero.Hp);
                el.SetElementValue("Lvl", Lvl);
                el.SetElementValue("Xp", Xp);
            }
            SaveClass.SaveFile(save);

            Console.WriteLine(" ");
            Console.WriteLine("Appuyez sur une touche pour continuer");
            Console.ReadKey();
        }
Exemple #4
0
        //---

        public void CreateCharacter()
        {
            Console.Clear();

            XElement save = SaveClass.LoadSave();

            string name;

            Console.WriteLine("Ajouter un héros");
            Console.WriteLine("Quel est le nom de votre nouveau héros?");
            name = Console.ReadLine();
            int testing = 0;

            foreach (Hero h in ListHeroes)
            {
                if (name == h.Name)
                {
                    Console.WriteLine("Erreur, un Héros porte déjà ce nom!");
                    Console.ReadKey();
                    testing = 1;
                }
            }
            if (testing == 0)
            {
                Hero newHeroes = new Hero(name);
                ListHeroes.Add(newHeroes);
                XElement NewHero = new XElement("Hero",
                                                new XAttribute("ID", name),
                                                new XElement("Name", newHeroes.Name),
                                                new XElement("Hp", newHeroes.StatHero.Hp),
                                                new XElement("Strenght", newHeroes.StatHero.Strenght),
                                                new XElement("Stamina", newHeroes.StatHero.Stamina),
                                                new XElement("Agility", newHeroes.StatHero.Agility),
                                                new XElement("Speed", newHeroes.StatHero.Speed),
                                                new XElement("Lvl", newHeroes.Lvl),
                                                new XElement("Xp", newHeroes.Xp)
                                                );
                IEnumerable <XElement> SaveHeroes =
                    save.XPathSelectElements("./Inns/Inn[@ID='" + this.Name + "']/Heroes");
                foreach (XElement el in SaveHeroes)
                {
                    el.Add(NewHero);
                }

                SaveClass.SaveFile(save);
            }
        }