Gamesystem-Class (PlayCard-method), NormalCard-Class, SpecialCard-Class

& SpecialAbility-Enum
MAIN
wafialwakil 2024-03-07 14:35:07 +01:00
parent 356354acee
commit e95d212ddd
5 changed files with 53 additions and 11 deletions

View File

@ -14,6 +14,7 @@ public class Gamesystem {
private boolean hasGameEnded = false; private boolean hasGameEnded = false;
private int playerCounter = 0; private int playerCounter = 0;
private int playerID = 1; private int playerID = 1;
private int playerPosition = 0;
private ArrayList<Player> playersList= new ArrayList<>(); private ArrayList<Player> playersList= new ArrayList<>();
private ArrayList<ArrayList<Card>> playerCards = new ArrayList<>(); private ArrayList<ArrayList<Card>> playerCards = new ArrayList<>();
@ -89,12 +90,34 @@ public class Gamesystem {
public void playCard (int id_Card) { public void playCard (int id_Card) {
for(Card card : playerCards.get(playerPosition)) {
if(card.getID() == id_Card) {
if(!playerCards.get(playerPosition).isEmpty()) {
playedCards.add(card);
playerCards.get(playerPosition).remove(card);
playerPosition++;
}
}
}
if (playerPosition >= 4) {
playerPosition = 0;
playedCards.clear();
}
} }
public void startGame() { public void startGame() {
} }
private boolean cardChecker() {
return true;
}
} }

View File

@ -18,7 +18,7 @@ public class Card {
this.id = id; this.id = id;
} }
public void setKartenTyp(CardKind kartenTyp) { public void setCardKind(CardKind kartenTyp) {
this.kartenTyp = kartenTyp; this.kartenTyp = kartenTyp;
} }

View File

@ -2,14 +2,19 @@ package Infrastructur;
public class NormalCard extends Card{ public class NormalCard extends Card{
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) { public NormalCard(int id, CardKind kartenTyp, int steps) {
// super(id); setID(id);
setKartenTyp(kartenTyp); setCardKind(kartenTyp);
// Setze den Wert basierend auf dem KartenTyp (z.B., TWO = 2, THREE = 3, etc.) this.steps = steps;
setWert(kartenTyp.ordinal() + 2);
} }
public int getSteps() {
return steps;
}
} }

View File

@ -0,0 +1,9 @@
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
}

View File

@ -4,11 +4,16 @@ 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};
public SpecialCard(CardKind kartenTyp) { private SpecialAbility specialAbility;
// super(id);
setKartenTyp(kartenTyp); public SpecialCard(CardKind kartenTyp, SpecialAbility specialAbility) {
setCardKind(kartenTyp);
this.specialAbility = specialAbility;
}
public SpecialAbility getSpecialAbility() {
return specialAbility;
} }
} }