From 9dba3ed6596d6db35c26b0972fc12a035fce6178 Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 31 May 2022 15:06:48 +0200 Subject: [PATCH] ADD method checkScoreToPlay to Rules | UPDATE LaticeApplicationConsole --- .../java/latice/application/LaticeApplicationConsole.java | 8 ++++---- src/main/java/latice/model/Rules.java | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/latice/application/LaticeApplicationConsole.java b/src/main/java/latice/application/LaticeApplicationConsole.java index d9042ac..ab3e642 100644 --- a/src/main/java/latice/application/LaticeApplicationConsole.java +++ b/src/main/java/latice/application/LaticeApplicationConsole.java @@ -142,9 +142,9 @@ public class LaticeApplicationConsole { int choiceMenu = Integer.parseInt(play.next()); switch(choiceMenu) { - case 1: //if (arbitre.checkScore(freeTile)){ - //System.out.println("Vous n'avez pas assez de points pour jouer un nouvelle tuile"); - //}else { + case 1: if (arbitre.checkScoreToPlay(player, freeTile) == false){ + System.out.println("Il vous faut 2 points pour jouer un nouvelle tuile !!!"); + }else { Boolean rulesCheck = false; while (rulesCheck == false) { @@ -162,7 +162,7 @@ public class LaticeApplicationConsole { player.getRack().removeTile(tile); board.displayGameBoard(); - //} + } break; diff --git a/src/main/java/latice/model/Rules.java b/src/main/java/latice/model/Rules.java index ad1343b..c1b39a9 100644 --- a/src/main/java/latice/model/Rules.java +++ b/src/main/java/latice/model/Rules.java @@ -74,6 +74,14 @@ public class Rules { return sun; } + public Boolean checkScoreToPlay(Player player, Boolean free) { + if (player.getScore() < 2 && free == false) { + return false; + }else { + return true; + } + } + public Boolean arbitration(Player player, GameBoard board, Tile tile, Boolean start) { if (start == true){