diff --git a/Sources/CoreLibrary/Events/DemanderJetonEventArgs.cs b/Sources/CoreLibrary/Events/DemanderJetonEventArgs.cs
index 78dacc1..a8f3bae 100644
--- a/Sources/CoreLibrary/Events/DemanderJetonEventArgs.cs
+++ b/Sources/CoreLibrary/Events/DemanderJetonEventArgs.cs
@@ -1,22 +1,22 @@
-namespace CoreLibrary.Events
-{
+namespace CoreLibrary.Events
+{
///
/// Classe contenant les arguments passées en paramètre lors de l'événement DemanderJeton.
- ///
- public class DemanderJetonEventArgs : EventArgs
- {
+ ///
+ public class DemanderJetonEventArgs : EventArgs
+ {
///
/// L'indice du code où le jeton va être ajouté.
- ///
- public int Indice { get; private set; }
-
+ ///
+ public int Indice { get; private set; }
+
///
/// Initialise une nouvelle instance de la classe avec l'indice spécifié.
///
- /// L'indice du jeton qui va été ajouté.
- public DemanderJetonEventArgs(int indice)
+ /// L'indice du jeton qui va été ajouté.
+ public DemanderJetonEventArgs(int indice)
{
- Indice = indice;
- }
- }
-}
+ Indice = indice;
+ }
+ }
+}
diff --git a/Sources/CoreLibrary/Joueurs/Joueur.cs b/Sources/CoreLibrary/Joueurs/Joueur.cs
index 336a6ac..e3f9635 100644
--- a/Sources/CoreLibrary/Joueurs/Joueur.cs
+++ b/Sources/CoreLibrary/Joueurs/Joueur.cs
@@ -1,7 +1,4 @@
-using CoreLibrary.Core;
-using CoreLibrary.Events;
-
-namespace CoreLibrary.Joueurs
+namespace CoreLibrary.Joueurs
{
///
/// Classe représentant un joueur.
@@ -13,12 +10,13 @@ namespace CoreLibrary.Joueurs
///
public string Nom { get; private init; }
- ///
- /// Le plateau du joueur.
- ///
- public Plateau Plateau { get; private init; }
+ public int NbCoutTotal { get; set; }
+ public int NbPartieGagnee { get; set; }
+ public int NbPartieEgalite { get; set; }
+ public int NbPartiePerdue { get; set; }
///
+ /// Crée une nouvelle instance de joueur avec un nom
/// Evénement appelé pour jouer un code.
///
public event EventHandler? JouerCode;
@@ -32,11 +30,22 @@ namespace CoreLibrary.Joueurs
/// Crée une nouvelle instance de joueur avec un nom et un plateau spécifié.
///
/// Le nom du joueur.
- /// Le plateau du joueur.
- public Joueur(string nom, Plateau plateau)
+ public Joueur(string nom)
+ {
+ Nom = nom;
+ NbCoutTotal = 0;
+ NbPartieGagnee = 0;
+ NbPartieEgalite = 0;
+ NbPartiePerdue = 0;
+ }
+
+ public Joueur(string nom, int nbCoutTotal, int nbPartieGagnee, int nbPartieEgalite, int nbPartiePerdue)
{
Nom = nom;
- Plateau = plateau;
+ NbCoutTotal = nbCoutTotal;
+ NbPartieGagnee = nbPartieGagnee;
+ NbPartieEgalite = nbPartieEgalite;
+ NbPartiePerdue = nbPartiePerdue;
}
}
}
diff --git a/Sources/CoreLibrary/Manager/IPersistanceManager.cs b/Sources/CoreLibrary/Manager/IPersistanceManager.cs
new file mode 100644
index 0000000..5795d3a
--- /dev/null
+++ b/Sources/CoreLibrary/Manager/IPersistanceManager.cs
@@ -0,0 +1,11 @@
+namespace CoreLibrary.Manager
+{
+ public interface IPersistanceManager
+ {
+ public void Charger();
+
+ public void Enregistrer();
+
+
+ }
+}
diff --git a/Sources/CoreLibrary/Manager/Manager.cs b/Sources/CoreLibrary/Manager/Manager.cs
new file mode 100644
index 0000000..55ad615
--- /dev/null
+++ b/Sources/CoreLibrary/Manager/Manager.cs
@@ -0,0 +1,28 @@
+using CoreLibrary.Joueurs;
+using CoreLibrary.Regles;
+
+namespace CoreLibrary.Manager
+{
+ public class Manager : IPersistanceManager
+ {
+ private Joueur[] joueurs = [];
+ public IReadOnlyList Joueurs => Array.AsReadOnly(joueurs);
+
+ public void Charger()
+ {
+ joueurs = [
+ new Joueur("Pauline", 50, 5, 2, 0),
+ new Joueur("Céleste", 40, 6, 2, 0),
+ new Joueur("Camille", 55, 8, 0, 1),
+ new Joueur("Toto", 70, 0, 0, 10),
+ ];
+ }
+
+
+ public void Enregistrer()
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+}
diff --git a/Sources/CoreLibrary/Regles/IRegles.cs b/Sources/CoreLibrary/Regles/IRegles.cs
index bb0945f..a66b5a3 100644
--- a/Sources/CoreLibrary/Regles/IRegles.cs
+++ b/Sources/CoreLibrary/Regles/IRegles.cs
@@ -44,7 +44,7 @@ namespace CoreLibrary.Regles
/// Récupère le joueur courant.
///
/// Le joueur courant.
- Joueur JoueurCourant();
+ (Joueur, Plateau) JoueurCourant();
///
/// Passe la main au joueur suivant.
diff --git a/Sources/CoreLibrary/Regles/ReglesClassiques.cs b/Sources/CoreLibrary/Regles/ReglesClassiques.cs
index 7ef929c..e329a83 100644
--- a/Sources/CoreLibrary/Regles/ReglesClassiques.cs
+++ b/Sources/CoreLibrary/Regles/ReglesClassiques.cs
@@ -1,171 +1,174 @@
-using CoreLibrary.Core;
-using CoreLibrary.Exceptions;
-using CoreLibrary.Joueurs;
-
-namespace CoreLibrary.Regles
-{
- ///
- /// Classe définissant les règles classiques du jeu.
- ///
- public class ReglesClassiques : IRegles
- {
- private int nbJoueurs = 0;
- private int? joueurCourant;
- private readonly Joueur[] joueurs;
-
- ///
- /// Le nom des règles.
- ///
- public string Nom { get => "Règles classiques"; }
-
- ///
- /// Le nombre maximum de tour.
- ///
- public int TourMaximum { get => 12; }
-
- ///
- /// La taille maximale d'un code.
- ///
-
- public int TailleCodeMaximum { get => 4; }
- ///
- /// Le nombre de joueurs actuels dans le jeu.
- ///
-
+using CoreLibrary.Core;
+using CoreLibrary.Exceptions;
+using CoreLibrary.Joueurs;
+
+namespace CoreLibrary.Regles
+{
+ ///
+ /// Classe définissant les règles classiques du jeu.
+ ///
+ public class ReglesClassiques : IRegles
+ {
+ private int nbJoueurs = 0;
+ private int? joueurCourant;
+ private readonly Joueur[] joueurs;
+ private readonly Plateau[] plateaux;
+
+ ///
+ /// Le nom des règles.
+ ///
+ public string Nom { get => "Règles classiques"; }
+
+ ///
+ /// Le nombre maximum de tour.
+ ///
+ public int TourMaximum { get => 12; }
+
+ ///
+ /// La taille maximale d'un code.
+ ///
+
+ public int TailleCodeMaximum { get => 4; }
+ ///
+ /// Le nombre de joueurs actuels dans le jeu.
+ ///
+
public int NbJoueurs { get => nbJoueurs; }
- ///
- /// Me nombre maximum de joueurs possibles pour le jeu.
- ///
-
- public int NbJoueursMaximum { get => 2; }
-
-
- ///
- /// Initialise une nouvelle instance de la classe
- ///
- public ReglesClassiques()
- {
- joueurs = new Joueur[NbJoueursMaximum];
- }
-
- ///
- /// Ajoute un joueur avec le nom spécifié.
- ///
- /// Le nom du joueur à ajouter.
- /// Le joueur ajouté.
- public Joueur AjouterJoueur(string nom)
- {
- Joueur joueur = new Joueur(nom, new Plateau(TailleCodeMaximum, TourMaximum));
- joueurs[nbJoueurs++] = joueur;
- return joueur;
- }
-
- ///
- /// Obtient le joueur dont c'est actuellement le tour.
- ///
- /// Le joueur actuel.
- /// Levée lorsque la partie n'a pas commencée.
-
- public Joueur JoueurCourant()
- {
- if (!joueurCourant.HasValue)
- throw new PartieNonCommenceeException();
-
- return joueurs[joueurCourant.Value];
- }
-
- ///
- /// Passe la main au joueur suivant.
- ///
- /// Levée lorsque la partie n'a pas commmencée.
- public void PasserLaMain()
- {
- if (!joueurCourant.HasValue)
- {
- throw new PartieNonCommenceeException();
- }
-
- ++joueurCourant;
-
- if (joueurCourant >= joueurs.Length)
- {
- joueurCourant = 0;
- }
-
- }
-
- ///
- /// Génère un nouveau code respectant les règles classiques.
- ///
- /// Le code généré.
- public Code GenererCode()
- {
- return new Code(TailleCodeMaximum);
- }
-
- ///
- /// Démarre la partie en décidant que le premier joueur commence.
- ///
- public void CommencerLaPartie()
- {
- joueurCourant = 0;
- }
-
- ///
- /// Vérifie si la partie est terminée.
- ///
- /// True si la partie est terminée, sinon False.
- public bool EstTerminee()
- {
- if (!joueurCourant.HasValue || joueurCourant != 0)
- return false;
-
- if (JoueurCourant().Plateau.Tour > TourMaximum)
- return true;
-
- for (int i = 0; i < joueurs.Length; ++i)
- {
- if (joueurs[i].Plateau.Victoire)
- return true;
- }
-
- return false;
- }
-
- ///
- /// Obtient les joueurs gagnants de la partie.
- ///
- /// La liste des joueurs gagnants.
- public IEnumerable Gagnants()
- {
- Joueur[] gagnants = [];
- for (int i = 0; i < joueurs.Length; ++i)
- {
- if (joueurs[i].Plateau.Victoire)
- {
- gagnants = gagnants.Append(joueurs[i]).ToArray();
- }
- }
-
- return gagnants;
- }
-
- ///
- /// Obtient les joueurs perdants de la partie.
- ///
- /// La liste des joueurs perdants.
- public IEnumerable Perdants()
- {
- Joueur[] perdants = [];
- for (int i = 0; i < joueurs.Length; ++i)
- {
- if (!joueurs[i].Plateau.Victoire)
- {
- perdants = perdants.Append(joueurs[i]).ToArray();
- }
- }
-
- return perdants;
- }
- }
-}
+ ///
+ /// Me nombre maximum de joueurs possibles pour le jeu.
+ ///
+
+ public int NbJoueursMaximum { get => 2; }
+
+
+ ///
+ /// Initialise une nouvelle instance de la classe
+ ///
+ public ReglesClassiques()
+ {
+ joueurs = new Joueur[NbJoueursMaximum];
+ plateaux = new Plateau[NbJoueursMaximum];
+ }
+
+ ///
+ /// Ajoute un joueur avec le nom spécifié.
+ ///
+ /// Le nom du joueur à ajouter.
+ /// Le joueur ajouté.
+ public Joueur AjouterJoueur(string nom)
+ {
+ Joueur joueur = new Joueur(nom);
+ joueurs[nbJoueurs] = joueur;
+ plateaux[nbJoueurs++] = new Plateau(TailleCodeMaximum, TourMaximum);
+ return joueur;
+ }
+
+ ///
+ /// Obtient le joueur dont c'est actuellement le tour.
+ ///
+ /// Le joueur actuel.
+ /// Levée lorsque la partie n'a pas commencée.
+
+ public (Joueur, Plateau) JoueurCourant()
+ {
+ if (!joueurCourant.HasValue)
+ throw new PartieNonCommenceeException();
+
+ return (joueurs[joueurCourant.Value], plateaux[joueurCourant.Value]);
+ }
+
+ ///
+ /// Passe la main au joueur suivant.
+ ///
+ /// Levée lorsque la partie n'a pas commmencée.
+ public void PasserLaMain()
+ {
+ if (!joueurCourant.HasValue)
+ {
+ throw new PartieNonCommenceeException();
+ }
+
+ ++joueurCourant;
+
+ if (joueurCourant >= joueurs.Length)
+ {
+ joueurCourant = 0;
+ }
+
+ }
+
+ ///
+ /// Génère un nouveau code respectant les règles classiques.
+ ///
+ /// Le code généré.
+ public Code GenererCode()
+ {
+ return new Code(TailleCodeMaximum);
+ }
+
+ ///
+ /// Démarre la partie en décidant que le premier joueur commence.
+ ///
+ public void CommencerLaPartie()
+ {
+ joueurCourant = 0;
+ }
+
+ ///
+ /// Vérifie si la partie est terminée.
+ ///
+ /// True si la partie est terminée, sinon False.
+ public bool EstTerminee()
+ {
+ if (!joueurCourant.HasValue || joueurCourant != 0)
+ return false;
+
+ if (JoueurCourant().Item2.Tour > TourMaximum)
+ return true;
+
+ for (int i = 0; i < joueurs.Length; ++i)
+ {
+ if (plateaux[i].Victoire)
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Obtient les joueurs gagnants de la partie.
+ ///
+ /// La liste des joueurs gagnants.
+ public IEnumerable Gagnants()
+ {
+ Joueur[] gagnants = [];
+ for (int i = 0; i < joueurs.Length; ++i)
+ {
+ if (plateaux[i].Victoire)
+ {
+ gagnants = gagnants.Append(joueurs[i]).ToArray();
+ }
+ }
+
+ return gagnants;
+ }
+
+ ///
+ /// Obtient les joueurs perdants de la partie.
+ ///
+ /// La liste des joueurs perdants.
+ public IEnumerable Perdants()
+ {
+ Joueur[] perdants = [];
+ for (int i = 0; i < joueurs.Length; ++i)
+ {
+ if (!plateaux[i].Victoire)
+ {
+ perdants = perdants.Append(joueurs[i]).ToArray();
+ }
+ }
+
+ return perdants;
+ }
+ }
+}
diff --git a/Sources/MauiSpark/MauiProgram.cs b/Sources/MauiSpark/MauiProgram.cs
index a44a012..be3b5b2 100644
--- a/Sources/MauiSpark/MauiProgram.cs
+++ b/Sources/MauiSpark/MauiProgram.cs
@@ -1,11 +1,16 @@
-using Microsoft.Extensions.Logging;
+using CoreLibrary.Manager;
+using Microsoft.Extensions.Logging;
namespace MauiSpark
{
public static class MauiProgram
{
+ public static Manager Manager { get; private set; } = new Manager();
+
public static MauiApp CreateMauiApp()
{
+ Manager.Charger();
+
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp()
diff --git a/Sources/MauiSpark/MauiSpark.csproj b/Sources/MauiSpark/MauiSpark.csproj
index 9f70617..01cba09 100644
--- a/Sources/MauiSpark/MauiSpark.csproj
+++ b/Sources/MauiSpark/MauiSpark.csproj
@@ -62,6 +62,10 @@
+
+
+
+
MSBuild:Compile
diff --git a/Sources/MauiSpark/Pages/TableauScore.xaml b/Sources/MauiSpark/Pages/TableauScore.xaml
index f637c5c..c095872 100644
--- a/Sources/MauiSpark/Pages/TableauScore.xaml
+++ b/Sources/MauiSpark/Pages/TableauScore.xaml
@@ -18,25 +18,18 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/Sources/MauiSpark/Pages/TableauScore.xaml.cs b/Sources/MauiSpark/Pages/TableauScore.xaml.cs
index db2de05..febd769 100644
--- a/Sources/MauiSpark/Pages/TableauScore.xaml.cs
+++ b/Sources/MauiSpark/Pages/TableauScore.xaml.cs
@@ -1,9 +1,48 @@
+
+using CoreLibrary.Joueurs;
+using MauiSpark.Views;
+using System.Collections.ObjectModel;
namespace MauiSpark.Pages;
public partial class TableauScore : ContentPage
{
- public TableauScore()
- {
- InitializeComponent();
- }
+ public TableauScore()
+ {
+ InitializeComponent();
+ SetDefaultClassement();
+ }
+ private void SetDefaultClassement()
+ {
+ CTableauScore.UpdateClassement(CTableauScore.GetClassementNbCoupParPartie);
+ }
+
+ private void QuandNbCoutMoyenButtonClicked(object sender, EventArgs e)
+ {
+ CTableauScore.UpdateClassement(CTableauScore.GetClassementNbCoupParPartie);
+ }
+
+ private void QuandGagneeButtonClicked(object sender, EventArgs e)
+ {
+ CTableauScore.UpdateClassement(CTableauScore.GetClassementPartieGagnee);
+ }
+
+ private void QuandPerduButtonClicked(object sender, EventArgs e)
+ {
+ CTableauScore.UpdateClassement(CTableauScore.GetClassementPartiePerdue);
+ }
+
+ private void QuandEgaliteButtonClicked(object sender, EventArgs e)
+ {
+ CTableauScore.UpdateClassement(CTableauScore.GetClassementPartieEgalite);
+ }
+
+ private void QuandAlphabetHautButtonClicked(object sender, EventArgs e)
+ {
+ CTableauScore.UpdateClassement(CTableauScore.GetClassementAlphabetHaut);
+ }
+
+ private void QuandAlphabetBasButtonClicked(object sender, EventArgs e)
+ {
+ CTableauScore.UpdateClassement(CTableauScore.GetClassementAlphabetBas);
+ }
}
\ No newline at end of file
diff --git a/Sources/MauiSpark/Views/CTableauScore.xaml b/Sources/MauiSpark/Views/CTableauScore.xaml
index 5ef6dcd..684ab52 100644
--- a/Sources/MauiSpark/Views/CTableauScore.xaml
+++ b/Sources/MauiSpark/Views/CTableauScore.xaml
@@ -1,14 +1,23 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/MauiSpark/Views/CTableauScore.xaml.cs b/Sources/MauiSpark/Views/CTableauScore.xaml.cs
index 28a60c1..5f7430e 100644
--- a/Sources/MauiSpark/Views/CTableauScore.xaml.cs
+++ b/Sources/MauiSpark/Views/CTableauScore.xaml.cs
@@ -1,9 +1,191 @@
+using CoreLibrary.Events;
+using CoreLibrary.Joueurs;
+using CoreLibrary.Manager;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
namespace MauiSpark.Views;
-public partial class CTableauScore : ContentView
-{
- public CTableauScore()
+public class JoueurClassementNbCoupParPartie
+{
+ private Manager manager;
+ private Joueur joueur;
+
+ public Joueur Joueur
+ {
+ get => joueur;
+ private set => joueur = value;
+ }
+ public int Place
+ {
+ get => manager.Joueurs
+ .OrderBy(joueur => joueur.NbCoutTotal/(joueur.NbPartiePerdue+joueur.NbPartieGagnee+joueur.NbPartieEgalite)).ToList()
+ .IndexOf(Joueur) + 1;
+ }
+
+ public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
+
+ public JoueurClassementNbCoupParPartie(Joueur joueur, Manager manager)
+ {
+ this.manager = manager;
+ this.joueur = joueur;
+ }
+}
+
+public class JoueurClassementPartieGagnee
+{
+ private Manager manager;
+ private Joueur joueur;
+
+ public Joueur Joueur
+ {
+ get => joueur;
+ private set => joueur = value;
+ }
+
+ public int Place
+ {
+ get => manager.Joueurs.OrderByDescending(joueur => joueur.NbPartieGagnee).ToList().IndexOf(Joueur) + 1;
+ }
+
+ public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
+
+ public JoueurClassementPartieGagnee(Joueur joueur, Manager manager)
+ {
+ this.manager = manager;
+ this.joueur = joueur;
+ }
+}
+
+public class JoueurClassementPartieEgalite
+{
+ private Manager manager;
+ private Joueur joueur;
+
+ public Joueur Joueur
+ {
+ get => joueur;
+ private set => joueur = value;
+ }
+
+ public int Place
+ {
+ get => manager.Joueurs.OrderByDescending(joueur => joueur.NbPartieEgalite).ToList().IndexOf(joueur)+1;
+ }
+
+ public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
+
+ public JoueurClassementPartieEgalite(Joueur joueur, Manager manager)
+ {
+ this.manager = manager;
+ this.joueur = joueur;
+ }
+}
+
+public class JoueurClassementPartiePerdue
+{
+ private Manager manager;
+ private Joueur joueur;
+
+ public Joueur Joueur
+ {
+ get => joueur;
+ private set => joueur = value;
+ }
+
+ public int Place
+ {
+ get => manager.Joueurs.OrderByDescending(joueur => joueur.NbPartiePerdue).ToList().IndexOf(joueur)+1;
+ }
+
+ public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
+
+ public JoueurClassementPartiePerdue(Joueur joueur, Manager manager)
+ {
+ this.manager = manager;
+ this.joueur = joueur;
+ }
+}
+
+public class JoueurClassementAlphabet
+{
+ private Manager manager;
+ private Joueur joueur;
+
+ public Joueur Joueur
+ {
+ get => joueur;
+ private set => joueur = value;
+ }
+
+ public int Place
+ {
+ get => manager.Joueurs
+ .OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite)).ToList()
+ .IndexOf(Joueur) + 1;
+ }
+
+ public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
+
+ public JoueurClassementAlphabet(Joueur joueur, Manager manager)
+ {
+ this.manager = manager;
+ this.joueur = joueur;
+ }
+}
+
+ public partial class CTableauScore : ContentView
+{
+ public IEnumerable GetClassementNbCoupParPartie()
+ {
+ return MauiProgram.Manager.Joueurs
+ .OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite))
+ .Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manager));
+ }
+
+ public IEnumerable GetClassementPartieGagnee()
+ {
+ return MauiProgram.Manager.Joueurs
+ .OrderByDescending(joueur => joueur.NbPartieGagnee)
+ .Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manager));
+ }
+
+ public IEnumerable GetClassementPartieEgalite()
+ {
+ return MauiProgram.Manager.Joueurs
+ .OrderByDescending(joueur => joueur.NbPartieEgalite)
+ .Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manager));
+ }
+
+ public IEnumerable GetClassementPartiePerdue()
+ {
+ return MauiProgram.Manager.Joueurs
+ .OrderByDescending(joueur => joueur.NbPartiePerdue)
+ .Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manager));
+ }
+
+ public IEnumerable GetClassementAlphabetHaut()
+ {
+ return MauiProgram.Manager.Joueurs
+ .OrderBy(joueur => joueur.Nom)
+ .Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manager));
+ }
+ public IEnumerable GetClassementAlphabetBas()
+ {
+ return MauiProgram.Manager.Joueurs
+ .OrderByDescending(joueur => joueur.Nom)
+ .Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manager));
+ }
+
+
+ public CTableauScore()
{
InitializeComponent();
- }
+ }
+
+ public void UpdateClassement(Func> getClassement)
+ {
+ BindingContext = getClassement();
+ }
}
\ No newline at end of file
diff --git a/Sources/UnitTesting/AjouterJoueurEventArgs.cs b/Sources/UnitTesting/AjouterJoueurEventArgs.cs
index 5433ab5..f614d6b 100644
--- a/Sources/UnitTesting/AjouterJoueurEventArgs.cs
+++ b/Sources/UnitTesting/AjouterJoueurEventArgs.cs
@@ -10,7 +10,7 @@ namespace UnitTesting
[Fact]
public void TestConstructeurValide()
{
- Joueur monJoueur = new Joueur("Céleste", new Plateau(4, 12));
+ Joueur monJoueur = new Joueur("Céleste");
AjouterJoueursEventArgs evenement = new AjouterJoueursEventArgs(monJoueur);
diff --git a/Sources/UnitTesting/JoueurUT.cs b/Sources/UnitTesting/JoueurUT.cs
index 5de0df7..147f3ee 100644
--- a/Sources/UnitTesting/JoueurUT.cs
+++ b/Sources/UnitTesting/JoueurUT.cs
@@ -7,13 +7,38 @@ namespace UnitTesting
public class JoueurUT
{
[Fact]
- public void TestConstructeurValide()
+ public void TestConstructeur1Valide()
{
- Plateau plateau = new Plateau(4, 10);
- Joueur joueur = new Joueur("MonJoueur", plateau);
+ string nom = "toto";
- Assert.Equal("MonJoueur", joueur.Nom);
- Assert.Equal(plateau, joueur.Plateau);
+ Joueur joueur = new Joueur(nom);
+
+
+ Assert.Equal(nom, joueur.Nom);
+ Assert.Equal(0, joueur.NbCoutTotal);
+ Assert.Equal(0, joueur.NbPartieGagnee);
+ Assert.Equal(0, joueur.NbPartieEgalite);
+ Assert.Equal(0, joueur.NbPartiePerdue);
}
+
+
+ [Fact]
+ public void TestConstructeur2Valide()
+ {
+ string nom = "Bob";
+ int nbCoutTotal = 10;
+ int nbPartieGagnee = 5;
+ int nbPartieEgalite = 2;
+ int nbPartiePerdue = 3;
+
+ Joueur joueur = new Joueur(nom, nbCoutTotal, nbPartieGagnee, nbPartieEgalite, nbPartiePerdue);
+
+ Assert.Equal(nom, joueur.Nom);
+ Assert.Equal(nbCoutTotal, joueur.NbCoutTotal);
+ Assert.Equal(nbPartieGagnee, joueur.NbPartieGagnee);
+ Assert.Equal(nbPartieEgalite, joueur.NbPartieEgalite);
+ Assert.Equal(nbPartiePerdue, joueur.NbPartiePerdue);
+ }
+
}
}
diff --git a/Sources/UnitTesting/NouveauTourEventArgsUT.cs b/Sources/UnitTesting/NouveauTourEventArgsUT.cs
index a634a5f..d1f877a 100644
--- a/Sources/UnitTesting/NouveauTourEventArgsUT.cs
+++ b/Sources/UnitTesting/NouveauTourEventArgsUT.cs
@@ -11,7 +11,7 @@ namespace UnitTesting
public void TestConstructeurValide()
{
Plateau monPlateau = new Plateau(4, 12);
- Joueur monJoueur = new Joueur("Céleste", monPlateau);
+ Joueur monJoueur = new Joueur("Céleste");
NouveauTourEventArgs evenement =
new NouveauTourEventArgs(monJoueur, 5, monPlateau.Grille(), monPlateau.Indicateurs());
diff --git a/Sources/UnitTesting/PartieTermineeEventArgsUT.cs b/Sources/UnitTesting/PartieTermineeEventArgsUT.cs
index 9b96d40..09f0e6a 100644
--- a/Sources/UnitTesting/PartieTermineeEventArgsUT.cs
+++ b/Sources/UnitTesting/PartieTermineeEventArgsUT.cs
@@ -11,8 +11,8 @@ namespace UnitTesting
public void TestConstructeurValide()
{
Plateau plateau = new Plateau(4, 12);
- Joueur[] gagnants = [new Joueur("Pauline", plateau), new Joueur("Camille", plateau)];
- Joueur[] perdants = [new Joueur("Céleste", plateau)];
+ Joueur[] gagnants = [new Joueur("Pauline"), new Joueur("Camille")];
+ Joueur[] perdants = [new Joueur("Céleste")];
PartieTermineeEventArgs evenement = new PartieTermineeEventArgs(gagnants, perdants);
diff --git a/Sources/UnitTesting/ReglesClassiquesUT.cs b/Sources/UnitTesting/ReglesClassiquesUT.cs
index 25fcfb9..b58aa1c 100644
--- a/Sources/UnitTesting/ReglesClassiquesUT.cs
+++ b/Sources/UnitTesting/ReglesClassiquesUT.cs
@@ -52,14 +52,14 @@ namespace UnitTesting
regles.CommencerLaPartie();
int? joueurCourantAvant = (int?) fieldInfo.GetValue(regles);
- Joueur courantAvant = regles.JoueurCourant();
+ Joueur courantAvant = regles.JoueurCourant().Item1;
Assert.NotNull(joueurCourantAvant);
Assert.Equal(0, joueurCourantAvant);
regles.PasserLaMain();
int? joueurCourantApres = (int?)fieldInfo.GetValue(regles);
- Joueur courantApres = regles.JoueurCourant();
+ Joueur courantApres = regles.JoueurCourant().Item1;
Assert.NotNull(joueurCourantApres);
Assert.Equal(1, joueurCourantApres);
Assert.NotEqual(joueurCourantAvant, joueurCourantApres);
@@ -68,7 +68,7 @@ namespace UnitTesting
regles.PasserLaMain();
int? joueurCourantBoucle = (int?)fieldInfo.GetValue(regles);
- Joueur courantBoucle = regles.JoueurCourant();
+ Joueur courantBoucle = regles.JoueurCourant().Item1;
Assert.NotNull(joueurCourantBoucle);
Assert.Equal(0, joueurCourantBoucle);
Assert.NotEqual(joueurCourantApres, joueurCourantBoucle);
@@ -103,7 +103,7 @@ namespace UnitTesting
regles.PasserLaMain();
- Plateau plateauj1 = regles.JoueurCourant().Plateau;
+ Plateau plateauj1 = regles.JoueurCourant().Item2;
type = typeof(Plateau);
fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
@@ -112,7 +112,7 @@ namespace UnitTesting
Code? codeSecret = (Code?)fieldInfo.GetValue(plateauj1);
Assert.NotNull(codeSecret);
- regles.JoueurCourant().Plateau.AjouterCode(codeSecret);
+ regles.JoueurCourant().Item2.AjouterCode(codeSecret);
bool estTerminee = regles.EstTerminee();
@@ -132,7 +132,7 @@ namespace UnitTesting
regles.CommencerLaPartie();
- Plateau plateauj1 = regles.JoueurCourant().Plateau;
+ Plateau plateauj1 = regles.JoueurCourant().Item2;
Type type = typeof(Plateau);
FieldInfo? fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
@@ -140,10 +140,10 @@ namespace UnitTesting
Code? codeSecret = (Code?)fieldInfo.GetValue(plateauj1);
Assert.NotNull(codeSecret);
- regles.JoueurCourant().Plateau.AjouterCode(codeSecret);
+ regles.JoueurCourant().Item2.AjouterCode(codeSecret);
IEnumerable gagnants = regles.Gagnants();
Assert.Single(gagnants);
- Assert.Contains(regles.JoueurCourant(), gagnants);
+ Assert.Contains(regles.JoueurCourant().Item1, gagnants);
}
}
}