Пример #1
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);
        }
Пример #2
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);
            }
        }
Пример #3
0
        public static void LoadInn(string InnName, List <Hero> List)
        {
            XElement save = SaveClass.LoadSave();
            IEnumerable <XElement> LoadHero =
                save.XPathSelectElements("./Inns/Inn[@ID='" + InnName + "']/Heroes/Hero");

            foreach (XElement el in LoadHero)
            {
                try
                {
                    XElement Hero         = el;
                    string   heroName     = (string)Hero.Element("Name");
                    int      heroHp       = (int)Hero.Element("Hp");
                    int      heroStrenght = (int)Hero.Element("Strenght");
                    int      heroStamina  = (int)Hero.Element("Stamina");
                    int      heroAgility  = (int)Hero.Element("Agility");
                    int      heroSpeed    = (int)Hero.Element("Speed");
                    int      heroLvl      = (int)Hero.Element("Lvl");
                    int      heroXp       = (int)Hero.Element("Xp");

                    Hero hero1 = new Hero(heroName, heroHp, heroStrenght, heroStamina, heroAgility, heroSpeed, heroLvl, heroXp);
                    List.Add(hero1);
                }catch (Exception e)
                {
                    continue;
                }
            }
        }
Пример #4
0
 //---
 static void Main(string[] args)
 {
     SaveClass.CheckSave();
     SaveClass.LoadGame(ListInn);
     Menu();
     Console.WriteLine("Press any key to exit.");
     Console.ReadKey();
 }
Пример #5
0
        public void EndFightPvP(Hero h1, Hero h2)
        {
            Console.WriteLine("---------------------------------------------------------------");
            Console.WriteLine("{0} meurt dans d'atroces souffrances!", h2.Name);
            Console.WriteLine("{0} est le gagnant du duel!", h1.Name);
            int xpWin = (h2.Lvl * 100);

            Console.WriteLine("{0} gagne {1} xp!", h1.Name, xpWin);
            h1.GainXP(xpWin);
            ListHeroes.Remove(h2);
            SaveClass.DelHero(h2.Name, this.Name, ListHeroes);
        }
Пример #6
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();
        }
Пример #7
0
        //---

        static void DelInn(int i)
        {
            int compteur = 0;

            foreach (Inn I in ListInn)
            {
                compteur++;
                if (i == compteur)
                {
                    SaveClass.DelInnSave(ListInn[compteur - 1].Name, ListInn);
                    ListInn.RemoveAt(compteur - 1);
                    break;
                }
            }
        }
Пример #8
0
        //---

        static void SelectInn(int i)
        {
            int compteur = 0;

            foreach (Inn I in ListInn)
            {
                compteur++;
                if (i == compteur)
                {
                    SaveClass.LoadInn(I.Name, I.ListHeroes);
                    I.InnMenu();
                    break;
                }
            }
        }
Пример #9
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);
            }
        }
Пример #10
0
        //---

        public void DelCharacter(int i)
        {
            int timer = 0;

            foreach (Hero H in ListHeroes)
            {
                if (i == timer)
                {
                    string nameHero = ListHeroes[timer].Name;
                    ListHeroes.RemoveAt(timer);
                    SaveClass.DelHero(nameHero, this.Name, ListHeroes);
                    break;
                }
                timer++;
            }
        }
Пример #11
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);
            }
        }