You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
using CoreLibrary;
|
|
using CoreLibrary.Events;
|
|
using CoreLibrary.Joueurs;
|
|
|
|
namespace MauiSpark.Pages;
|
|
|
|
|
|
public partial class ConnexionPage : ContentPage
|
|
{
|
|
private readonly JoueurBuilder joueurBuilder;
|
|
|
|
public ConnexionPage(Partie partie, DemanderNomEventArgs e)
|
|
{
|
|
NavigationPage.SetHasBackButton(this, false);
|
|
NavigationPage.SetHasNavigationBar(this, false);
|
|
|
|
InitializeComponent();
|
|
|
|
joueurBuilder = e.JoueurBuilder;
|
|
|
|
if (e.Indice == partie.Regles.NbJoueursMaximum)
|
|
{
|
|
partie.NouveauTour += QuandNouveauTour;
|
|
partie.PartieTerminee += PartieTerminee;
|
|
}
|
|
|
|
BindingContext = $"Joueur {e.Indice}";
|
|
}
|
|
|
|
private void QuandNouveauTour(object? sender, NouveauTourEventArgs e)
|
|
{
|
|
if (sender != null && sender is Partie)
|
|
Navigation.PushAsync(new Plateau(sender as Partie, e));
|
|
}
|
|
|
|
private void QuandSeConnecterPresse(Object sender, EventArgs e)
|
|
{
|
|
joueurBuilder.Nom(Nom.Text);
|
|
}
|
|
|
|
private void PartieTerminee(Object? sender, PartieTermineeEventArgs e)
|
|
{
|
|
if(e.Gagnants.Count() == 0)
|
|
{
|
|
Navigation.PushAsync(new Defaite((Partie) sender, e));
|
|
}
|
|
else if (e.Gagnants.Count() == 2)
|
|
{
|
|
Navigation.PushAsync(new Egalite());
|
|
}
|
|
else
|
|
{
|
|
Navigation.PushAsync(new Victoire((Partie)sender, e));
|
|
}
|
|
}
|
|
} |