Files
Gruppe-01-fin/Projekte/mdga/model/src/main/java/pp.mdga/game/Player.java
Hanno Fleischer 9bafd749b6 removed card and fixed codes style
removed card because it was unnecessary and reworked all classes containing it to implement the change
2024-11-14 15:49:22 +01:00

83 lines
2.0 KiB
Java

package pp.mdga.game;
import java.util.ArrayList;
/**
* This class will be used to handle general PlayerData
*/
public class Player {
private String name;
private Statistic playerStatistic;
private ArrayList<BonusCard> handCards;
private final int id;
/**
* This constructor constructs a new Player object
*/
public Player(int id) {
this.id = id;
playerStatistic = new Statistic();
handCards = new ArrayList<>();
}
/**
* This method returns the give name of the Player
*
* @return the name of the player as a String
*/
public String getName() {
return name;
}
/**
* This method sets the name of the player
*
* @param name the new name of the player
*/
public void setName(String name) {
this.name = name;
}
/**
* This methode returns the statistics of the player
*
* @return the statistics of the player
*/
public Statistic getPlayerStatistic() {
return playerStatistic;
}
/**
* This method returns the current handCards of the player
*
* @return the handCards of the player
*/
public ArrayList<BonusCard> getHandCards() {
return handCards;
}
/**
* This method adds a new handCard to the player
*
* @param card the card to be added to the players hand
*/
public void addHandCards(BonusCard card){
handCards.add(card);
}
/**
* This method returns a BonusCard to be removed from the players hand.
*
* @param card the cards type to be removed
* @return the removed card or null if there is none of that card type
*/
public BonusCard removeHandCard(BonusCard card) {
BonusCard cardToRemove = handCards.stream().filter(c -> c.equals(card)).findFirst().orElse(null);
if (cardToRemove != null) {
handCards.remove(cardToRemove);
}
return cardToRemove;
}
}