JACKAROO_PROJECT/Jackaroo/src/GameFunctionality/Gamesystem.java

100 lines
2.0 KiB
Java

package GameFunctionality;
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<Player> playersList= new ArrayList<>();
private ArrayList<ArrayList<Card>> playerCards = new ArrayList<>();
private ArrayList <Card> 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<playersList.size(); i++) {
allPlayers[i] = "ID: " + playersList.get(i).getID() +
", Name: " + playersList.get(i).getName();
}
return allPlayers;
}
// TODO
public String getTheWinner() {
return null;
}
public boolean isTheGameGoing() {
if(deck.getNumberOfCards() == 0) {
hasGameEnded = true;
}
return hasGameEnded;
}
public void handOutCards() throws Exception {
playerCards = new ArrayList<>();
deck.createAndShuffleDeck();
for (int i=0; i<CARDS_PRO_ROUND; i++) {
for(int j=0; j<playerCounter; j++) {
Card card = deck.getTopCard();
if(card != null) {
playerCards.get(i).add(card);
}
else {
// TODO Exception schreiben DeckIsEmpty
throw new Exception();
}
}
}
}
public void playCard (int id_Card) {
}
public void startGame() {
}
}