diff --git a/Jackaroo/src/GameFunctionality/Gamesystem.java b/Jackaroo/src/GameFunctionality/Gamesystem.java index 5877ab6..a848afb 100644 --- a/Jackaroo/src/GameFunctionality/Gamesystem.java +++ b/Jackaroo/src/GameFunctionality/Gamesystem.java @@ -1,8 +1,100 @@ package GameFunctionality; -import Infrastructur.Gameboard; +import java.util.ArrayList; + +import Infrastructur.Card; +import Infrastructur.Deck; +import Infrastructur.Player; public class Gamesystem { + private final static int CARDS_PRO_ROUND = 4; + + private boolean gameIsGoing = false; + private boolean hasGameEnded = false; + private int playerCounter = 0; + private int playerID = 1; + + private ArrayList playersList= new ArrayList<>(); + private ArrayList> playerCards = new ArrayList<>(); + private ArrayList playedCards; + + private Player playingPlayer; + private Deck deck; + + public Gamesystem () { + + } + + public void addPlayer(String name) { + Player player = new Player(playerID, name); + playersList.add(player); + playerCounter++; +// if(playersList.size()>0){ + playerID++; +// } + } + + public void removePlayer(int id_player) throws Exception { + for(Player plr : playersList) { + if(plr.getID() == id_player) { + playersList.remove(plr); + playerCounter--; + return; + } + } + // TODO Exception schreiben für nicht existierende ID's + throw new Exception(); + } + + public String[] getAllPlayers() { + String[] allPlayers = new String [playersList.size()]; + for(int i=0; i(); + deck.createAndShuffleDeck(); + + for (int i=0; i deck; - public Deck() { - deck = new ArrayList<>(); - for (CardKind kartenTyp : CardKind.values()) { - for (int i = 0; i < 4; i++) { - deck.add(new Card()); - } - } - } + public Deck() { + + } - public List shuffleDeck(List deck) { - Collections.shuffle(deck); - return deck; - } + public List createAndShuffleDeck() { + deck = new ArrayList<>(); + for (CardKind kartenTyp : CardKind.values()) { + for (int i = 0; i < 4; i++) { + deck.add(new Card()); + } + } + Collections.shuffle(deck); + return deck; + } + + public Card getTopCard() { + if(!deck.isEmpty()) { + return deck.remove(0); + } + return null; + } + + public int getNumberOfCards() { + return deck.size(); + } }