From 471a55f7ef3a955169d1c6d652f50c8eacce9ba2 Mon Sep 17 00:00:00 2001 From: victor perez ngounou Date: Wed, 26 Oct 2022 15:13:31 +0200 Subject: [PATCH] Mode Solo OKAY #67 --- Sources/BowlingApp/Match.cs | 16 ++++------------ Sources/BowlingLib/Model/Frame.cs | 2 +- Sources/BowlingMaping/JoueurDbDataManager.cs | 2 +- Sources/Tests/BowlingAppUnitTest/UTPartie.cs | 6 +++++- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Sources/BowlingApp/Match.cs b/Sources/BowlingApp/Match.cs index 51a88b1..6df354c 100644 --- a/Sources/BowlingApp/Match.cs +++ b/Sources/BowlingApp/Match.cs @@ -156,23 +156,15 @@ namespace BowlingApp Afficheur.InviteQuilleTombe(1); frame.Lancer(saissiseur.CollectQuilleTomber()); - if (!frame.IsStrike && i!=9) + if (!frame.IsStrike) { Afficheur.InviteQuilleTombe(2); frame.Lancer(saissiseur.CollectQuilleTomber()); } - if (i==9) + if (i == 9 && (frame.IsStrike || frame.IsSpare)) { - if(!frame.IsStrike) - { - Afficheur.InviteQuilleTombe(2); - frame.Lancer(saissiseur.CollectQuilleTomber()); - } - if (frame.IsStrike||frame.IsSpare) - { - Afficheur.InviteQuilleTombe(3); - frame.Lancer(saissiseur.CollectQuilleTomber()); - } + Afficheur.InviteQuilleTombe(3); + frame.Lancer(saissiseur.CollectQuilleTomber()); } partie.AddFrame(frame); Console.WriteLine(partie.GetScore()); diff --git a/Sources/BowlingLib/Model/Frame.cs b/Sources/BowlingLib/Model/Frame.cs index 5b5696c..1c2ebc8 100644 --- a/Sources/BowlingLib/Model/Frame.cs +++ b/Sources/BowlingLib/Model/Frame.cs @@ -198,7 +198,7 @@ namespace BowlingLib.Model { //lorsque le lancer actuel est un strike this.IsStrike = true; - QuillesRestantes = MAX_QUILLE;//Remetre le nombre de quilles restantes à 10 pour le lancer 2 + QuillesRestantes = MAX_QUILLE;//Remetre le nombre de quilles restantes à 10 pour le lancer 3 } else { diff --git a/Sources/BowlingMaping/JoueurDbDataManager.cs b/Sources/BowlingMaping/JoueurDbDataManager.cs index 1f467ac..69ea32a 100644 --- a/Sources/BowlingMaping/JoueurDbDataManager.cs +++ b/Sources/BowlingMaping/JoueurDbDataManager.cs @@ -58,7 +58,7 @@ namespace BowlingMaping { Id = _joueur.Parties[i].Frames[j].Id, Lancer1 = _joueur.Parties[i].Frames[j].Lancer1.QuillesTombees, - Lancer2 = _joueur.Parties[i].Frames[j].Lancer2.QuillesTombees, + Lancer2 = (_joueur.Parties[i].Frames[j].Lancer2 == null) ? 0 : _joueur.Parties[i].Frames[j].Lancer2.QuillesTombees, Lancer3 = (_joueur.Parties[i].Frames[j].Lancer3 == null) ? 0 : _joueur.Parties[i].Frames[j].Lancer3.QuillesTombees,//si Lancer3 est null il prend la valeur Zero Partie = partieEntity }; diff --git a/Sources/Tests/BowlingAppUnitTest/UTPartie.cs b/Sources/Tests/BowlingAppUnitTest/UTPartie.cs index 0daf5ff..f397a40 100644 --- a/Sources/Tests/BowlingAppUnitTest/UTPartie.cs +++ b/Sources/Tests/BowlingAppUnitTest/UTPartie.cs @@ -29,11 +29,15 @@ namespace BowlingAppUnitTest partie.AddFrame(new Frame(8)); partie.AddFrame(new Frame(9)); partie.AddFrame(new Frame(10)); - partie.AddFrame(new Frame(11)); for (int i = 0; i < partie.Frames.Count; i++) { + i = 9; partie.Frames[i].Lancer(10); + if (i==9) + { + partie.Frames[i].Lancer(10); + } } //Act