Exemplo n.º 1
0
        private void btnValider_Click(object sender, EventArgs e)
        {
            if (IsChampsValid() == true)
            {
                Joueur joueur = new Joueur();
                joueur.Pseudo = tbPseudo.Text;
                listeJoueurs.Add(joueur);
                Serialisation.SaveJson(@"C:\Windows\Temp\Toplayers.json", listeJoueurs);
                DialogResult result = MessageBox.Show("Félicitations, vous faites désormais partie\n" +
                                                      "du Top 10 des meilleurs joueurs de tous les temps.\n" +
                                                      "Souhaitez-vous refaire une partie?", "////***Congratulations!!!***\\\\",
                                                      MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    tbPseudo.Clear();
                    tbScore.Clear();

                    //Faudrait faire un gestionnaire de contextes qui renvoie au menu principal du jeu
                }
                else
                {
                    this.Close();
                    interface_Victoire.ActiveForm.Close();
                }
            }
        }
Exemplo n.º 2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                Mots mots = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsFacileJson.json", typeof(Mots));

                mot = Mots.ChargerMot(mots);
            }
            else if (radioButton2.Checked)
            {
                Mots mots = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsDifficileJson.json", typeof(Mots));

                mot = Mots.ChargerMot(mots);
            }
            else if (radioButton3.Checked)
            {
                Mots mots = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsExpertJson.json", typeof(Mots));


                mot = Mots.ChargerMot(mots);
            }

            if (joueur.NbManchesRemportees == 0)
            {
                CreationTimer();
            }

            timer.Start();
            textBox2.Text = joueur.NbManchesRemportees.ToString();
            GestionnaireContextes(Contextes.GameStarted);
            //DateTime TpsDebut = TempsDebut();
            btnStart.Enabled = false;

            joueur.NbEssaiRestant = 7;
            tbNbrEssais.Text      = joueur.NbEssaiRestant.ToString();


            //essai pour charger mot aleatoire à partir du hashset d'essai
            // Random aleatoire = new Random();
            // int index=aleatoire.Next(0, 5);
            // string LeMot = HashSetEssai.ElementAt(index);
            // mot.MotInitial = LeMot.ToUpper();
            tbMotADeviner.Text = mot.MettreTirets(mot.MotInitial);

            //FinEssai
        }
Exemplo n.º 3
0
        //    else
        //    {
        //        MessageBox.Show("Mot entré dans le lexique incorrect", "Erreur!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //    }



        //}

        //private void tbMot_Validating(object sender, CancelEventArgs e)
        //{
        //    mot.Texte = tbMot.Text;
        //    if (!Mot.IsMotValideFacile(tbMot.Text))
        //    {
        //        epLexique.SetError(btnValider, "Mot invalide");
        //    }
        //    else
        //    {
        //        epLexique.SetError(btnValider, string.Empty);
        //    }

        //}
        public void SerializeAll()
        {
            Serialisation.SaveJson(@"C:\Windows\Temp\MotsFacileJson.json", motsFacile);
            Serialisation.SaveJson(@"C:\Windows\Temp\MotsDifficileJson.json", motsDifficile);
            Serialisation.SaveJson(@"C:\Windows\Temp\MotsExpertJson.json", motsExpert);
        }
Exemplo n.º 4
0
        //public static void ChargerMots()
        //{
        //    Random rand = new Random();
        //    if (joueur.Niveaudifficulte == "Facile")
        //    {

        //        int index = rand.Next(motsFacile.Count);
        //        Mot mot = motsFacile.ElementAt(index);
        //       // tbEssai.Text = mot.MotInitial;
        //    }
        //    else if (joueur.Niveaudifficulte == "Difficile")
        //    {

        //        int index = rand.Next(motsDifficile.Count);
        //        Mot mot = motsDifficile.ElementAt(index);
        //      //  tbEssai.Text = mot.MotInitial;
        //    }
        //    else if (joueur.Niveaudifficulte == "Expert")
        //    {
        //        int index = rand.Next(motsExpert.Count);
        //        Mot mot = motsExpert.ElementAt(index);
        //      //  tbEssai.Text = mot.MotInitial;
        //    }


        //}
        public void DeserializeAll()
        {
            motsFacile    = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsFacileJson.json", typeof(Mots));
            motsDifficile = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsDifficileJson.json", typeof(Mots));
            motsExpert    = (Mots)Serialisation.LoadJson(@"C:\Windows\Temp\MotsExpertJson.json", typeof(Mots));
        }