From b0a2d916d43fde7e783d5c07b1d02b67f60d7efc Mon Sep 17 00:00:00 2001 From: "nicolas.barbosa" Date: Mon, 6 May 2024 17:44:27 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20de=20la=20classe=20Partie=20et=20d?= =?UTF-8?q?es=20=C3=A9venments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/ConsoleApp/Program.cs | 88 ------------------- Sources/CoreLibrary/CoreLibrary.csproj | 4 + .../CodeIndiceHorsDePorteeException.cs | 2 +- .../CodeJetonNullException.cs | 0 .../CodeTableauLesJetonsCompletException.cs | 0 .../CodeTableauLesJetonsIncompletException.cs | 0 .../CodeTableauLesJetonsVideException.cs | 0 .../PlateauCodeIncompletException.cs | 0 .../PlateauTailleCodeException.cs | 0 .../PlateauTailleCodeIncompleteException.cs | 0 .../PlateauTailleGrilleException.cs | 0 .../ReglesClassiquesJoueurCourantNull.cs | 0 Sources/CoreLibrary/Partie.cs | 42 +++++++++ 13 files changed, 47 insertions(+), 89 deletions(-) rename Sources/CoreLibrary/{ => Exceptions}/CodeIndiceHorsDePorteeException.cs (90%) rename Sources/CoreLibrary/{ => Exceptions}/CodeJetonNullException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/CodeTableauLesJetonsCompletException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/CodeTableauLesJetonsIncompletException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/CodeTableauLesJetonsVideException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/PlateauCodeIncompletException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/PlateauTailleCodeException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/PlateauTailleCodeIncompleteException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/PlateauTailleGrilleException.cs (100%) rename Sources/CoreLibrary/{ => Exceptions}/ReglesClassiquesJoueurCourantNull.cs (100%) create mode 100644 Sources/CoreLibrary/Partie.cs diff --git a/Sources/ConsoleApp/Program.cs b/Sources/ConsoleApp/Program.cs index 475a617..e69de29 100644 --- a/Sources/ConsoleApp/Program.cs +++ b/Sources/ConsoleApp/Program.cs @@ -1,88 +0,0 @@ -using CoreLibrary; -using ConsoleApp; - - - -Console.OutputEncoding = System.Text.Encoding.UTF8; - -ReglesClassiques partie = new ReglesClassiques(); - -Utils.AfficherTitre(); - -Utils.AfficherTitre("Joueurs"); - -string joueur1; -string joueur2; - -while (true) -{ - try - { - joueur1 = Utils.SaisirNom(); - break; - } - catch(UtilsNomJoueurNullException) - { - Console.WriteLine("Nom invalide pour le joueur ! Ressaisir le nom"); - } -} - -while (true) -{ - try - { - joueur2 = Utils.SaisirNom(); - break; - } - catch (UtilsNomJoueurNullException) - { - Console.WriteLine("Nom invalide pour le joueur 2 ! Ressaisir le nom"); - } -} - -Utils.AfficherSeparateur(); - -partie.AjouterJoueur(joueur1); -partie.AjouterJoueur(joueur2); - -partie.CommencerLaPartie(); - -while (!partie.EstTerminee()) -{ - Console.WriteLine(partie.JoueurCourant().Nom); - Console.WriteLine(); - - Utils.DessinerPlateau(partie.JoueurCourant().Plateau.Grille(), partie.JoueurCourant().Plateau.Indicateurs()); - Console.WriteLine(); - - Code code = partie.GenererCode(); - - Utils.ChoixCode(ref code); - - partie.JoueurCourant().Plateau.AjouterCode(code); - - partie.PasserLaMain(); - - Utils.AfficherSeparateur(); -} - -Console.WriteLine("La partie est maintenant terminée !"); - -Joueur[] gagnants = partie.Gagnants().ToArray(); -Joueur[] perdants = partie.Perdants().ToArray(); - - - -if (gagnants.Length > 1) -{ - Console.WriteLine("C'est une égalité !"); -} -else if (gagnants.Length == 1) -{ - Console.WriteLine($"C'est une victoire de {gagnants[0].Nom}." + - $""); -} -else -{ - Console.WriteLine("C'est une défaite..."); -} diff --git a/Sources/CoreLibrary/CoreLibrary.csproj b/Sources/CoreLibrary/CoreLibrary.csproj index fa71b7a..9ff0d50 100644 --- a/Sources/CoreLibrary/CoreLibrary.csproj +++ b/Sources/CoreLibrary/CoreLibrary.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/Sources/CoreLibrary/CodeIndiceHorsDePorteeException.cs b/Sources/CoreLibrary/Exceptions/CodeIndiceHorsDePorteeException.cs similarity index 90% rename from Sources/CoreLibrary/CodeIndiceHorsDePorteeException.cs rename to Sources/CoreLibrary/Exceptions/CodeIndiceHorsDePorteeException.cs index 36c0929..6615035 100644 --- a/Sources/CoreLibrary/CodeIndiceHorsDePorteeException.cs +++ b/Sources/CoreLibrary/Exceptions/CodeIndiceHorsDePorteeException.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CoreLibrary +namespace CoreLibrary.Excpetion { public class CodeIndiceHorsDePorteeException : Exception { diff --git a/Sources/CoreLibrary/CodeJetonNullException.cs b/Sources/CoreLibrary/Exceptions/CodeJetonNullException.cs similarity index 100% rename from Sources/CoreLibrary/CodeJetonNullException.cs rename to Sources/CoreLibrary/Exceptions/CodeJetonNullException.cs diff --git a/Sources/CoreLibrary/CodeTableauLesJetonsCompletException.cs b/Sources/CoreLibrary/Exceptions/CodeTableauLesJetonsCompletException.cs similarity index 100% rename from Sources/CoreLibrary/CodeTableauLesJetonsCompletException.cs rename to Sources/CoreLibrary/Exceptions/CodeTableauLesJetonsCompletException.cs diff --git a/Sources/CoreLibrary/CodeTableauLesJetonsIncompletException.cs b/Sources/CoreLibrary/Exceptions/CodeTableauLesJetonsIncompletException.cs similarity index 100% rename from Sources/CoreLibrary/CodeTableauLesJetonsIncompletException.cs rename to Sources/CoreLibrary/Exceptions/CodeTableauLesJetonsIncompletException.cs diff --git a/Sources/CoreLibrary/CodeTableauLesJetonsVideException.cs b/Sources/CoreLibrary/Exceptions/CodeTableauLesJetonsVideException.cs similarity index 100% rename from Sources/CoreLibrary/CodeTableauLesJetonsVideException.cs rename to Sources/CoreLibrary/Exceptions/CodeTableauLesJetonsVideException.cs diff --git a/Sources/CoreLibrary/PlateauCodeIncompletException.cs b/Sources/CoreLibrary/Exceptions/PlateauCodeIncompletException.cs similarity index 100% rename from Sources/CoreLibrary/PlateauCodeIncompletException.cs rename to Sources/CoreLibrary/Exceptions/PlateauCodeIncompletException.cs diff --git a/Sources/CoreLibrary/PlateauTailleCodeException.cs b/Sources/CoreLibrary/Exceptions/PlateauTailleCodeException.cs similarity index 100% rename from Sources/CoreLibrary/PlateauTailleCodeException.cs rename to Sources/CoreLibrary/Exceptions/PlateauTailleCodeException.cs diff --git a/Sources/CoreLibrary/PlateauTailleCodeIncompleteException.cs b/Sources/CoreLibrary/Exceptions/PlateauTailleCodeIncompleteException.cs similarity index 100% rename from Sources/CoreLibrary/PlateauTailleCodeIncompleteException.cs rename to Sources/CoreLibrary/Exceptions/PlateauTailleCodeIncompleteException.cs diff --git a/Sources/CoreLibrary/PlateauTailleGrilleException.cs b/Sources/CoreLibrary/Exceptions/PlateauTailleGrilleException.cs similarity index 100% rename from Sources/CoreLibrary/PlateauTailleGrilleException.cs rename to Sources/CoreLibrary/Exceptions/PlateauTailleGrilleException.cs diff --git a/Sources/CoreLibrary/ReglesClassiquesJoueurCourantNull.cs b/Sources/CoreLibrary/Exceptions/ReglesClassiquesJoueurCourantNull.cs similarity index 100% rename from Sources/CoreLibrary/ReglesClassiquesJoueurCourantNull.cs rename to Sources/CoreLibrary/Exceptions/ReglesClassiquesJoueurCourantNull.cs diff --git a/Sources/CoreLibrary/Partie.cs b/Sources/CoreLibrary/Partie.cs new file mode 100644 index 0000000..ecb4b1c --- /dev/null +++ b/Sources/CoreLibrary/Partie.cs @@ -0,0 +1,42 @@ +namespace CoreLibrary +{ + public class Partie + { + private IRegles regles; + + public Partie(IRegles regles) + { + this.regles = regles; + } + + public void Jouer() + { + DefinirJoueurs(); + + regles.CommencerLaPartie(); + + while (!regles.EstTerminee()) + { + // ?? + } + + PartieTerminee(); + + } + + private void DefinirJoueurs() + { + while(regles.NbJoueurs != regles.NbJoueursMaximum) + { + // + } + } + + private void PartieTerminee() + { + + } + + + } +}