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.
73 lines
2.0 KiB
73 lines
2.0 KiB
using CoreLibrary.Evenements;
|
|
using CoreLibrary.Joueurs;
|
|
|
|
namespace MauiSpark.Pages;
|
|
|
|
|
|
partial class Message
|
|
{
|
|
public string Titre { get; init; } = "";
|
|
public string Texte { get; init; } = "";
|
|
public string Image { get; init; } = "";
|
|
}
|
|
|
|
|
|
|
|
public partial class VictoirePage : ContentPage
|
|
{
|
|
public VictoirePage()
|
|
{
|
|
NavigationPage.SetHasNavigationBar(this, false);
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
public async void QuandPartieTerminee(object? sender, PartiePartieTermineeEventArgs e)
|
|
{
|
|
if (Application.Current == null || Application.Current.MainPage == null)
|
|
return;
|
|
|
|
if (((NavigationPage)Application.Current.MainPage).CurrentPage != this)
|
|
await Application.Current.MainPage.Navigation.PushAsync(this);
|
|
|
|
IEnumerable<Page> pages = Application.Current.MainPage.Navigation.NavigationStack.Reverse().Skip(1);
|
|
|
|
foreach (Page page in pages)
|
|
{
|
|
if (page is AccueilPage)
|
|
break;
|
|
|
|
Application.Current.MainPage.Navigation.RemovePage(page);
|
|
}
|
|
|
|
IReadOnlyList<string> gagnants = e.Gagnants;
|
|
IReadOnlyList<string> perdants = e.Perdants;
|
|
|
|
if (gagnants.Count == 1)
|
|
BindingContext = new Message()
|
|
{
|
|
Titre = "Victoire",
|
|
Texte = $"Le joueur {gagnants[0]} a gagné",
|
|
Image = "trophy.jpg"
|
|
};
|
|
else if (gagnants.Count > 1)
|
|
BindingContext = new Message()
|
|
{
|
|
Titre = "Egalité",
|
|
Texte = $"Les joueurs {string.Join(' ', gagnants)} ont gagné",
|
|
Image = "egalite.jpg"
|
|
};
|
|
else
|
|
BindingContext = new Message()
|
|
{
|
|
Titre = "Défaite",
|
|
Texte = "Personne n'a trouvé le code...",
|
|
Image = "defaite.png"
|
|
};
|
|
}
|
|
|
|
public async void QuandMenuPresse(object sender, EventArgs e)
|
|
{
|
|
await Navigation.PopAsync();
|
|
}
|
|
} |