From 8bb224a07b2101e181a977f7ad9d229588378378 Mon Sep 17 00:00:00 2001 From: fdai7793 Date: Sat, 3 Feb 2024 16:50:41 +0100 Subject: [PATCH] refactoring: setFirstCard --- .../hsfulda/onses/services/GameService.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index 55c5c98..766a28f 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -14,14 +14,7 @@ public class GameService { this.game.setGameService(this); fillDrawDeck(); shuffleDeck(); - - for (int i = 0; i < this.game.getDrawCardDeck().size(); i++) { - Card card = this.game.getDrawCardDeck().get(i); - if (card.getColor() != Card.Color.BLACK) { - this.game.setLastPlayedCard(card); - break; - } - } + setFirstCard(); } public GameService() { @@ -130,4 +123,14 @@ public class GameService { Collections.shuffle(game.getDrawCardDeck()); } + public void setFirstCard() { + for (int i = 0; i < this.game.getDrawCardDeck().size(); i++) { + Card card = this.game.getDrawCardDeck().get(i); + if (card.getColor() != Card.Color.BLACK) { + this.game.setLastPlayedCard(card); + break; + } + } + } + }