removed card and fixed codes style

removed card because it was unnecessary and reworked all classes containing it to implement the change
This commit is contained in:
Hanno Fleischer
2024-11-14 15:49:22 +01:00
parent c7b65d949a
commit 9bafd749b6
4 changed files with 18 additions and 50 deletions

View File

@@ -1,34 +0,0 @@
package pp.mdga.game;
/**
* This class is used to create a card
*/
public class Card {
private BonusCard type;
/**
* This constructor is used to create a new card
*
* @param type the type of the card
*/
public Card(BonusCard type) {
this.type = type;
}
/**
* This method is used to get the type of the card
*
* @return the type of the card
*/
public BonusCard getType() {
return type;
}
/**
* This method is used to set the type of the card
*
* @param type the new type of the card
*/
public void setType(BonusCard type) {
this.type = type;
}
}

View File

@@ -14,8 +14,8 @@ public class Game {
private int diceEyes; private int diceEyes;
private Map <Color, Player> players; private Map <Color, Player> players;
private Statistic gameStatistics; private Statistic gameStatistics;
private ArrayList<Card> drawPile; private ArrayList<BonusCard> drawPile;
private ArrayList<Card> discardPile = new ArrayList<>(); private ArrayList<BonusCard> discardPile = new ArrayList<>();
private Board board; private Board board;
private Color activeColor; private Color activeColor;
private LinkedList<Color> order; private LinkedList<Color> order;
@@ -31,11 +31,11 @@ public Game(){
gameStatistics = new Statistic(); gameStatistics = new Statistic();
drawPile = new ArrayList<>(); drawPile = new ArrayList<>();
for (int i = 0; i < AMOUNT_OF_TURBO_CARDS; i++) { for (int i = 0; i < AMOUNT_OF_TURBO_CARDS; i++) {
drawPile.add(new Card(BonusCard.TURBO)); drawPile.add(BonusCard.TURBO);
} }
for (int i = 0; i < AMOUNT_OF_SHIELD_AND_SWAP_CARDS; i++) { for (int i = 0; i < AMOUNT_OF_SHIELD_AND_SWAP_CARDS; i++) {
drawPile.add(new Card(BonusCard.SHIELD)); drawPile.add(BonusCard.SWAP);
drawPile.add(new Card(BonusCard.SWAP)); drawPile.add(BonusCard.SHIELD);
} }
board = new Board(); board = new Board();
} }
@@ -117,7 +117,7 @@ public void setGameStatistics(Statistic gameStatistics) {
* *
* @return the draw pile * @return the draw pile
*/ */
public ArrayList<Card> getDrawPile() { public ArrayList<BonusCard> getDrawPile() {
return drawPile; return drawPile;
} }
@@ -126,7 +126,7 @@ public ArrayList<Card> getDrawPile() {
* *
* @param drawPile the new draw pile * @param drawPile the new draw pile
*/ */
public void setDrawPile(ArrayList<Card> drawPile) { public void setDrawPile(ArrayList<BonusCard> drawPile) {
this.drawPile = drawPile; this.drawPile = drawPile;
} }
@@ -135,7 +135,7 @@ public void setDrawPile(ArrayList<Card> drawPile) {
* *
* @return the discard pile * @return the discard pile
*/ */
public ArrayList<Card> getDiscardPile() { public ArrayList<BonusCard> getDiscardPile() {
return discardPile; return discardPile;
} }
@@ -144,7 +144,7 @@ public ArrayList<Card> getDiscardPile() {
* *
* @param discardPile the new discard pile * @param discardPile the new discard pile
*/ */
public void setDiscardPile(ArrayList<Card> discardPile) { public void setDiscardPile(ArrayList<BonusCard> discardPile) {
this.discardPile = discardPile; this.discardPile = discardPile;
} }

View File

@@ -9,7 +9,7 @@ public class Player {
private String name; private String name;
private Statistic playerStatistic; private Statistic playerStatistic;
private ArrayList<Card> handCards; private ArrayList<BonusCard> handCards;
private final int id; private final int id;
/** /**
@@ -53,17 +53,17 @@ public Statistic getPlayerStatistic() {
* *
* @return the handCards of the player * @return the handCards of the player
*/ */
public ArrayList<Card> getHandCards() { public ArrayList<BonusCard> getHandCards() {
return handCards; return handCards;
} }
/** /**
* This method adds a new handCard to the player * This method adds a new handCard to the player
* *
* @param cards the card to be added to the players hand * @param card the card to be added to the players hand
*/ */
public void addHandCards(Card cards){ public void addHandCards(BonusCard card){
handCards.add(cards); handCards.add(card);
} }
/** /**
@@ -72,8 +72,8 @@ public void addHandCards(Card cards){
* @param card the cards type to be removed * @param card the cards type to be removed
* @return the removed card or null if there is none of that card type * @return the removed card or null if there is none of that card type
*/ */
public Card removeHandCard(Card card) { public BonusCard removeHandCard(BonusCard card) {
Card cardToRemove = handCards.stream().filter(card1 -> card1.getType().equals(card.getType())).findFirst().orElse(null); BonusCard cardToRemove = handCards.stream().filter(c -> c.equals(card)).findFirst().orElse(null);
if (cardToRemove != null) { if (cardToRemove != null) {
handCards.remove(cardToRemove); handCards.remove(cardToRemove);
} }

View File

@@ -3,8 +3,10 @@
import com.jme3.network.AbstractMessage; import com.jme3.network.AbstractMessage;
public abstract class ClientMessage extends AbstractMessage { public abstract class ClientMessage extends AbstractMessage {
protected ClientMessage() { protected ClientMessage() {
super(true); super(true);
} }
public abstract void accept(ClientInterpreter interpreter, int from); public abstract void accept(ClientInterpreter interpreter, int from);
} }