diff --git a/Jackaroo/src/GameFunctionality/Gamesystem.java b/Jackaroo/src/GameFunctionality/GameSystem.java similarity index 57% rename from Jackaroo/src/GameFunctionality/Gamesystem.java rename to Jackaroo/src/GameFunctionality/GameSystem.java index 822b235..deca6d9 100644 --- a/Jackaroo/src/GameFunctionality/Gamesystem.java +++ b/Jackaroo/src/GameFunctionality/GameSystem.java @@ -1,29 +1,35 @@ package GameFunctionality; import java.util.ArrayList; +import java.util.List; import Infrastructur.Card; import Infrastructur.Deck; import Infrastructur.Player; -public class Gamesystem { +public class GameSystem { private final static int CARDS_PRO_ROUND = 4; - private boolean gameIsGoing = false; + private boolean gameHasStarted = false; private boolean hasGameEnded = false; + + private int inTurn; private int playerCounter = 0; private int playerID = 1; private int playerPosition = 0; + private int counter; private ArrayList playersList= new ArrayList<>(); +// private List gameDeck; private ArrayList> playerCards = new ArrayList<>(); private ArrayList playedCards; + private ArrayList playerInfo = new ArrayList(); private Player playingPlayer; private Deck deck; - public Gamesystem () { + public GameSystem () { } @@ -111,7 +117,65 @@ public class Gamesystem { } - public void startGame() { + public void startGame() throws Exception { + + if (playersList.size()<=4 && playersList.size()>=2) { + gameHasStarted = true; + } + if(playerCards == null) { + playerCards = new ArrayList<>(); + } + deck = new Deck(); + deck.createAndShuffleDeck(); + + playingPlayer = playersList.get(0); + inTurn = 0; + for(int i=0; i()); + } + + } + + public String[] getThePlayingPlayer() { + + if(inTurn == playersList.size()) { + inTurn = 0; + } + playingPlayer = playersList.get(inTurn); + if(! playedCards.isEmpty()) { + playerInfo.add("Die gespielte Karten im Spielfeld --> " + + playedCards.toString() + "\n"); + playerInfo.add("----------------------------------------" + + "\n" + "\n"); + } + + playerInfo.add("Name: " + playingPlayer.getName()); + playerInfo.add("ID: " + playingPlayer.getID()); + playerInfo.add("Handkarten: " + playerCards.get(inTurn).size()); + + // Show Cards for each Player + StringBuilder handCards = new StringBuilder(); + for (Card card : playerCards.get(inTurn)) { + handCards.append(card.toString()).append("\n"); + } + playerInfo.add(handCards.toString()); + + counter++; + inTurn++; + + if(inTurn == playersList.size()) { + counter=0; + } + + String[] playerInfoArray = playerInfo.toArray(new String[0]); + playerInfo.clear(); + + if(playedCards.size() == playersList.size()) { + playerPosition = 0; + playedCards.clear(); + } + + return playerInfoArray; } diff --git a/Jackaroo/src/Infrastructur/NormalCard.java b/Jackaroo/src/Infrastructur/NormalCard.java index ee2c4fb..9ce54fd 100644 --- a/Jackaroo/src/Infrastructur/NormalCard.java +++ b/Jackaroo/src/Infrastructur/NormalCard.java @@ -4,11 +4,10 @@ public class NormalCard extends Card{ private int steps; - private CardKind[] laufKarten = {CardKind.TWO, CardKind.THREE, CardKind.SIX, CardKind.EIGHT, CardKind.NINE, - CardKind.QUEEN}; +// private CardKind[] laufKarten = {CardKind.TWO, CardKind.THREE, CardKind.SIX, CardKind.EIGHT, CardKind.NINE, +// CardKind.QUEEN}; - public NormalCard(int id, CardKind kartenTyp, int steps) { - setID(id); + public NormalCard(CardKind kartenTyp, int steps) { setCardKind(kartenTyp); this.steps = steps; } diff --git a/Jackaroo/src/Infrastructur/SpecialAbility.java b/Jackaroo/src/Infrastructur/SpecialAbility.java index d09b737..d1203fe 100644 --- a/Jackaroo/src/Infrastructur/SpecialAbility.java +++ b/Jackaroo/src/Infrastructur/SpecialAbility.java @@ -2,8 +2,8 @@ package Infrastructur; public enum SpecialAbility { - BACKWARDS, MOVE_OWN_OR_OTHER, DISTRIBUTE_STEPS_ON_TWO, DISCARD, - SWAP_OWN_WITH_OTHER, MOVE_FORWARD_13_TÖTEN, - MOVE_FORWARD_11, MOVE_FORWARD_1 + BACKWARDS, MOVE_OWN_OR_OTHER, DISTRIBUTE_STEPS_ON_TWO, DISCARD, + SWAP_OWN_WITH_OTHER, MOVE_FORWARD_13_TÖTEN, + MOVE_FORWARD_11, MOVE_FORWARD_1 } diff --git a/Jackaroo/src/Infrastructur/SpecialCard.java b/Jackaroo/src/Infrastructur/SpecialCard.java index 1c7b2fa..441a432 100644 --- a/Jackaroo/src/Infrastructur/SpecialCard.java +++ b/Jackaroo/src/Infrastructur/SpecialCard.java @@ -2,8 +2,8 @@ package Infrastructur; public class SpecialCard extends Card{ - private CardKind[] eigenschaftKarten = {CardKind.FOUR, CardKind.FIVE, CardKind.SEVEN, CardKind.TEN, - CardKind.JACK, CardKind.KING, CardKind.ACE}; +// private CardKind[] eigenschaftKarten = {CardKind.FOUR, CardKind.FIVE, CardKind.SEVEN, CardKind.TEN, +// CardKind.JACK, CardKind.KING, CardKind.ACE}; private SpecialAbility specialAbility;