Beispiel #1
0
        /// <summary>
        /// Affiche un texte d'encouragement si un score de mot est atteint.
        /// </summary>
        private void Encourage()
        {
            int score = DataGame.GetScoreMotJoueur();

            if (score >= 6 && score < 8)
            {
                this.labEncouragement.Text = "Beau!";
            }

            if (score >= 8 && score < 10)
            {
                this.labEncouragement.Text = "Superbe!";
            }

            if (score >= 10 && score < 12)
            {
                this.labEncouragement.Text = "GENIAL!";
            }

            if (score >= 12 && score <= 50)
            {
                this.labEncouragement.Text = "Exeptionnel!";
            }

            if (DataGame.ScoreTotal >= this.ScoreMaxi() / 2)
            {
                this.labEncouragement2.Text = "Super moitié du score atteinte.";
            }
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string t;
            int    cpt = 0;

            this.labEncouragement.Text  = string.Empty;
            this.labEncouragement2.Text = string.Empty;

            for (int j = 0; j < 4; j++)
            {
                // Création des LABEL  de la grille
                for (int i = 0; i < 4; i++)
                {
                    cpt++;
                    int     pas = 60;
                    LAbelXY l   = new LAbelXY();
                    {
                        l.Font   = new System.Drawing.Font("Microsoft Sans Serif", 14F, FontStyle.Bold, GraphicsUnit.Point, (byte)0);
                        l.Parent = this;
                    }

                    l.Click    += new EventHandler(this.LetterIsChoosen);
                    t           = cpt.ToString();
                    l.Text      = t;
                    l.Name      = t;
                    l.Width     = pas - 20;
                    l.Height    = pas - 20;
                    l.Top       = 20 + (j * pas);
                    l.Left      = 20 + (i * pas);
                    l.ForeColor = this.defaultColor;
                    l.X         = i;
                    l.Y         = j;
                    l.Show();
                }
            }

            DataGame.ResetWordScore();
            DataGame.RazScoreTotal();

            // Pour la contruction d'un arbre des lettres à partir de la liste des mots français
            LoadWordsDictionnary.InitialiseEnvironnement();
            if (LoadWordsDictionnary.GetAuthorizationStatus())
            {
                DonneesLettres.MatrixIniialization();
                this.NewGame();
            }
            else
            {
                _ = MessageBox.Show(
                    "Erreur à l'ouverture du dictionnaire des mots Français\r\n" +
                    " Verifiez si le fichier MOTS TRADUITS.txt est présent sous le même répertoire que celui\r\n" +
                    " de l'application.", "Erreur fatale.", buttons: MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Application.Exit();
            }

            this.PossibleWordsInTextbox2();
        }
Beispiel #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     // Réalise un nouveau tirage de lettres et configure l'IHM
     this.textBox2.Clear();
     this.textBox1.Clear();
     DataGame.ResetWordScore();
     DataGame.ResetNumberOfGoodWord();
     this.NewGame();
     this.DrawMatrix();
 }
Beispiel #4
0
 private void BoutonVerifMot(object sender, EventArgs e)
 {
     this.VerifMot();
     this.labNmotsTrouves.Text = "Nombre de mots trouvés = " + DataGame.GetNumberOfGoodWord().ToString()
                                 + " sur " + this.possibleWords.Count;
     this.textBox1.Clear();
     DataGame.ResetWordScore();
     this.labScoreMotJoueur.Text = string.Empty;
     this.DrawMatrix();
 }
Beispiel #5
0
        // Vérifie si le mot à controler n'est pas un mot déjà utilisé
        private void VerifMot()
        {
            Form1 form1 = this;

            if (WordsTree.WordExists(form1.textBox1.Text, LoadWordsDictionnary.NoeudRacine))
            { // le mot proposé par joueur existe
                bool motDejaUtilise = false;
                for (int i = 0; i < form1.findedWordList.Count; i++)
                {
                    if (form1.findedWordList[i] == form1.textBox1.Text)
                    {
                        motDejaUtilise                  = true;
                        form1.ImageTriste.Visible       = true;
                        form1.labNotification.ForeColor = Color.FromName("Red");
                        form1.labNotification.Text      = "Mot déja choisi";
                        form1.DrawMatrix();
                        i = form1.findedWordList.Count;
                    }
                }

                if (motDejaUtilise == false)
                {
                    form1.ImageGai.Visible    = true;
                    form1.ImageTriste.Visible = false;
                    DataGame.ActualiseScoreTotal(DataGame.GetScoreMotJoueur());
                    this.Encourage();
                    DataGame.IncrementeNumberOfGoddWord();
                    form1.progressBar1.Value = DataGame.ScoreTotal;
                    form1.labScoreTotal.Text = DataGame.ScoreTotal.ToString();
                    form1.findedWordList.Add(form1.textBox1.Text);
                }
                else
                {
                    form1.ImageGai.Visible    = false;
                    form1.ImageTriste.Visible = true;
                }
            }
            else
            {
                form1.ImageTriste.Visible = true;
            }

            // met le mot trouvé entre parenthèse dans la liste des mots
            for (int i = 0; i < form1.possibleWords.Count; i++)
            {
                if (form1.possibleWords[i] == form1.textBox1.Text)
                {
                    form1.possibleWords[i] = "(" + form1.textBox1.Text + ")";
                    i = form1.possibleWords.Count;
                }
            }

            form1.AfficheMotsPossibles();
        }
Beispiel #6
0
 private void UpdateWordScore(char c)
 {
     for (int i = 0; i < DonneesLettres.Alphabet.Length - 1; i++)
     {
         if (DonneesLettres.Alphabet[i] == c)
         {
             // caractère identifié
             DataGame.UpdatePlayerScore(DonneesLettres.PointArrayForAletter[i]);
             this.labScoreMotJoueur.Text = DataGame.GetScoreMotJoueur().ToString();
         }
     }
 }
Beispiel #7
0
        /// <summary>
        /// Réalise un nouveau tirage de lettres.
        /// </summary>
        private void NewGame()
        {
            this.findedWordList.Clear();
            this.textBox2.Clear();
            DataGame.ResetWordScore();
            DataGame.RazScoreTotal();
            this.labScoreMotJoueur.Text = "Score du mot";
            this.labScoreTotal.Text     = "Score de la partie.";
            this.CreateMatrix();
            this.DrawMatrix();
            WordsInGrid solver = new WordsInGrid();

            this.possibleWords      = solver.ExploreCellWay();
            this.lab_scoreMaxi.Text = "SCORE MAXIMAL : " + this.ScoreMaxi();
            this.possibleWords.Sort();
            this.PossibleWordsInTextbox2();
        }