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.
60 lines
1.9 KiB
60 lines
1.9 KiB
using CoreLibrary;
|
|
using MauiSpark.Pages;
|
|
using System.ComponentModel;
|
|
|
|
namespace MauiSpark.Vues;
|
|
|
|
public partial class PartieCommenceeVue : ContentView, INotifyPropertyChanged
|
|
{
|
|
public static readonly BindableProperty PartieProperty = BindableProperty.Create(nameof(Partie), typeof(Partie), typeof(PartieCommenceeVue), null, propertyChanged: QuandPartieChangee);
|
|
|
|
public Partie Partie
|
|
{
|
|
get => (Partie)GetValue(PartieProperty);
|
|
set => SetValue(PartieProperty, value);
|
|
}
|
|
|
|
public string NomRegles
|
|
{
|
|
get => Partie != null ? Partie.Regles.Nom : "";
|
|
}
|
|
|
|
public string TourActuel
|
|
{
|
|
get => $"Tour : {(Partie != null ? Partie.Tour : 0)} / {(Partie != null ? Partie.Regles.NbTour : 0)}";
|
|
}
|
|
|
|
public string[] Joueurs
|
|
{
|
|
get => Partie != null ? Partie.Joueurs.ToArray() : [];
|
|
}
|
|
|
|
public string NombreJoueurs => $"Joueurs : {Joueurs.Length} / {(Partie != null ? Partie.Regles.NbJoueurs : 0)}";
|
|
|
|
private static void QuandPartieChangee(BindableObject bindable, object ancienneValeur, object nouvelleValeur)
|
|
{
|
|
((PartieCommenceeVue)bindable).OnPropertyChanged(nameof(NomRegles));
|
|
((PartieCommenceeVue)bindable).OnPropertyChanged(nameof(TourActuel));
|
|
((PartieCommenceeVue)bindable).OnPropertyChanged(nameof(Joueurs));
|
|
((PartieCommenceeVue)bindable).OnPropertyChanged(nameof(NombreJoueurs));
|
|
}
|
|
|
|
private void PartiePressee(object? sender, EventArgs e)
|
|
{
|
|
if (Partie == null)
|
|
return;
|
|
|
|
Partie partie = MauiProgram.Manageur.ChargerPartie(Partie);
|
|
|
|
partie.PartieDemanderJoueur += new ConnexionPage().QuandDemanderNom;
|
|
partie.PartiePartieTerminee += new VictoirePage().QuandPartieTerminee;
|
|
partie.PartieNouveauTour += new PlateauPage().QuandNouveauTour;
|
|
|
|
partie.Jouer();
|
|
}
|
|
|
|
public PartieCommenceeVue()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
} |