From 7bdd76cca4faf4369e921bd7bbf3836f17982338 Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 2 Feb 2024 14:34:41 +0100 Subject: [PATCH] Relationship PlayerService_Game --- src/main/java/de/hsfulda/onses/models/Game.java | 16 ++++++++++++++++ .../de/hsfulda/onses/services/PlayerService.java | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/de/hsfulda/onses/models/Game.java b/src/main/java/de/hsfulda/onses/models/Game.java index 0fe4eb1..0f9a56c 100644 --- a/src/main/java/de/hsfulda/onses/models/Game.java +++ b/src/main/java/de/hsfulda/onses/models/Game.java @@ -1,12 +1,14 @@ package de.hsfulda.onses.models; import de.hsfulda.onses.services.GameService; +import de.hsfulda.onses.services.PlayerService; import java.util.ArrayList; public class Game { private GameService gameService; + private PlayerService playerService; private final ArrayList drawCardDeck = new ArrayList<>(); @@ -37,4 +39,18 @@ public class Game { this.gameService = gameService; return this; } + + public PlayerService getPlayerService() { + return playerService; + } + + public Game setPlayerService(PlayerService playerService) { + this.playerService = playerService; + return this; + } + + public Game() + { + this.playerService = new PlayerService().setGame(this); + } } diff --git a/src/main/java/de/hsfulda/onses/services/PlayerService.java b/src/main/java/de/hsfulda/onses/services/PlayerService.java index d726af8..32d1c5e 100644 --- a/src/main/java/de/hsfulda/onses/services/PlayerService.java +++ b/src/main/java/de/hsfulda/onses/services/PlayerService.java @@ -1,11 +1,13 @@ package de.hsfulda.onses.services; +import de.hsfulda.onses.models.Game; import de.hsfulda.onses.models.Player; import java.util.ArrayList; public class PlayerService { + private Game game; private boolean currentTurn = true; // true --> real player, false --> Bot private final ArrayList playerList = new ArrayList<>(); @@ -31,4 +33,12 @@ public class PlayerService { return this; } + public Game getGame() { + return game; + } + + public PlayerService setGame(Game game) { + this.game = game; + return this; + } }