NormalCard, SpecialCard, GameSystem & SpecialAbility
parent
e95d212ddd
commit
eaf43d6cc5
|
@ -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<Player> playersList= new ArrayList<>();
|
||||
// private List<Card> gameDeck;
|
||||
private ArrayList<ArrayList<Card>> playerCards = new ArrayList<>();
|
||||
private ArrayList <Card> playedCards;
|
||||
private ArrayList <String> 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<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 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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue