Example #1
0
 public Lancer(DeGenerique d, int n)
 {
     De = d;
     nblancers = n;
     Lancers = new int[n];
     resultat = 0;
 }
Example #2
0
 public Lancer(DeGenerique d, int n)
 {
     De        = d;
     nblancers = n;
     Lancers   = new int[n];
     resultat  = 0;
 }
 public void calcul()
 {
     if (face == 0)
     {
         MessageBox.Show("Vous n'avez pas choisi de dé.");
     }
     else
     {
         if (verif_nb(nb_des.Text))
         {
             if (obj_text.Text != "")
             {
                 jeu();
             }
             if (verif_jeu)
             {
                 DeGenerique dg = new DeGenerique(face);
                 Lancer l = new Lancer(dg, int.Parse(nb_des.Text));
                 l.roll();
                 Thread.Sleep(1500);
                 journal.maj(l);
                 for (int i = 0; i < l.Lancers.Length - 1; i++)
                 {
                     show += l.Lancers[i] + " + ";
                 }
                 show += l.Lancers[l.Lancers.Length - 1] + " = " + l.resultat + " .";
                 if (obj_text.Text != "")
                 {
                     Jeu j = new Jeu(int.Parse(obj_text.Text), Condition, l);
                     j.ResultatJeu();
                 }
                 AffRes.Invoke((Action)(() =>
                 {
                     AffRes.Text = show;
                     Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                 }));
             }
             else
             {
                 Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                 verif_jeu = true;
             }
         }
         else
         {
             MessageBox.Show("Vérifiez le nombre de dés que vous avez entré.");
         }
     }
 }
 public void calcul()
 {
     if (face == 0)
     {
         MessageBox.Show("Vous n'avez pas choisi de dé.");
     }
     else
     {
         if (verif_nb(nb_des.Text))
         {
             if (obj_text.Text != "")
             {
                 jeu();
             }
             if (verif_jeu)
             {
                 DeGenerique dg = new DeGenerique(face);
                 Lancer      l  = new Lancer(dg, int.Parse(nb_des.Text));
                 l.roll();
                 Thread.Sleep(1500);
                 journal.maj(l);
                 for (int i = 0; i < l.Lancers.Length - 1; i++)
                 {
                     show += l.Lancers[i] + " + ";
                 }
                 show += l.Lancers[l.Lancers.Length - 1] + " = " + l.resultat + " .";
                 if (obj_text.Text != "")
                 {
                     Jeu j = new Jeu(int.Parse(obj_text.Text), Condition, l);
                     j.ResultatJeu();
                 }
                 AffRes.Invoke((Action)(() =>
                 {
                     AffRes.Text = show;
                     Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                 }));
             }
             else
             {
                 Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                 verif_jeu   = true;
             }
         }
         else
         {
             MessageBox.Show("Vérifiez le nombre de dés que vous avez entré.");
         }
     }
 }
        private void jeu_421_Click(object sender, EventArgs e)
        {
            DeGenerique dg       = new DeGenerique(6);
            bool        victoire = false;

            while (!victoire)
            {
                Lancer l = new Lancer(dg, 3);
                l.roll();
                journal.maj(l);
                if (l.Lancers[0] == 4 || l.Lancers[1] == 4 || l.Lancers[2] == 4)
                {
                    if (l.Lancers[0] == 2 || l.Lancers[1] == 2 || l.Lancers[2] == 2)
                    {
                        if (l.Lancers[0] == 1 || l.Lancers[1] == 1 || l.Lancers[2] == 1)
                        {
                            victoire = true;
                            show     = "Félicitations! Vous avez gagné!";
                        }
                        else
                        {
                            show = "Loupé! Au joueur suivant! Votre résultat: " + l.Lancers[0] + " " + l.Lancers[1] + " " + l.Lancers[2];
                        }
                    }
                    else
                    {
                        show = "Loupé! Au joueur suivant! Votre résultat: " + l.Lancers[0] + " " + l.Lancers[1] + " " + l.Lancers[2];
                    }
                }
                else
                {
                    show = "Loupé! Au joueur suivant! Votre résultat: " + l.Lancers[0] + " " + l.Lancers[1] + " " + l.Lancers[2];
                    //}
                    //Thread.Sleep(2500);
                    //AffRes.Invoke((Action)(() =>
                    //{
                    //    AffRes.Text = show;
                    //    Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                    //}));
                }
                DialogResult dialogResult = MessageBox.Show(show, "421", MessageBoxButtons.OKCancel);
                if (dialogResult == DialogResult.Cancel)
                {
                    victoire = true;
                }
            }
        }
        private void jeter_Click(object sender, EventArgs e)
        {
            System.Timers.Timer waiter = new System.Timers.Timer();
            waiter.Interval = 5000;
            show            = "";
            Lancer l;

            if (piped_values.Text == "")
            {
                if (face == 4)
                {
                    Jeter.Image = Resource.d4_gif;
                }
                Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                DeGenerique dg = new DeGenerique(face);
                l = new Lancer(dg, int.Parse(nb_des.Text));
                l.roll();
                journal.maj(l);
                for (int i = 0; i < l.Lancers.Length - 1; i++)
                {
                    show += l.Lancers[i] + " + ";
                }
                show       += l.Lancers[l.Lancers.Length - 1] + " = " + l.resultat + " .";
                AffRes.Text = show;
            }
            else
            {
                String[] val_pip  = piped_values.Text.Split(';');
                int[]    temp_val = new int[val_pip.Length];
                for (int i = 0; i < val_pip.Length; i++)
                {
                    temp_val[i] = int.Parse(val_pip[i]);
                }
                DePipe dp = new DePipe(temp_val.Length, temp_val);
                l = new Lancer(dp, int.Parse(nb_des.Text));
                l.roll();
                journal.maj(l);
                for (int i = 0; i < l.Lancers.Length; i++)
                {
                    if (i < l.Lancers.Length - 1)
                    {
                        show += l.Lancers[i] + " + ";
                    }
                }
                show       += l.Lancers[l.Lancers.Length - 1] + " = " + l.resultat + " .";
                AffRes.Text = show;
            }

            if (obj_text.Text != "")
            {
                Jeu j = new Jeu(int.Parse(obj_text.Text), Condition, l);
                j.ResultatJeu();
            }

            //show="" ;
            //sum = 0;
            //for(int i = 0; i < results.Length-1; i++)
            //{
            //    results[i] = randy.Next(1, face);
            //    show += results[i] + " + ";
            //    sum +=  results[i];
            //}
            //results[results.Length - 1] = randy.Next(1, face);
            //show += results[results.Length - 1] + " = ";
            //sum += results[results.Length - 1];
            //show += sum + " .";
            //textBox1.Text = show;
        }
        private void jeu_421_Click(object sender, EventArgs e)
        {
            DeGenerique dg = new DeGenerique(6);
            bool victoire = false;
            while (!victoire)
            {
                Lancer l = new Lancer(dg, 3);
                l.roll();
                journal.maj(l);
                if (l.Lancers[0] == 4 || l.Lancers[1] == 4 || l.Lancers[2] == 4)
                {
                    if (l.Lancers[0] == 2 || l.Lancers[1] == 2 || l.Lancers[2] == 2)
                    {
                        if (l.Lancers[0] == 1 || l.Lancers[1] == 1 || l.Lancers[2] == 1)
                        {
                            victoire = true;
                            show = "Félicitations! Vous avez gagné!";
                        }
                        else
                        {
                            show = "Loupé! Au joueur suivant! Votre résultat: " + l.Lancers[0] + " " + l.Lancers[1] + " " + l.Lancers[2];
                        }

                    }
                    else
                    {
                        show = "Loupé! Au joueur suivant! Votre résultat: " + l.Lancers[0] + " " + l.Lancers[1] + " " + l.Lancers[2];
                    }

                }
                else
                {
                    show = "Loupé! Au joueur suivant! Votre résultat: " + l.Lancers[0] + " " + l.Lancers[1] + " " + l.Lancers[2];
                    //}
                    //Thread.Sleep(2500);
                    //AffRes.Invoke((Action)(() =>
                    //{
                    //    AffRes.Text = show;
                    //    Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                    //}));
                }
                DialogResult dialogResult = MessageBox.Show(show, "421", MessageBoxButtons.OKCancel);
                if (dialogResult == DialogResult.Cancel)
                {
                    victoire = true;
                }
            }
        }
        private void jeter_Click(object sender, EventArgs e)
        {
            System.Timers.Timer waiter = new System.Timers.Timer();
            waiter.Interval=5000;
            show = "";
            Lancer l;
            if (piped_values.Text == "")
            {
                if(face==4)
                {
                    Jeter.Image = Resource.d4_gif;
                }
                Jeter.Image = Resource.dice_game_gamble_roll_label_64;
                DeGenerique dg = new DeGenerique(face);
                l = new Lancer(dg, int.Parse(nb_des.Text));
                l.roll();
                journal.maj(l);
                for(int i = 0; i < l.Lancers.Length-1; i++)
                {
                    show += l.Lancers[i] + " + ";
                }
                show += l.Lancers[l.Lancers.Length-1] + " = " + l.resultat + " .";
                AffRes.Text = show;
            }
            else
            {
                String[] val_pip = piped_values.Text.Split(';');
                int[] temp_val = new int[val_pip.Length];
                for (int i = 0; i < val_pip.Length;i++)
                {
                    temp_val[i] = int.Parse(val_pip[i]);
                }
                DePipe dp = new DePipe(temp_val.Length, temp_val);
                l = new Lancer(dp, int.Parse(nb_des.Text));
                l.roll();
                journal.maj(l);
                for (int i = 0; i < l.Lancers.Length; i++)
                {
                    if(i< l.Lancers.Length - 1)
                    {
                        show += l.Lancers[i] + " + ";
                    }
                }
                show += l.Lancers[l.Lancers.Length - 1] + " = " + l.resultat + " .";
                AffRes.Text = show;

            }

            if (obj_text.Text != "")
            {
                Jeu j = new Jeu(int.Parse(obj_text.Text), Condition, l);
                j.ResultatJeu();
            }

            //show="" ;
            //sum = 0;
            //for(int i = 0; i < results.Length-1; i++)
            //{
            //    results[i] = randy.Next(1, face);
            //    show += results[i] + " + ";
            //    sum +=  results[i];
            //}
            //results[results.Length - 1] = randy.Next(1, face);
            //show += results[results.Length - 1] + " = ";
            //sum += results[results.Length - 1];
            //show += sum + " .";
            //textBox1.Text = show;
        }