Exemple #1
0
        static List <Personnel> LecturePersonnel(StreamReader monStreamReader, List <Attraction> liste_attraction)
        {
            List <Personnel> liste_personnel = new List <Personnel>();
            string           ligne           = monStreamReader.ReadLine(); //on stock la premiere ligne

            for (int j = 0; j < 17; j++)                                   // tant qu'il y a pas d'espace vide
            {
                string[] temp      = ligne.Split(';');
                Typesexe type_sex  = Typesexe.none;
                int      matricule = -1;
                try { matricule = int.Parse(temp[1]); } catch (InvalidCastException e) { Console.WriteLine(e.Message); }
                try { type_sex = (Typesexe)Enum.Parse(typeof(Typesexe), temp[4]); } catch (InvalidCastException e) { Console.WriteLine(e.Message); }
                int        c             = -1;
                Attraction monAttraction = null;
                if (temp[0] != "Sorcier")
                {
                    try { c = int.Parse(temp[7]); } catch (FormatException e) { Console.WriteLine(e.Message); }
                    monAttraction = QuelEstAttraction(liste_attraction, c);
                }


                switch (temp[0])
                {
                case "Sorcier":
                    grade G = grade.none;
                    try { G = (grade)Enum.Parse(typeof(grade), temp[6]); } catch (InvalidCastException e) { Console.WriteLine(e.Message); }

                    List <string> liste_p = new List <string>();
                    string[]      temp2   = temp[7].Split('-');
                    for (int i = 0; i < temp2.Length; i++)
                    {
                        liste_p.Add(temp2[i]);
                    }
                    Sorcier monSorcier = new Sorcier(matricule, temp[2], temp[3], type_sex, temp[5], G, liste_p);
                    liste_personnel.Add(monSorcier);
                    break;

                case "Monstre":

                    int cagnotte_monstre = 0;
                    try { cagnotte_monstre = int.Parse(temp[6]); } catch (InvalidCastException e) { Console.WriteLine(e.Message); }
                    Monstre monMonstre = new Monstre(matricule, temp[2], temp[3], type_sex, temp[5], cagnotte_monstre, monAttraction);
                    liste_personnel.Add(monMonstre);
                    break;

                case "Demon":
                    int   cagnotte_demon = int.Parse(temp[6]);
                    int   force          = int.Parse(temp[8]);
                    Demon monDemon       = new Demon(matricule, temp[2], temp[3], type_sex, temp[5], cagnotte_demon, monAttraction, force);
                    liste_personnel.Add(monDemon);
                    break;

                case "Fantome":
                    int     cagnotte_fantome = int.Parse(temp[6]);
                    Fantome monFantome       = new Fantome(matricule, temp[2], temp[3], type_sex, temp[5], cagnotte_fantome, monAttraction);
                    liste_personnel.Add(monFantome);
                    break;

                case "LoupGarou":
                    int       cagnotte_loup = int.Parse(temp[6]);
                    float     indiceCruaute = float.Parse(temp[8]);
                    LoupGarou monLoup       = new LoupGarou(matricule, temp[2], temp[3], type_sex, temp[5], cagnotte_loup, monAttraction, indiceCruaute);
                    liste_personnel.Add(monLoup);
                    break;

                case "Vampire":
                    int     cagnotte_vamp    = int.Parse(temp[6]);
                    float   indiceLuminosite = float.Parse(temp[8]);
                    Vampire monVamp          = new Vampire(matricule, temp[2], temp[3], type_sex, temp[5], cagnotte_vamp, monAttraction, indiceLuminosite);
                    liste_personnel.Add(monVamp);
                    break;

                case "Zombie":
                    CouleurZ maCouleur          = (CouleurZ)Enum.Parse(typeof(CouleurZ), temp[8]);
                    int      degreDecomposition = int.Parse(temp[9]);
                    int      cagnotte_zomb      = int.Parse(temp[6]);
                    Zombie   monZomb            = new Zombie(matricule, temp[2], temp[3], type_sex, temp[5], cagnotte_zomb, monAttraction, maCouleur, degreDecomposition);
                    liste_personnel.Add(monZomb);
                    break;
                }



                ligne = monStreamReader.ReadLine();
            }
            monStreamReader.Close();
            return(liste_personnel);
        }
Exemple #2
0
 public LoupGarou(int matricule, string nom, string prenom, Typesexe sexe, string function, int cagnotte, Attraction attribution, float indiceCruaute) : base(matricule, nom, prenom, sexe, function, cagnotte, attribution)
 {
     this.IndiceCruaute = indiceCruaute;
 }
Exemple #3
0
 public Monstre(int matricule, string nom, string prenom, Typesexe sexe, string function, int cagnotte, Attraction affectation) : base(function, matricule, nom, prenom, sexe)
 {
     this.Affectation = affectation;
     this.Cagnotte    = cagnotte;
 }
Exemple #4
0
 public Fantome(int matricule, string nom, string prenom, Typesexe sexe, string function, int cagnotte, Attraction attribution) : base(matricule, nom, prenom, sexe, function, cagnotte, attribution)
 {
     Atout = "invisibilite";
 }
Exemple #5
0
 public Demon(int matricule, string nom, string prenom, Typesexe sexe, string function, int cagnotte, Attraction affectation, int force) : base(matricule, nom, prenom, sexe, function, cagnotte, affectation)
 {
     this.Force = force;
 }
Exemple #6
0
 public Zombie(int matricule, string nom, string prenom, Typesexe sexe, string function, int cagnotte, Attraction attribution, CouleurZ teint, int degreDecomposition) : base(matricule, nom, prenom, sexe, function, cagnotte, attribution)
 {
     this.DegreDecomposition = degreDecomposition;
     this.Teint = teint;
 }
Exemple #7
0
 public Vampire(int matricule, string nom, string prenom, Typesexe sexe, string function, int cagnotte, Attraction attribution, float indiceLuminosite) : base(matricule, nom, prenom, sexe, function, cagnotte, attribution)
 {
     this.IndiceLuminosite = indiceLuminosite;
 }