From 30bad619ad5d6e125a2b4a7a62475ce8c8e67980 Mon Sep 17 00:00:00 2001 From: "nicolas.barbosa" Date: Mon, 27 May 2024 17:25:35 +0200 Subject: [PATCH] Continuer page --- .../Events/ConstruireJoueurEventArgs.cs | 12 +- Sources/CoreLibrary/Joueurs/JoueurBuilder.cs | 6 +- Sources/CoreLibrary/Partie.cs | 30 +-- Sources/CoreLibrary/Regles/IRegles.cs | 7 +- .../CoreLibrary/Regles/ReglesClassiques.cs | 9 +- Sources/MauiSpark/App.xaml.cs | 6 +- Sources/MauiSpark/AppShell.xaml | 45 ---- Sources/MauiSpark/AppShell.xaml.cs | 10 - Sources/MauiSpark/MauiSpark.csproj | 6 +- Sources/MauiSpark/Pages/Accueil.xaml | 3 +- Sources/MauiSpark/Pages/Accueil.xaml.cs | 7 + Sources/MauiSpark/Pages/ConnexionPage.xaml | 23 +- Sources/MauiSpark/Pages/ConnexionPage.xaml.cs | 29 ++- Sources/MauiSpark/Pages/Mode.xaml | 10 + Sources/MauiSpark/Pages/Mode.xaml.cs | 26 ++ Sources/MauiSpark/Pages/Plateau.xaml | 72 +----- Sources/MauiSpark/Pages/Plateau.xaml.cs | 235 ++---------------- .../MauiSpark/Views/UsernameEntryView.xaml | 24 -- .../MauiSpark/Views/UsernameEntryView.xaml.cs | 9 - 19 files changed, 147 insertions(+), 422 deletions(-) delete mode 100644 Sources/MauiSpark/AppShell.xaml delete mode 100644 Sources/MauiSpark/AppShell.xaml.cs create mode 100644 Sources/MauiSpark/Pages/Mode.xaml create mode 100644 Sources/MauiSpark/Pages/Mode.xaml.cs delete mode 100644 Sources/MauiSpark/Views/UsernameEntryView.xaml delete mode 100644 Sources/MauiSpark/Views/UsernameEntryView.xaml.cs diff --git a/Sources/CoreLibrary/Events/ConstruireJoueurEventArgs.cs b/Sources/CoreLibrary/Events/ConstruireJoueurEventArgs.cs index ce7f62b..186fb2f 100644 --- a/Sources/CoreLibrary/Events/ConstruireJoueurEventArgs.cs +++ b/Sources/CoreLibrary/Events/ConstruireJoueurEventArgs.cs @@ -1,4 +1,6 @@ -namespace CoreLibrary.Events +using CoreLibrary.Joueurs; + +namespace CoreLibrary.Events { /// /// Classe contenant les arguments passées en paramètre lors de l'événement ConstruireJoueurEventArgs. @@ -8,15 +10,15 @@ /// /// Le nom du joueur à ajouter. /// - public string? Nom { get; private set; } + public Joueur Joueur { get; private set; } /// /// Initialise une nouvelle instance de la classe avec les informations spécifiées. /// - /// Le nom du joueur à ajouter. - public ConstruireJoueurEventArgs(string? nom) + /// Le joueur à ajouter. + public ConstruireJoueurEventArgs(Joueur joueur) { - Nom = nom; + Joueur = joueur; } } } diff --git a/Sources/CoreLibrary/Joueurs/JoueurBuilder.cs b/Sources/CoreLibrary/Joueurs/JoueurBuilder.cs index b136b7b..6a0f3bf 100644 --- a/Sources/CoreLibrary/Joueurs/JoueurBuilder.cs +++ b/Sources/CoreLibrary/Joueurs/JoueurBuilder.cs @@ -6,11 +6,11 @@ namespace CoreLibrary.Joueurs { public event EventHandler? ConstruireJoueur; - private void QuandConstruireJoueur(string? nom) => ConstruireJoueur?.Invoke(this, new ConstruireJoueurEventArgs(nom)); + private void QuandConstruireJoueur(Joueur joueur) => ConstruireJoueur?.Invoke(this, new ConstruireJoueurEventArgs(joueur)); - public void Nom(string? nom) + public void Joueur(Joueur joueur) { - QuandConstruireJoueur(nom); + QuandConstruireJoueur(joueur); } } } diff --git a/Sources/CoreLibrary/Partie.cs b/Sources/CoreLibrary/Partie.cs index b3e1ea3..bf7c2e9 100644 --- a/Sources/CoreLibrary/Partie.cs +++ b/Sources/CoreLibrary/Partie.cs @@ -99,7 +99,7 @@ namespace CoreLibrary /// Les règles de la partie. public Partie(IRegles regles) { - this.regles = regles; + Regles = regles; } /// @@ -110,7 +110,7 @@ namespace CoreLibrary JoueurBuilder joueurBuilder = new JoueurBuilder(); joueurBuilder.ConstruireJoueur += Joueur; - QuandDemanderNom(regles.NbJoueurs + 1, joueurBuilder); + QuandDemanderNom(Regles.NbJoueurs + 1, joueurBuilder); } /// @@ -118,15 +118,17 @@ namespace CoreLibrary /// private void Joueur(Object? sender, ConstruireJoueurEventArgs e) { - Joueur joueur = regles.AjouterJoueur(e.Nom ?? $"Joueur {regles.NbJoueurs + 1}"); + Joueur joueur = e.Joueur; + + Regles.AjouterJoueur(joueur); QuandAjouterJoueur(joueur); joueur.JouerCode += Tour; - if (regles.NbJoueurs != regles.NbJoueursMaximum) + if (Regles.NbJoueurs != Regles.NbJoueursMaximum) { JoueurBuilder joueurBuilder = new JoueurBuilder(); joueurBuilder.ConstruireJoueur += Joueur; - QuandDemanderNom(regles.NbJoueurs + 1, joueurBuilder); + QuandDemanderNom(Regles.NbJoueurs + 1, joueurBuilder); } else { @@ -139,11 +141,11 @@ namespace CoreLibrary /// private void Commencer() { - regles.CommencerLaPartie(); + Regles.CommencerLaPartie(); QuandDebutPartie(); - (Joueur joueurCourant, Plateau plateauCourant) = regles.JoueurCourant(); - QuandNouveauTour(joueurCourant, plateauCourant.Tour, regles.GenererCode(), plateauCourant.Grille(), plateauCourant.Indicateurs()); + (Joueur joueurCourant, Plateau plateauCourant) = Regles.JoueurCourant(); + QuandNouveauTour(joueurCourant, plateauCourant.Tour, Regles.GenererCode(), plateauCourant.Grille(), plateauCourant.Indicateurs()); } /// @@ -151,21 +153,21 @@ namespace CoreLibrary /// private void Tour(Object? sender, JouerCodeEventArgs e) { - (Joueur joueurCourant, Plateau plateauCourant) = regles.JoueurCourant(); + (Joueur joueurCourant, Plateau plateauCourant) = Regles.JoueurCourant(); plateauCourant.AjouterCode(e.Code); QuandAjouterCode(e.Code); - if(regles.EstTerminee()) + if(Regles.EstTerminee()) { Terminee(); } else { - regles.PasserLaMain(); + Regles.PasserLaMain(); QuandPasserMain(); - (joueurCourant, plateauCourant) = regles.JoueurCourant(); - QuandNouveauTour(joueurCourant, plateauCourant.Tour, regles.GenererCode(), plateauCourant.Grille(), plateauCourant.Indicateurs()); + (joueurCourant, plateauCourant) = Regles.JoueurCourant(); + QuandNouveauTour(joueurCourant, plateauCourant.Tour, Regles.GenererCode(), plateauCourant.Grille(), plateauCourant.Indicateurs()); } } @@ -174,7 +176,7 @@ namespace CoreLibrary /// private void Terminee() { - QuandPartieTerminee(regles.Gagnants(), regles.Perdants()); + QuandPartieTerminee(Regles.Gagnants(), Regles.Perdants()); } } } diff --git a/Sources/CoreLibrary/Regles/IRegles.cs b/Sources/CoreLibrary/Regles/IRegles.cs index a66b5a3..b3bc4a9 100644 --- a/Sources/CoreLibrary/Regles/IRegles.cs +++ b/Sources/CoreLibrary/Regles/IRegles.cs @@ -34,11 +34,10 @@ namespace CoreLibrary.Regles int NbJoueursMaximum { get; } /// - /// Ajoute un joueur à partir de son nom. + /// Ajoute un joueur à la partie. /// - /// Nom du joueur à ajouter. - /// Le joueur ajouté. - Joueur AjouterJoueur(string nom); + /// Joueur à ajouter. + void AjouterJoueur(Joueur joueur); /// /// Récupère le joueur courant. diff --git a/Sources/CoreLibrary/Regles/ReglesClassiques.cs b/Sources/CoreLibrary/Regles/ReglesClassiques.cs index e329a83..35abefb 100644 --- a/Sources/CoreLibrary/Regles/ReglesClassiques.cs +++ b/Sources/CoreLibrary/Regles/ReglesClassiques.cs @@ -51,16 +51,13 @@ namespace CoreLibrary.Regles } /// - /// Ajoute un joueur avec le nom spécifié. + /// Ajoute un joueur à la partie. /// - /// Le nom du joueur à ajouter. - /// Le joueur ajouté. - public Joueur AjouterJoueur(string nom) + /// Le joueur à ajouter. + public void AjouterJoueur(Joueur joueur) { - Joueur joueur = new Joueur(nom); joueurs[nbJoueurs] = joueur; plateaux[nbJoueurs++] = new Plateau(TailleCodeMaximum, TourMaximum); - return joueur; } /// diff --git a/Sources/MauiSpark/App.xaml.cs b/Sources/MauiSpark/App.xaml.cs index 375acaa..7ec9fcc 100644 --- a/Sources/MauiSpark/App.xaml.cs +++ b/Sources/MauiSpark/App.xaml.cs @@ -1,4 +1,6 @@ -namespace MauiSpark +using MauiSpark.Pages; + +namespace MauiSpark { public partial class App : Application { @@ -6,7 +8,7 @@ { InitializeComponent(); - MainPage = new AppShell(); + MainPage = new NavigationPage(new Accueil()); } } } diff --git a/Sources/MauiSpark/AppShell.xaml b/Sources/MauiSpark/AppShell.xaml deleted file mode 100644 index 59d1de6..0000000 --- a/Sources/MauiSpark/AppShell.xaml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/Sources/MauiSpark/AppShell.xaml.cs b/Sources/MauiSpark/AppShell.xaml.cs deleted file mode 100644 index d52f2e3..0000000 --- a/Sources/MauiSpark/AppShell.xaml.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MauiSpark -{ - public partial class AppShell : Shell - { - public AppShell() - { - InitializeComponent(); - } - } -} diff --git a/Sources/MauiSpark/MauiSpark.csproj b/Sources/MauiSpark/MauiSpark.csproj index 18f63b2..acb4bd6 100644 --- a/Sources/MauiSpark/MauiSpark.csproj +++ b/Sources/MauiSpark/MauiSpark.csproj @@ -79,6 +79,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile @@ -94,9 +97,6 @@ MSBuild:Compile - - MSBuild:Compile - diff --git a/Sources/MauiSpark/Pages/Accueil.xaml b/Sources/MauiSpark/Pages/Accueil.xaml index 310a4ef..72cf04a 100644 --- a/Sources/MauiSpark/Pages/Accueil.xaml +++ b/Sources/MauiSpark/Pages/Accueil.xaml @@ -1,6 +1,7 @@ + Clicked="QuandJouerClique"/> - - + + +