added getter for ArrayList Player in Game and created a flag for ready status in Player

This commit is contained in:
Hanno Fleischer
2024-11-25 12:52:22 +01:00
committed by Felix
parent f97eea3e5e
commit eba681c350
2 changed files with 41 additions and 1 deletions

View File

@@ -364,7 +364,7 @@ public void setStartPlayer(Player startPlayer) {
/**
* This method returns the all ready state.
*
* @return the all ready state
* @return the already state
*/
public Boolean allReady() {
return allReady;
@@ -413,4 +413,13 @@ public void addPlayerToList(Player player) {
public void removePlayerFromList(Player player) {
playerList.remove(player);
}
public Player getPlayerFromList(String name) {
for (Player player : playerList) {
if (player.getName().equals(name)) {
return player;
}
}
return null;
}
}

View File

@@ -12,6 +12,7 @@ public class Player {
private ArrayList<BonusCard> handCards;
private final int id;
private Color color;
private boolean isReady;
/**
* This constructor constructs a new Player object
@@ -22,6 +23,18 @@ public Player(int id) {
handCards = new ArrayList<>();
}
/**
* This constructor constructs a new Player object
*
* @param name the name of the player
*/
public Player(String name) {
this.name = name;
playerStatistic = new Statistic();
handCards = new ArrayList<>();
id = 0;
}
/**
* This method returns the give name of the Player
*
@@ -107,4 +120,22 @@ public Color getColor() {
public void setColor(Color color) {
this.color = color;
}
/**
* This method returns if the player is ready
*
* @return true if the player is ready, false otherwise
*/
public boolean isReady() {
return isReady;
}
/**
* This method sets the player to ready
*
* @param ready true if the player is ready, false otherwise
*/
public void setReady(boolean ready) {
isReady = ready;
}
}