|
|
|
@ -17,7 +17,7 @@ namespace ConsoleApp
|
|
|
|
|
/// <param name="e">L'instance de l'événement DemanderNomEventArgs créée par Partie.</param>
|
|
|
|
|
/// <returns>Le nom du joueur.</returns>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void DemanderNom(Object? sender, PartieDemanderJoueurEventArgs e)
|
|
|
|
|
public static void DemanderNom(object? sender, PartieDemanderJoueurEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Joueur {e.Indice}");
|
|
|
|
|
Console.Write(">>> ");
|
|
|
|
@ -26,7 +26,10 @@ namespace ConsoleApp
|
|
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
|
|
|
|
e.JoueurDemande.SeConnecter(!string.IsNullOrEmpty(nom) ? Program.Manageur.DemanderJoueur(nom) : new Joueur($"Joueur {e.Indice}"));
|
|
|
|
|
Joueur joueur = !string.IsNullOrEmpty(nom) ? Program.Manageur.DemanderJoueur(nom) : new Robot();
|
|
|
|
|
joueur.JoueurJouer += JoueurJouer;
|
|
|
|
|
|
|
|
|
|
e.JoueurDemande.SeConnecter(joueur);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -35,46 +38,50 @@ namespace ConsoleApp
|
|
|
|
|
/// <param name="sender">La classe qui appelle l'événement; ici Partie.</param>
|
|
|
|
|
/// <param name="e">L'instance de l'événement DebutPartieEventArgs créée par Partie.</param>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void CommencerLaPartie(Object? sender, PartieDebutPartieEventArgs e)
|
|
|
|
|
public static void CommencerLaPartie(object? sender, PartieDebutPartieEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Utils.DessinerSeparateur();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("La partie commence, bonne chance à tous !\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ecoute l'événement en rapport avec un nouveau tour.
|
|
|
|
|
/// <param name="sender">La classe qui appelle l'événement; ici Partie.</param>
|
|
|
|
|
/// <param name="e">L'instance de l'événement NouveauTourEventArgs créée par Partie.</param>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void NouveauTour(Object? sender, PartieNouveauTourEventArgs e)
|
|
|
|
|
public static void JoueurJouer(object? sender, JoueurJouerEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Utils.DessinerSeparateur();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"Tour {e.Tour} - {e.Joueur.Nom}\n");
|
|
|
|
|
Console.WriteLine($"{e.Nom} - Tour {e.Tour}\n");
|
|
|
|
|
|
|
|
|
|
(IReadOnlyList<IReadOnlyList<Jeton>> codes, IReadOnlyList<IReadOnlyList<Indicateur>> indicateurs) = e.Plateau.Grille;
|
|
|
|
|
Utils.DessinerPlateau(e.Plateau);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
foreach(Jeton jeton in e.Code.Jetons)
|
|
|
|
|
Utils.DessinerPion(jeton.Couleur);
|
|
|
|
|
|
|
|
|
|
Code code = e.Code;
|
|
|
|
|
while(!code.Complet)
|
|
|
|
|
while (!e.Code.Complet)
|
|
|
|
|
{
|
|
|
|
|
Jeton? jeton = Utils.SaisirJeton(code.Taille);
|
|
|
|
|
Jeton? jeton = Utils.SaisirJeton(e.Code.Taille);
|
|
|
|
|
|
|
|
|
|
if (jeton.HasValue)
|
|
|
|
|
{
|
|
|
|
|
e.Code.AjouterJeton(jeton.Value);
|
|
|
|
|
Utils.DessinerPion(jeton.Value.Couleur);
|
|
|
|
|
code.AjouterJeton(jeton.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.Code.SupprimerDernierJeton();
|
|
|
|
|
Utils.SupprimerDernierJeton();
|
|
|
|
|
code.SupprimerDernierJeton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.Plateau.AjouterCode(code);
|
|
|
|
|
Console.WriteLine("\n");
|
|
|
|
|
|
|
|
|
|
if (!e.EstJoueur)
|
|
|
|
|
{
|
|
|
|
|
Task t = Task.Delay(1000);
|
|
|
|
|
t.GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.Plateau.AjouterCode(e.Code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -82,10 +89,8 @@ namespace ConsoleApp
|
|
|
|
|
/// <param name="sender">La classe qui appelle l'événement; ici Partie.</param>
|
|
|
|
|
/// <param name="e">L'instance de l'événement AjouterCodeEventArgs créée par Partie.</param>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void AjouterCode(Object? sender, PartiePasserLaMainEventArgs e)
|
|
|
|
|
public static void AjouterCode(object? sender, PartiePasserLaMainEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
|
|
|
|
Utils.DessinerSeparateur();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -96,7 +101,7 @@ namespace ConsoleApp
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void PartieTerminee(Object? sender, PartiePartieTermineeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Joueur[] gagnants = e.Gagnants.ToArray();
|
|
|
|
|
string[] gagnants = e.Gagnants.ToArray();
|
|
|
|
|
|
|
|
|
|
if (gagnants.Length > 1)
|
|
|
|
|
{
|
|
|
|
@ -104,7 +109,7 @@ namespace ConsoleApp
|
|
|
|
|
}
|
|
|
|
|
else if (gagnants.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"C'est une victoire de {gagnants[0].Nom}.");
|
|
|
|
|
Console.WriteLine($"C'est une victoire de {gagnants[0]}.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|