From bcaf4c8aac3cbfb7414bfc578ed4e04e065999be Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Wed, 7 Feb 2024 12:58:38 +0100 Subject: [PATCH] add special Rule playSeven --- .../de/hsfulda/onses/services/GameService.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index 129790f..29c01d5 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -4,6 +4,7 @@ import de.hsfulda.onses.models.Card; import de.hsfulda.onses.models.Game; import de.hsfulda.onses.models.Player; +import java.util.ArrayList; import java.util.Collections; import java.util.Random; @@ -107,6 +108,21 @@ public class GameService { } } + public void playSeven() { + ArrayList übergangBot = new ArrayList<>(game.getPlayerService().getPlayerList().getLast().getPlayerDeck()); + ArrayList übergangSpieler = new ArrayList<>(game.getPlayerService().getPlayerList().getFirst().getPlayerDeck()); + + game.getPlayerService().getPlayerList().getFirst().getPlayerDeck().clear(); + for (int i = 0; i < übergangBot.size(); i++) { + game.getPlayerService().getPlayerList().getFirst().getPlayerDeck().add(übergangBot.get(i)); + } + + game.getPlayerService().getPlayerList().getLast().getPlayerDeck().clear(); + for (int i = 0; i < übergangSpieler.size(); i++) { + game.getPlayerService().getPlayerList().getLast().getPlayerDeck().add(übergangSpieler.get(i)); + } + } + public void checkForWin() { if (this.game.getPlayerService().getPlayerList().getFirst().getPlayerDeck().isEmpty() || this.game.getPlayerService().getPlayerList().getLast().getPlayerDeck().isEmpty()) { this.game.setGameOver(true);