コード例 #1
0
        //Supprime un montre à l'attraction grâce aux propriétésde la liste
        public void SupprimerEquipe(Monstre M)
        {
            bool supprimer = false;

            for (int i = 0; i < equipe.Count() && supprimer == false; i++)
            {
                if (equipe[i].NOM == M.NOM && equipe[i].PRENOM == M.PRENOM)
                {
                    equipe.Remove(M);
                    supprimer = true;
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Incremente la cagnotte du monstre fourni par un montant fourni. On utilise un montant negatif pour decrementer la cagnotte
 /// </summary>
 /// <param name="sujet">Monstre auquel incrementer la cagnotte</param>
 /// <param name="montant">Montant par lequel incrementer la cagnotte, negatif pour decrementer la cagnotte</param>
 public void GestionCagnotte(Monstre sujet, int montant)
 {
     sujet.Cagnotte += montant;
     if (sujet.Cagnotte < 50)
     {
         Affecter(sujet, purgatory);
     }
     else if (sujet.Cagnotte > 500)
     {
         if (sujet is IVanishable)
         {
             (sujet as IVanishable).Vanish();
         }
     }
 }
コード例 #3
0
        //Fonction qu'on appelle lorsque de l'ajout/suppression de points est fait
        //Elle vérifie que le monstre a la bonne affectation
        public void GererCagnotte(Monstre M)
        {
            if (M.CAGNOTTE < 50)
            {
                bool rechercher = false;
                for (int j = 0; j < attractions.Count() && rechercher == false; j++)
                {
                    if (attractions[j] is Boutique && (attractions[j] as Boutique).Type.ToString() == "barbeAPapa")
                    {
                        M.ChangerAffectation(attractions[j].Nom);
                        attractions[j].AjouterEquipe(M);
                        rechercher = true;
                    }
                }
            }
            if (M.CAGNOTTE > 500 && M.AFFECTATION != "parc" && M.AFFECTATION != "neant")
            {
                bool rechercher = false;

                for (int j = 0; j < attractions.Count() && rechercher == false; j++)
                {
                    if (attractions[j].Nom == M.AFFECTATION)
                    {
                        if (attractions[j].NombreMinMonstre < attractions[j].Equipe.Count())
                        {
                            M.ChangerAffectation("parc");
                            attractions[j].SupprimerEquipe(M);
                        }
                        rechercher = true;
                    }
                }
            }
            if (M.CAGNOTTE < 500 && M.CAGNOTTE > 50 && M.AFFECTATION == "parc" || M.CAGNOTTE < 500 && M.CAGNOTTE > 50 && M.AFFECTATION == "")
            {
                Attraction temp = RechercherAttraction();
                M.ChangerAffectation(temp.Nom);

                bool rechercher = false;
                for (int j = 0; j < attractions.Count() && rechercher == false; j++)
                {
                    if (attractions[j].Nom == temp.Nom)
                    {
                        attractions[j].AjouterEquipe(M);
                        rechercher = true;
                    }
                }
            }
        }
コード例 #4
0
        public void AfficherClassement()
        {
            List <Monstre> listMonstre = new List <Monstre>();

            for (int i = 0; i < toutLePersonnel.Count; i++)
            {
                if (toutLePersonnel[i] is Monstre)
                {
                    Monstre M = (Monstre)toutLePersonnel[i];
                    listMonstre.Add(M);
                }
            }
            listMonstre.Sort(delegate(Monstre X, Monstre Y)
                             { return(X.CAGNOTTE.CompareTo(Y.CAGNOTTE)); });
            for (int i = 0; i < listMonstre.Count; i++)
            {
                Console.WriteLine(listMonstre[i].NOM + " " + listMonstre[i].PRENOM + " " + listMonstre[i].CAGNOTTE);
            }
        }
コード例 #5
0
 public void SupprimerCagnotte(Monstre M, int nbPoint)
 {
     M.SupprimerPoint(nbPoint);
     GererCagnotte(M);
 }
コード例 #6
0
 //Deux prochaines fonctions utilisées par Rose seulement
 public void AjouterCagnotte(Monstre M, int nbPoint)
 {
     M.AjouterPoint(nbPoint);
     GererCagnotte(M);
 }
コード例 #7
0
        //Lis un fichier puis convertis les données ou les attractions selon le document données par Mme.Branchet et les types
        public void LectureFichier(string nomFichier)
        {
            StreamReader monStreamReader = new StreamReader(nomFichier);
            string       ligne           = monStreamReader.ReadLine();

            while (ligne != null)
            {
                string[] temp = ligne.Split(';');

                if (temp[0] == "Sorcier")
                {
                    List <string> listeTemp = new List <string>();
                    listeTemp.Add(temp[7]);
                    Sorcier S = new Sorcier(Convert.ToInt32(temp[1]), temp[2], temp[3], (TypeSexe)Enum.Parse(typeof(TypeSexe), temp[4]), temp[5], (Grade)Enum.Parse(typeof(Grade), temp[6]), listeTemp);
                    toutLePersonnel.Add(S);
                }
                else if (temp[0] == "Monstre")
                {
                    Monstre M = new Monstre(Convert.ToInt32(temp[1]), temp[2], temp[3], (TypeSexe)Enum.Parse(typeof(TypeSexe), temp[4]), temp[5], temp[7], Convert.ToInt32(temp[6]));
                    toutLePersonnel.Add(M);
                }
                else if (temp[0] == "Vampire")
                {
                    Vampire V = new Vampire(Convert.ToInt32(temp[1]), temp[2], temp[3], (TypeSexe)Enum.Parse(typeof(TypeSexe), temp[4]), temp[5], Convert.ToInt32(temp[6]), temp[7], Convert.ToDouble(temp[8]));
                    toutLePersonnel.Add(V);
                }
                else if (temp[0] == "Zombie")
                {
                    Zombie Z = new Zombie(Convert.ToInt32(temp[1]), temp[2], temp[3], (TypeSexe)Enum.Parse(typeof(TypeSexe), temp[4]), temp[5], Convert.ToInt32(temp[6]), temp[7], Convert.ToInt32(temp[9]), (CouleurZ)Enum.Parse(typeof(CouleurZ), temp[8]));
                    toutLePersonnel.Add(Z);
                }
                else if (temp[0] == "Demon")
                {
                    Demon D = new Demon(Convert.ToInt32(temp[1]), temp[2], temp[3], (TypeSexe)Enum.Parse(typeof(TypeSexe), temp[4]), temp[5], Convert.ToInt32(temp[6]), temp[7], Convert.ToInt32(temp[8]));
                    toutLePersonnel.Add(D);
                }
                else if (temp[0] == "Fantome")
                {
                    Fantome F = new Fantome(Convert.ToInt32(temp[1]), temp[2], temp[3], (TypeSexe)Enum.Parse(typeof(TypeSexe), temp[4]), temp[5], Convert.ToInt32(temp[6]), temp[7]);
                    toutLePersonnel.Add(F);
                }
                else if (temp[0] == "LoupGarou")
                {
                    LoupGarou LG = new LoupGarou(Convert.ToInt32(temp[1]), temp[2], temp[3], (TypeSexe)Enum.Parse(typeof(TypeSexe), temp[4]), temp[5], Convert.ToInt32(temp[6]), temp[7], Convert.ToDouble(temp[8]));
                    toutLePersonnel.Add(LG);
                }
                else if (temp[0] == "RollerCoaster")
                {
                    RollerCoaster RC = new RollerCoaster(Convert.ToBoolean(temp[4]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[3]), temp[2], temp[5], Convert.ToInt32(temp[7]), (TypeCategorie)Enum.Parse(typeof(TypeCategorie), temp[6]), Convert.ToDouble(temp[8]));
                    attractions.Add(RC);
                }
                else if (temp[0] == "Spectacle")
                {
                    List <DateTime> listeTemp = new List <DateTime>();
                    string[]        temp2     = temp[8].Split(' ');
                    for (int k = 0; k < temp2.Length; k++)
                    {
                        listeTemp.Add(Convert.ToDateTime(temp2[k]));
                    }
                    Spectacle Sp = new Spectacle(Convert.ToBoolean(temp[4]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[3]), temp[2], temp[5], listeTemp, Convert.ToInt32(temp[7]), temp[6]);
                    attractions.Add(Sp);
                }
                else if (temp[0] == "DarkRide")
                {
                    DarkRide Dr = new DarkRide(Convert.ToBoolean(temp[4]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[3]), temp[2], temp[5], TimeSpan.Parse(temp[6]), Convert.ToBoolean(temp[7]));
                    attractions.Add(Dr);
                }
                else if (temp[0] == "Boutique")
                {
                    Boutique B = new Boutique(Convert.ToBoolean(temp[4]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[3]), temp[2], temp[5], (TypeBoutique)Enum.Parse(typeof(TypeBoutique), temp[6]));
                    AjouterAttraction((Attraction)B);
                }

                ligne = monStreamReader.ReadLine();
            }
            monStreamReader.Close();
            //Une fois que tout est créé on ajoute dans les attractions le personnel correspondant
            for (int i = 0; i < toutLePersonnel.Count(); i++)
            {
                for (int j = 0; j < attractions.Count(); j++)
                {
                    if (toutLePersonnel[i] is Monstre)
                    {
                        if ((toutLePersonnel[i] as Monstre).AFFECTATION == Convert.ToString(attractions[j].Identifiant))
                        {
                            attractions[j].AjouterEquipe(toutLePersonnel[i] as Monstre);
                        }
                    }
                }
            }
        }
コード例 #8
0
 //Ajoute un montre à l'attraction grâce aux propriétés de la liste
 public void AjouterEquipe(Monstre M)
 {
     equipe.Add(M);
 }
コード例 #9
0
 /// <summary>
 /// Affecte un monstre fourni a une attraction fournie
 /// </summary>
 /// <param name="toBeAffected">Monstre a affecter a l'attraction fournie</param>
 /// <param name="toAffectTo">Attraction a laquelle affecter le monstre fournie</param>
 public void Affecter(Monstre toBeAffected, Attraction toAffectTo)
 {
     toBeAffected.Affectation = toAffectTo;
 }
コード例 #10
0
        /// <summary>
        /// Lis un ficher dont le chemin est fourni et en interprete le contenu en creant les personnels et attractions decrit en format CSV
        /// </summary>
        /// <param name="chemin">chemin relatif du fichier a lire</param>
        public void ReadCSV(string chemin)
        {
            try
            {
                StreamReader monStreamReader = new StreamReader(chemin);
                string       ligne;
                while ((ligne = monStreamReader.ReadLine()) != null)
                {
                    string[] temp  = ligne.Split(';');
                    int      temp1 = Int32.Parse(temp[1]);
                    if (temp[0] == "Sorcier")
                    {
                        string[]      listeValues = temp[7].Split('-');
                        List <string> powers      = new List <string>();
                        foreach (string value in listeValues)
                        {
                            powers.Add(value);
                        }
                        Sorcier so = new Sorcier(temp1, temp[2], temp[3], temp[4], temp[5], temp[6], powers);
                        AjoutPersonnel(so);
                    }
                    else if (temp[0] == "Boutique" || temp[0] == "RollerCoaster" || temp[0] == "DarkRide" || temp[0] == "Spectacle")
                    {
                        int  temp3 = Int32.Parse(temp[3]);
                        bool temp4 = Boolean.Parse(temp[4]);
                        switch (temp[0])
                        {
                        case "Boutique":
                            Boutique b;
                            if (temp4)
                            {
                                b = new Boutique(temp1, temp[2], temp3, temp4, temp[5], temp[6]);
                            }
                            else
                            {
                                b = new Boutique(temp1, temp[2], temp3, temp4, "", temp[6]);
                            }
                            AjoutAttraction(b);;
                            break;

                        case "RollerCoaster":
                            int           temp7_rc = Int32.Parse(temp[7]);
                            float         temp8_rc = float.Parse(temp[8]);
                            RollerCoaster rc       = new RollerCoaster(temp1, temp[2], temp3, temp4, temp[5], temp[6], temp7_rc, temp8_rc);
                            AjoutAttraction(rc);
                            break;

                        case "Spectacle":
                            int             temp7_s   = Int32.Parse(temp[7]);
                            List <DateTime> tempList  = new List <DateTime>();
                            string[]        listeDate = temp[8].Split(' ');
                            foreach (string value in listeDate)
                            {
                                tempList.Add(DateTime.Parse(value));
                            }
                            Spectacle sp = new Spectacle(temp1, temp[2], temp3, temp4, temp[5], temp[6], temp7_s, tempList);
                            AjoutAttraction(sp);
                            break;

                        case "DarkRide":
                            TimeSpan temp6_d = TimeSpan.Parse(temp[6]);
                            bool     temp7_d = Boolean.Parse(temp[7]);
                            DarkRide dr      = new DarkRide(temp1, temp[2], temp3, temp4, temp[5], temp6_d, temp7_d);
                            AjoutAttraction(dr);
                            break;
                        }
                    }
                    else
                    {
                        int temp6 = Int32.Parse(temp[6]);
                        int temp7;
                        try
                        {
                            temp7 = Int32.Parse(temp[7]);
                        }
                        catch (FormatException)
                        {
                            temp7 = -1;
                        }
                        switch (temp[0])
                        {
                        case "Monstre":
                            foreach (Attraction i in attractions)
                            {
                                if (i.Id == temp7)
                                {
                                    Monstre m = new Monstre(temp1, temp[2], temp[3], temp[4], temp[5], temp6, i);
                                    AjoutPersonnel(m);
                                }
                            }
                            if (temp7 == -1)
                            {
                                Monstre m = new Monstre(temp1, temp[2], temp[3], temp[4], temp[5], temp6, null);
                                AjoutPersonnel(m);
                            }
                            break;

                        case "Demon":
                            int temp8;
                            try
                            {
                                temp8 = Int32.Parse(temp[8]);
                            }
                            catch (FormatException)
                            {
                                temp8 = -1;
                            }
                            foreach (Attraction i in attractions)
                            {
                                if (i.Id == temp7)
                                {
                                    Demon d = new Demon(temp1, temp[2], temp[3], temp[4], temp[5], temp6, i, temp8);
                                    //Console.WriteLine(d.ToString());
                                    AjoutPersonnel(d);
                                }
                            }
                            if (temp7 == -1)
                            {
                                Demon d = new Demon(temp1, temp[2], temp[3], temp[4], temp[5], temp6, null, temp8);
                                //Console.WriteLine(d.ToString());
                                AjoutPersonnel(d);
                            }
                            break;

                        case "Fantome":
                            foreach (Attraction i in attractions)
                            {
                                if (i.Id == temp7)
                                {
                                    Fantome f = new Fantome(temp1, temp[2], temp[3], temp[4], temp[5], temp6, i);
                                    AjoutPersonnel(f);
                                }
                            }
                            if (temp7 == -1)
                            {
                                Fantome f = new Fantome(temp1, temp[2], temp[3], temp[4], temp[5], temp6, null);
                                AjoutPersonnel(f);
                            }
                            break;

                        case "Zombie":
                            int temp9;
                            try
                            {
                                temp9 = Int32.Parse(temp[9]);
                            }
                            catch (FormatException)
                            {
                                temp9 = -1;
                            }
                            foreach (Attraction i in attractions)
                            {
                                if (i.Id == temp7)
                                {
                                    Zombie z = new Zombie(temp1, temp[2], temp[3], temp[4], temp[5], temp6, i, temp[8], temp9);
                                    AjoutPersonnel(z);
                                }
                            }
                            if (temp7 == -1)
                            {
                                Zombie z = new Zombie(temp1, temp[2], temp[3], temp[4], temp[5], temp6, null, temp[8], temp9);
                                AjoutPersonnel(z);
                            }
                            break;

                        case "Vampire":
                            float temp8_v;
                            try
                            {
                                temp8_v = float.Parse(temp[8]);
                            }
                            catch (FormatException)
                            {
                                temp8_v = -1;
                            }
                            foreach (Attraction i in attractions)
                            {
                                if (i.Id == temp7)
                                {
                                    Vampire v = new Vampire(temp1, temp[2], temp[3], temp[4], temp[5], temp6, i, temp8_v);
                                    AjoutPersonnel(v);
                                }
                            }
                            if (temp7 == -1)
                            {
                                Vampire v = new Vampire(temp1, temp[2], temp[3], temp[4], temp[5], temp6, null, temp8_v);
                                AjoutPersonnel(v);
                            }
                            break;

                        case "LoupGarou":
                            float temp8_lg;
                            try
                            {
                                temp8_lg = float.Parse(temp[8]);
                            }
                            catch (FormatException)
                            {
                                temp8_lg = -1;
                            }
                            foreach (Attraction i in attractions)
                            {
                                if (i.Id == temp7)
                                {
                                    LoupGarou lg = new LoupGarou(temp1, temp[2], temp[3], temp[4], temp[5], temp6, i, temp8_lg);
                                    AjoutPersonnel(lg);
                                }
                            }
                            if (temp7 == -1)
                            {
                                LoupGarou lg = new LoupGarou(temp1, temp[2], temp[3], temp[4], temp[5], temp6, null, temp8_lg);
                                AjoutPersonnel(lg);
                            }
                            break;
                        }
                    }
                }
                monStreamReader.Close();
            }
            catch (Exception)
            {
                Console.WriteLine("Fichier corrompu");
            }
        }