Пример #1
0
        private void BoutonConfirme_Click(object sender, RoutedEventArgs e)
        {
            ComboBoxItem typeItem = (ComboBoxItem)Choix.SelectedItem;
            string       choix    = typeItem.Content.ToString();

            if (choix == "Sorcier")
            {
                int           mat           = Convert.ToInt32(Texte1.Text);
                string        nom           = Texte2.Text;
                string        prenom        = Texte3.Text;
                string        fonction      = Texte4.Text;
                List <string> listePouvoirs = new List <string>();
                string        temp          = "";
                foreach (char elt in Texte5.Text)
                {
                    if (elt != '-')
                    {
                        temp = temp + elt;
                    }
                    else
                    {
                        listePouvoirs.Add(temp);
                        temp = "";
                    }
                }
                listePouvoirs.Add(temp);
                string   sexeSelection  = (string)Liste8.SelectionBoxItem;
                typesexe sexe           = RecupererSexe(sexeSelection);
                string   gradeSelection = (string)Liste9.SelectionBoxItem;
                Grade    grade          = Grade.novice;
                switch (gradeSelection)
                {
                case ("Strata"):
                {
                    grade = Grade.strata;
                    break;
                }

                case ("Mega"):
                {
                    grade = Grade.mega;
                    break;
                }

                case ("Giga"):
                {
                    grade = Grade.giga;
                    break;
                }
                }
                Sorcier sorcier = new Sorcier(listePouvoirs, grade, fonction, mat, nom, prenom, sexe);
                admin.AjouterSorcier(sorcier);
                MessageBox.Show("Sorcier ajouté.");
            }
            if (choix == "Monstre")
            {
                int        mat        = Convert.ToInt32(Texte1.Text);
                string     nom        = Texte2.Text;
                string     prenom     = Texte3.Text;
                string     fonction   = Texte4.Text;
                int        cagnotte   = Convert.ToInt32(Texte5.Text);
                Attraction attraction = new Attraction();
                typesexe   sexe       = RecupererSexe((string)Liste8.SelectionBoxItem);
                Monstre    monstre    = new Monstre(attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterMonstre(monstre);
                MessageBox.Show("Monstre ajouté.");
            }
            if (choix == "Démon")
            {
                int        mat        = Convert.ToInt32(Texte1.Text);
                string     nom        = Texte2.Text;
                string     prenom     = Texte3.Text;
                string     fonction   = Texte4.Text;
                int        cagnotte   = Convert.ToInt32(Texte5.Text);
                int        force      = Convert.ToInt32(Texte7.Text);
                Attraction attraction = new Attraction();
                typesexe   sexe       = RecupererSexe((string)Liste8.SelectionBoxItem);
                Demon      demon      = new Demon(force, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterDemon(demon);
                MessageBox.Show("Démon ajouté.");
            }
            if (choix == "Fantôme")
            {
                int        mat        = Convert.ToInt32(Texte1.Text);
                string     nom        = Texte2.Text;
                string     prenom     = Texte3.Text;
                string     fonction   = Texte4.Text;
                int        cagnotte   = Convert.ToInt32(Texte5.Text);
                Attraction attraction = new Attraction();
                typesexe   sexe       = RecupererSexe((string)Liste8.SelectionBoxItem);
                Fantome    fantome    = new Fantome(attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterFantome(fantome);
                MessageBox.Show("Fantôme ajouté");
            }
            if (choix == "Loup Garou")
            {
                int        mat           = Convert.ToInt32(Texte1.Text);
                string     nom           = Texte2.Text;
                string     prenom        = Texte3.Text;
                string     fonction      = Texte4.Text;
                int        cagnotte      = Convert.ToInt32(Texte5.Text);
                double     indiceCruaute = Convert.ToDouble(Texte7.Text);
                Attraction attraction    = new Attraction();
                typesexe   sexe          = RecupererSexe((string)Liste8.SelectionBoxItem);
                LoupGarou  loupGarou     = new LoupGarou(indiceCruaute, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterLoupGarou(loupGarou);
                MessageBox.Show("Loup garou ajouté.");
            }
            if (choix == "Vampire")
            {
                int        mat              = Convert.ToInt32(Texte1.Text);
                string     nom              = Texte2.Text;
                string     prenom           = Texte3.Text;
                string     fonction         = Texte4.Text;
                int        cagnotte         = Convert.ToInt32(Texte5.Text);
                double     indiceLuminosite = Convert.ToDouble(Texte7.Text);
                Attraction attraction       = new Attraction();
                typesexe   sexe             = RecupererSexe((string)Liste8.SelectionBoxItem);
                Vampire    vampire          = new Vampire(indiceLuminosite, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterVampire(vampire);
                MessageBox.Show("Vampire ajouté.");
            }
            if (choix == "Zombie")
            {
                int        mat                = Convert.ToInt32(Texte1.Text);
                string     nom                = Texte2.Text;
                string     prenom             = Texte3.Text;
                string     fonction           = Texte4.Text;
                int        cagnotte           = Convert.ToInt32(Texte5.Text);
                int        degreDecomposition = Convert.ToInt32(Texte7.Text);
                Attraction attraction         = new Attraction();
                typesexe   sexe               = RecupererSexe((string)Liste8.SelectionBoxItem);
                CouleurZ   couleur            = CouleurZ.bleuatre;
                if ((string)Liste9.SelectionBoxItem == "grisatre")
                {
                    couleur = CouleurZ.grisatre;
                }
                Zombie zombie = new Zombie(degreDecomposition, couleur, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterZombie(zombie);
                MessageBox.Show("Zombie ajouté.");
            }
            if (choix == "Boutique")
            {
                string       id               = Texte1.Text;
                string       nom              = Texte2.Text;
                int          nbMin            = Convert.ToInt32(Texte3.Text);
                string       typeBesoin       = Texte4.Text;
                bool         besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                TypeBoutique typeBoutique     = TypeBoutique.barbeAPapa;
                switch ((string)Liste9.SelectionBoxItem)
                {
                case ("Souvenir"):
                {
                    typeBoutique = TypeBoutique.souvenir;
                    break;
                }

                case ("Nourriture"):
                {
                    typeBoutique = TypeBoutique.nourriture;
                    break;
                }
                }
                List <Monstre> equipe   = new List <Monstre>();
                TimeSpan       time     = new TimeSpan(0);
                Boutique       boutique = new Boutique(typeBoutique, besoinSpecifique, time, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                MessageBox.Show("Boutique ajoutée.");
            }
            if (choix == "DarkRide")
            {
                string         id               = Texte1.Text;
                string         nom              = Texte2.Text;
                int            nbMin            = Convert.ToInt32(Texte3.Text);
                string         typeBesoin       = Texte4.Text;
                TimeSpan       time             = new TimeSpan(0, Convert.ToInt32(Texte5.Text), 0);
                bool           besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                bool           vehicule         = RecupererBool((string)Liste9.SelectionBoxItem);
                TimeSpan       dureeMaintenance = new TimeSpan(0);
                List <Monstre> equipe           = new List <Monstre>();
                DarkRide       darkRide         = new DarkRide(time, vehicule, besoinSpecifique, dureeMaintenance, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                admin.AjouterDarkRide(darkRide);
                MessageBox.Show("DarkRide ajouté.");
            }
            if (choix == "RollerCoaster")
            {
                string        id               = Texte1.Text;
                string        nom              = Texte2.Text;
                int           nbMin            = Convert.ToInt32(Texte3.Text);
                string        typeBesoin       = Texte4.Text;
                int           ageMin           = Convert.ToInt32(Texte5.Text);
                int           tailleMin        = Convert.ToInt32(Texte6.Text);
                bool          besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                TypeCategorie typeCategorie    = TypeCategorie.assise;
                switch ((string)Liste9.SelectionBoxItem)
                {
                case ("Bobsleigh"):
                {
                    typeCategorie = TypeCategorie.bobsleigh;
                    break;
                }

                case ("Inversée"):
                {
                    typeCategorie = TypeCategorie.inversee;
                    break;
                }
                }
                TimeSpan       dureeMaintenance = new TimeSpan(0);
                List <Monstre> equipe           = new List <Monstre>();
                RollerCoaster  roller           = new RollerCoaster(ageMin, typeCategorie, tailleMin, besoinSpecifique, dureeMaintenance, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                admin.AjouterRollerCoaster(roller);
                MessageBox.Show("RollerCoaster ajouté.");
            }
            if (choix == "Spectacle")
            {
                string          id           = Texte1.Text;
                string          nom          = Texte2.Text;
                int             nbMin        = Convert.ToInt32(Texte3.Text);
                string          typeBesoin   = Texte4.Text;
                string          nomSalle     = Texte5.Text;
                int             nbPlaces     = Convert.ToInt32(Texte6.Text);
                List <DateTime> listeHoraire = new List <DateTime>();
                string[]        lHoraire     = Texte7.Text.Split(' ');
                foreach (string elt in lHoraire)
                {
                    listeHoraire.Add(Convert.ToDateTime(elt));
                }
                bool           besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                TimeSpan       dureeMaintenance = new TimeSpan(0);
                List <Monstre> equipe           = new List <Monstre>();
                Spectacles     spectacles       = new Spectacles(listeHoraire, nbPlaces, nomSalle, besoinSpecifique, dureeMaintenance, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                admin.AjouterSpectacle(spectacles);
                MessageBox.Show("Spectacle ajouté.");
            }
        }
Пример #2
0
 public void AjouterSorcier(Sorcier sorcier)
 {
     this.equipeSorcier.Add(sorcier);
     this.toutLePersonnel.Add(sorcier);
 }
Пример #3
0
        static public void LireFichierPersonnel(StreamReader fichier, Administration admin, TextBlock text)
        {
            string ligne = fichier.ReadLine();

            while (ligne != null)
            {
                string[] temp = ligne.Split(';');
                if (temp[0] == "Sorcier")
                {
                    try
                    {
                        string   test             = temp[7];
                        int      matriculeSorcier = Convert.ToInt32(temp[1]);
                        string   nomSorcier       = temp[2];
                        string   prenomSorcier    = temp[3];
                        typesexe sexeSorcier      = typesexe.autre;
                        if (temp[4] == "femelle")
                        {
                            sexeSorcier = typesexe.femelle;
                        }
                        if (temp[4] == "male")
                        {
                            sexeSorcier = typesexe.male;
                        }
                        string fonctionSorcier = temp[5];
                        Grade  tatouageSorcier = Grade.novice;
                        if (temp[6] == "mega")
                        {
                            tatouageSorcier = Grade.mega;
                        }
                        if (temp[6] == "giga")
                        {
                            tatouageSorcier = Grade.giga;
                        }
                        if (temp[6] == "strata")
                        {
                            tatouageSorcier = Grade.strata;
                        }
                        string        test1           = "";
                        List <String> pouvoirsSorcier = new List <String>();
                        foreach (char elt in temp[7])
                        {
                            if (elt != '-')
                            {
                                test1 = test1 + elt;
                            }
                            else
                            {
                                pouvoirsSorcier.Add(test1);
                                test1 = "";
                            }
                        }
                        pouvoirsSorcier.Add(test1);

                        Sorcier sorcier = new Sorcier(pouvoirsSorcier, tatouageSorcier, fonctionSorcier, matriculeSorcier, nomSorcier, prenomSorcier, sexeSorcier);
                        admin.AjouterSorcier(sorcier);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }

                if (temp[0] == "Monstre")
                {
                    try
                    {
                        string   test             = temp[7];
                        int      matriculeMonstre = Convert.ToInt32(temp[1]);
                        string   nomMonstre       = temp[2];
                        string   prenomMonstre    = temp[3];
                        typesexe sexeMonstre      = typesexe.autre;
                        if (temp[4] == "femelle")
                        {
                            sexeMonstre = typesexe.femelle;
                        }
                        if (temp[4] == "male")
                        {
                            sexeMonstre = typesexe.male;
                        }
                        string     fonctionMonstre    = temp[5];
                        int        cagnotteMonstre    = Convert.ToInt32(temp[6]);
                        Attraction affectationMonstre = RechercheAttractionParIdentifiant(temp[7], admin.Attractions);
                        Monstre    monstre            = new Monstre(affectationMonstre, cagnotteMonstre, fonctionMonstre, matriculeMonstre, nomMonstre, prenomMonstre, sexeMonstre);
                        admin.AjouterMonstre(monstre);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }


                if (temp[0] == "Demon")
                {
                    try
                    {
                        string   test           = temp[8];
                        int      matriculeDemon = Convert.ToInt32(temp[1]);
                        string   nomDemon       = temp[2];
                        string   prenomDemon    = temp[3];
                        typesexe sexeDemon      = typesexe.autre;
                        if (temp[4] == "femelle")
                        {
                            sexeDemon = typesexe.femelle;
                        }
                        if (temp[4] == "male")
                        {
                            sexeDemon = typesexe.male;
                        }
                        string     fonctionDemon    = temp[5];
                        int        cagnotteDemon    = Convert.ToInt32(temp[6]);
                        Attraction affectationDemon = RechercheAttractionParIdentifiant(temp[7], admin.Attractions);
                        int        forceDemon       = Convert.ToInt32(temp[8]);
                        Demon      demon            = new Demon(forceDemon, affectationDemon, cagnotteDemon, fonctionDemon, matriculeDemon, nomDemon, prenomDemon, sexeDemon);
                        admin.AjouterDemon(demon);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }


                if (temp[0] == "Fantome")
                {
                    try
                    {
                        string   test             = temp[7];
                        int      matriculeFantome = Convert.ToInt32(temp[1]);
                        string   nomFantome       = temp[2];
                        string   prenomFantome    = temp[3];
                        typesexe sexeFantome      = typesexe.autre;
                        if (temp[4] == "femelle")
                        {
                            sexeFantome = typesexe.femelle;
                        }
                        if (temp[4] == "male")
                        {
                            sexeFantome = typesexe.male;
                        }
                        string     fonctionFantome    = temp[5];
                        int        cagnotteFantome    = Convert.ToInt32(temp[6]);
                        Attraction affectationFantome = RechercheAttractionParIdentifiant(temp[7], admin.Attractions);
                        Fantome    fantome            = new Fantome(affectationFantome, cagnotteFantome, fonctionFantome, matriculeFantome, nomFantome, prenomFantome, sexeFantome);
                        admin.AjouterFantome(fantome);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if (temp[0] == "LoupGarou")
                {
                    try
                    {
                        string   test = temp[8];
                        int      matriculeLoupGarou = Convert.ToInt32(temp[1]);
                        string   nomLoupGarou       = temp[2];
                        string   prenomLoupGarou    = temp[3];
                        typesexe sexeLoupGarou      = typesexe.autre;
                        if (temp[4] == "femelle")
                        {
                            sexeLoupGarou = typesexe.femelle;
                        }
                        if (temp[4] == "male")
                        {
                            sexeLoupGarou = typesexe.male;
                        }
                        string     fonctionLoupGarou      = temp[5];
                        int        cagnotteLoupGarou      = Convert.ToInt32(temp[6]);
                        Attraction affectationLoupGarou   = RechercheAttractionParIdentifiant(temp[7], admin.Attractions);
                        double     indiceCruauteLoupGarou = Convert.ToDouble(temp[8]);
                        LoupGarou  loupgarou = new LoupGarou(indiceCruauteLoupGarou, affectationLoupGarou, cagnotteLoupGarou, fonctionLoupGarou, matriculeLoupGarou, nomLoupGarou, prenomLoupGarou, sexeLoupGarou);
                        admin.AjouterLoupGarou(loupgarou);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if (temp[0] == "Vampire")
                {
                    try
                    {
                        string   test             = temp[8];
                        int      matriculeVampire = Convert.ToInt32(temp[1]);
                        string   nomVampire       = temp[2];
                        string   prenomVampire    = temp[3];
                        typesexe sexeVampire      = typesexe.autre;
                        if (temp[4] == "femelle")
                        {
                            sexeVampire = typesexe.femelle;
                        }
                        if (temp[4] == "male")
                        {
                            sexeVampire = typesexe.male;
                        }
                        string     fonctionVampire         = temp[5];
                        int        cagnotteVampire         = Convert.ToInt32(temp[6]);
                        Attraction affectationVampire      = RechercheAttractionParIdentifiant(temp[7], admin.Attractions);
                        double     indiceLuminositeVampire = Convert.ToDouble(temp[8]);
                        Vampire    vampire = new Vampire(indiceLuminositeVampire, affectationVampire, cagnotteVampire, fonctionVampire, matriculeVampire, nomVampire, prenomVampire, sexeVampire);
                        admin.AjouterVampire(vampire);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if (temp[0] == "Zombie")
                {
                    try
                    {
                        string   test            = temp[9];
                        int      matriculeZombie = Convert.ToInt32(temp[1]);
                        string   nomZombie       = temp[2];
                        string   prenomZombie    = temp[3];
                        typesexe sexeZombie      = typesexe.autre;
                        if (temp[4] == "femelle")
                        {
                            sexeZombie = typesexe.femelle;
                        }
                        if (temp[4] == "male")
                        {
                            sexeZombie = typesexe.male;
                        }
                        string     fonctionZombie    = temp[5];
                        int        cagnotteZombie    = Convert.ToInt32(temp[6]);
                        Attraction affectationZombie = RechercheAttractionParIdentifiant(temp[7], admin.Attractions);
                        CouleurZ   teintZombie       = CouleurZ.bleuatre;
                        if (temp[8] == "grisatre")
                        {
                            teintZombie = CouleurZ.grisatre;
                        }
                        int    degreDecompositionZombie = Convert.ToInt32(temp[9]);
                        Zombie zombie = new Zombie(degreDecompositionZombie, teintZombie, affectationZombie, cagnotteZombie, fonctionZombie, matriculeZombie, nomZombie, prenomZombie, sexeZombie);
                        admin.AjouterZombie(zombie);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                ligne = fichier.ReadLine();
            }
            fichier.Close();
        }