NormalCard, SpecialCard, GameSystem & SpecialAbility
parent
e95d212ddd
commit
eaf43d6cc5
|
@ -1,29 +1,35 @@
|
||||||
package GameFunctionality;
|
package GameFunctionality;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import Infrastructur.Card;
|
import Infrastructur.Card;
|
||||||
import Infrastructur.Deck;
|
import Infrastructur.Deck;
|
||||||
import Infrastructur.Player;
|
import Infrastructur.Player;
|
||||||
|
|
||||||
public class Gamesystem {
|
public class GameSystem {
|
||||||
|
|
||||||
private final static int CARDS_PRO_ROUND = 4;
|
private final static int CARDS_PRO_ROUND = 4;
|
||||||
|
|
||||||
private boolean gameIsGoing = false;
|
private boolean gameHasStarted = false;
|
||||||
private boolean hasGameEnded = false;
|
private boolean hasGameEnded = false;
|
||||||
|
|
||||||
|
private int inTurn;
|
||||||
private int playerCounter = 0;
|
private int playerCounter = 0;
|
||||||
private int playerID = 1;
|
private int playerID = 1;
|
||||||
private int playerPosition = 0;
|
private int playerPosition = 0;
|
||||||
|
private int counter;
|
||||||
|
|
||||||
private ArrayList<Player> playersList= new ArrayList<>();
|
private ArrayList<Player> playersList= new ArrayList<>();
|
||||||
|
// private List<Card> gameDeck;
|
||||||
private ArrayList<ArrayList<Card>> playerCards = new ArrayList<>();
|
private ArrayList<ArrayList<Card>> playerCards = new ArrayList<>();
|
||||||
private ArrayList <Card> playedCards;
|
private ArrayList <Card> playedCards;
|
||||||
|
private ArrayList <String> playerInfo = new ArrayList();
|
||||||
|
|
||||||
private Player playingPlayer;
|
private Player playingPlayer;
|
||||||
private Deck deck;
|
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<playersList.size(); i++) {
|
||||||
|
playerCards.add(new ArrayList<Card>());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,10 @@ public class NormalCard extends Card{
|
||||||
|
|
||||||
private int steps;
|
private int steps;
|
||||||
|
|
||||||
private CardKind[] laufKarten = {CardKind.TWO, CardKind.THREE, CardKind.SIX, CardKind.EIGHT, CardKind.NINE,
|
// private CardKind[] laufKarten = {CardKind.TWO, CardKind.THREE, CardKind.SIX, CardKind.EIGHT, CardKind.NINE,
|
||||||
CardKind.QUEEN};
|
// CardKind.QUEEN};
|
||||||
|
|
||||||
public NormalCard(int id, CardKind kartenTyp, int steps) {
|
public NormalCard(CardKind kartenTyp, int steps) {
|
||||||
setID(id);
|
|
||||||
setCardKind(kartenTyp);
|
setCardKind(kartenTyp);
|
||||||
this.steps = steps;
|
this.steps = steps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package Infrastructur;
|
||||||
|
|
||||||
public class SpecialCard extends Card{
|
public class SpecialCard extends Card{
|
||||||
|
|
||||||
private CardKind[] eigenschaftKarten = {CardKind.FOUR, CardKind.FIVE, CardKind.SEVEN, CardKind.TEN,
|
// private CardKind[] eigenschaftKarten = {CardKind.FOUR, CardKind.FIVE, CardKind.SEVEN, CardKind.TEN,
|
||||||
CardKind.JACK, CardKind.KING, CardKind.ACE};
|
// CardKind.JACK, CardKind.KING, CardKind.ACE};
|
||||||
|
|
||||||
private SpecialAbility specialAbility;
|
private SpecialAbility specialAbility;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue