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 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 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; } /** * Returns the id of the connection to the client represented by this player. * * @return the id */ public int getId() { return id; } }