diff --git a/Jackaroo/src/Infrastructur/Card.java b/Jackaroo/src/Infrastructur/Card.java index 0b28410..149a918 100644 --- a/Jackaroo/src/Infrastructur/Card.java +++ b/Jackaroo/src/Infrastructur/Card.java @@ -3,12 +3,21 @@ package Infrastructur; public class Card { private int wert; + private int id; private CardKind kartenTyp; +// public Card (int id) { +// this.id = id; +// } + public void setWert(int wert) { this.wert = wert; } + public void setID(int id) { + this.id = id; + } + public void setKartenTyp(CardKind kartenTyp) { this.kartenTyp = kartenTyp; } @@ -17,6 +26,10 @@ public class Card { return wert; } + public int getID() { + return id; + } + public CardKind getKartenTyp() { return kartenTyp; } diff --git a/Jackaroo/src/Infrastructur/Deck.java b/Jackaroo/src/Infrastructur/Deck.java index 3018ecd..4ee6306 100644 --- a/Jackaroo/src/Infrastructur/Deck.java +++ b/Jackaroo/src/Infrastructur/Deck.java @@ -1,6 +1,7 @@ package Infrastructur; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class Deck extends Card{ @@ -15,5 +16,10 @@ public class Deck extends Card{ } } } + + public List shuffleDeck(List deck) { + Collections.shuffle(deck); + return deck; + } } diff --git a/Jackaroo/src/Infrastructur/NormalCard.java b/Jackaroo/src/Infrastructur/NormalCard.java index 5170127..83f45cc 100644 --- a/Jackaroo/src/Infrastructur/NormalCard.java +++ b/Jackaroo/src/Infrastructur/NormalCard.java @@ -5,7 +5,8 @@ public class NormalCard extends Card{ private CardKind[] laufKarten = {CardKind.TWO, CardKind.THREE, CardKind.SIX, CardKind.EIGHT, CardKind.NINE, CardKind.QUEEN}; - public NormalCard(CardKind kartenTyp) { + public NormalCard(int id, CardKind kartenTyp) { +// super(id); setKartenTyp(kartenTyp); // Setze den Wert basierend auf dem KartenTyp (z.B., TWO = 2, THREE = 3, etc.) setWert(kartenTyp.ordinal() + 2); diff --git a/Jackaroo/src/Infrastructur/Player.java b/Jackaroo/src/Infrastructur/Player.java new file mode 100644 index 0000000..8680bcb --- /dev/null +++ b/Jackaroo/src/Infrastructur/Player.java @@ -0,0 +1,52 @@ +package Infrastructur; + +public class Player { + + private int id; + private String name; + private Card[] handCards; + + public Player (int id, String name) { + this.id = id; + this.name = name; + } + + public int getID() { + return id; + } + + public String getName() { + return name; + } + + public void setID (int id) { + this.id = id; + } + + public void setName (String name) { + this.name = name; + } + + public Card[] getHandCards () { + return handCards; + } + + public Card playCard (int id) throws Exception { + if ((handCards == null) || (id < 0) || (id >= handCards.length) || (handCards[id] == null)) { + System.err.println("Invalid Card!"); + //TODO Exception Schreiben InvalidCardException + throw new Exception(); + } + + Card playedCard = handCards[id]; + + return playedCard; + } + + @Override + public String toString() { + return "ID: " + this.getID() + ", Name: " + this.name; + } + + +} diff --git a/Jackaroo/src/Infrastructur/SpecialCard.java b/Jackaroo/src/Infrastructur/SpecialCard.java index d99532a..d33b313 100644 --- a/Jackaroo/src/Infrastructur/SpecialCard.java +++ b/Jackaroo/src/Infrastructur/SpecialCard.java @@ -7,6 +7,7 @@ public class SpecialCard extends Card{ public SpecialCard(CardKind kartenTyp) { +// super(id); setKartenTyp(kartenTyp); }