public void Creation_List_Match(Equipe_competition equipe_b) { Random generateur = new Random(); if (Assez_de_joueur() == true) { for (int n = 0; n < nb_match; n++) { int nb = generateur.Next(1, equipe_b.List_joueur_equipe.Count()); int na = generateur.Next(1, this.Liste_joueur_ok.Count()); Match_simple ma = new Match_simple(equipe_b.Liste_joueur_ok[nb], this.Liste_joueur_ok[na]); Liste_match_simple.Add(ma); } } foreach (Match_simple m in Liste_match_simple) { int res = generateur.Next(0, 1); if (res == 1) { m.Joueur_a.Nb_match_jouer++; m.Joueur_b.Nb_match_jouer++; m.Joueur_a.Nb_match_gagner++; } } }
public void Creation_List_Match(Equipe_competition equipe_b) { Random generateur = new Random(); if (Assez_de_joueur() == true) { for (int n = 0; n < nb_match_simple; n++) { int nb = generateur.Next(1, equipe_b.List_joueur_equipe.Count()); int na = generateur.Next(1, this.Liste_joueur_ok.Count()); Match_simple ma_s = new Match_simple(equipe_b.Liste_joueur_ok[nb], this.Liste_joueur_ok[na]); Liste_match_simple.Add(ma_s); equipe_b.Liste_joueur_ok.Remove(equipe_b.Liste_joueur_ok[nb]); this.Liste_joueur_ok.Remove(this.Liste_joueur_ok[na]); } for (int a = 0; a < nb_match_double; a++) { int nb1 = generateur.Next(1, equipe_b.List_joueur_equipe.Count()); int na1 = generateur.Next(1, this.Liste_joueur_ok.Count()); int nb2 = generateur.Next(1, equipe_b.List_joueur_equipe.Count()); int na2 = generateur.Next(1, this.Liste_joueur_ok.Count()); if ((nb1 != nb2) && (nb1 != na2)) { List <Joueur_competition> l_j1 = new List <Joueur_competition>(); l_j1.Add(equipe_b.Liste_joueur_ok[nb1]); l_j1.Add(equipe_b.Liste_joueur_ok[nb2]); List <Joueur_competition> l_j2 = new List <Joueur_competition>(); l_j2.Add(this.Liste_joueur_ok[na1]); l_j2.Add(this.Liste_joueur_ok[na2]); Equipe_competition eq1 = new Equipe_competition(l_j1); Equipe_competition eq2 = new Equipe_competition(l_j2); Match_double ma_d = new Match_double(eq1, eq2); equipe_b.Liste_joueur_ok.Remove(equipe_b.Liste_joueur_ok[nb1]); equipe_b.Liste_joueur_ok.Remove(equipe_b.Liste_joueur_ok[nb2]); this.Liste_joueur_ok.Remove(this.Liste_joueur_ok[na1]); this.Liste_joueur_ok.Remove(this.Liste_joueur_ok[na2]); Liste_match_double.Add(ma_d); } } } foreach (Match_simple m in Liste_match_simple) { int res = generateur.Next(0, 1); if (res == 1) { m.Joueur_a.Nb_match_jouer++; m.Joueur_b.Nb_match_jouer++; m.Joueur_a.Nb_match_gagner++; } else { m.Joueur_a.Nb_match_jouer++; m.Joueur_b.Nb_match_jouer++; m.Joueur_b.Nb_match_gagner++; } } foreach (Match_double m_d in Liste_match_double) { int res = generateur.Next(0, 1); if (res == 1) { m_d.Equipe_a.List_joueur_equipe[0].Nb_match_gagner++; m_d.Equipe_a.List_joueur_equipe[1].Nb_match_gagner++; m_d.Equipe_a.List_joueur_equipe[0].Nb_match_jouer++; m_d.Equipe_a.List_joueur_equipe[0].Nb_match_jouer++; m_d.Equipe_b.List_joueur_equipe[0].Nb_match_jouer++; m_d.Equipe_b.List_joueur_equipe[0].Nb_match_jouer++; } else { m_d.Equipe_b.List_joueur_equipe[0].Nb_match_gagner++; m_d.Equipe_b.List_joueur_equipe[1].Nb_match_gagner++; m_d.Equipe_a.List_joueur_equipe[0].Nb_match_jouer++; m_d.Equipe_a.List_joueur_equipe[0].Nb_match_jouer++; m_d.Equipe_b.List_joueur_equipe[0].Nb_match_jouer++; m_d.Equipe_b.List_joueur_equipe[0].Nb_match_jouer++; } } }
public Match_double() { this.equipe_a = null; this.equipe_b = null; this.score = null; }
public Match_double(Equipe_competition a, Equipe_competition b) { this.equipe_a = a; this.equipe_b = b; }
private void Button_Click(object sender, RoutedEventArgs e) { string fichier_compet_simple = "compet_individuel.txt"; StreamWriter lire = null; string l = lieu.Text; string n = nom_compet.Text; int min = int.Parse(nbre_min_joueur.Text); int max = int.Parse(classement_max.Text); string participant = liste_participant_equipe1.Text; string adversaire = liste_participant_equipe2.Text; int jour = int.Parse(nbre_jour.Text); int match = int.Parse(nbre_match.Text); int anne_min = int.Parse(annee_min.Text); int anne_max = int.Parse(annee_max.Text); int jou = int.Parse(jourr.Text); int moi = int.Parse(moiss.Text); int ann = int.Parse(anneee.Text); DateTime date = new DateTime(ann, moi, jou); List <Joueur_competition> list = new List <Joueur_competition>(); string[] list_j = participant.Split('/'); string[] list_ad = adversaire.Split('/'); List <Joueur_competition> list_j_c = Liste_joueur_compet(); List <Joueur_competition> list_adv = new List <Joueur_competition>(); foreach (string nom in list_j) { foreach (Joueur_competition j in list_j_c) { if (nom == j.Nom) { list.Add(j); } } } foreach (string name in list_ad) { Joueur_competition joueur = new Joueur_competition(name); list_adv.Add(joueur); } Equipe_competition eq = new Equipe_competition(list_adv); Competition_simple compet_s = new Competition_simple(match, l, list, jour, n, max, min, anne_min, anne_max, date); lire = new StreamWriter(fichier_compet_simple, true); if (compet_s.Assez_de_joueur()) { compet_s.Creation_List_Match(eq); compet_s.Compatibilite_age(); } //On verifie que les joueurs peuvent bien jouer et doncc on creer la nouvelle liste des joueurs string affichage = ""; foreach (Joueur_competition j in compet_s.Liste_joueur_ok) { affichage += (j.Nom + "/"); } lire.Write("\n" + l + "," + n + "," + min + "," + max + "," + affichage + "," + jour + "," + match + "," + anne_min + "/" + anne_max + "," + jou + "/" + moi + "/" + ann); lire.Close(); Ca_marche a = new Ca_marche(); a.Show(); this.Close(); }