2020-03-10 16:02:34 +01:00
|
|
|
package inf112.fiasko.roborally.objects;
|
|
|
|
|
|
|
|
import inf112.fiasko.roborally.element_properties.RobotID;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* This Class represents a player
|
|
|
|
*/
|
|
|
|
|
2020-03-10 16:02:34 +01:00
|
|
|
public class Player {
|
|
|
|
private final RobotID robotID;
|
|
|
|
private final String name;
|
|
|
|
private boolean powerDownNextRound = false;
|
|
|
|
private ProgrammingCardDeck playerDeck;
|
2020-03-12 12:38:00 +01:00
|
|
|
private List <ProgrammingCard> program;
|
2020-03-10 16:02:34 +01:00
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new player
|
|
|
|
* @param robotID the global identifier of the robot
|
|
|
|
* @param name the unique name of the player
|
|
|
|
*/
|
2020-03-12 12:38:00 +01:00
|
|
|
public Player(RobotID robotID, String name) {
|
2020-03-10 16:02:34 +01:00
|
|
|
this.robotID = robotID;
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gives you the RobotID of a player
|
2020-03-24 11:57:59 +01:00
|
|
|
* @return A RobotID
|
2020-03-10 16:02:34 +01:00
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public RobotID getRobotID() {
|
|
|
|
return robotID;
|
|
|
|
}
|
2020-03-10 16:02:34 +01:00
|
|
|
|
2020-03-12 12:38:00 +01:00
|
|
|
/**
|
|
|
|
* Set the players deck to the given deck
|
2020-03-24 11:57:59 +01:00
|
|
|
* @param playerDeck A deck of cards given to the player
|
2020-03-12 12:38:00 +01:00
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public void setPlayerDeck(ProgrammingCardDeck playerDeck) {
|
|
|
|
this.playerDeck = playerDeck;
|
2020-03-12 12:38:00 +01:00
|
|
|
}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Gives you the Name of the player
|
2020-03-24 11:57:59 +01:00
|
|
|
* @return A player Name
|
2020-03-12 11:24:20 +01:00
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
2020-03-10 16:02:34 +01:00
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Gives you the players program
|
2020-03-24 11:57:59 +01:00
|
|
|
* @return A list of programming cards
|
2020-03-12 11:24:20 +01:00
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public List<ProgrammingCard> getProgram() {
|
|
|
|
return program;
|
|
|
|
}
|
2020-03-10 16:02:34 +01:00
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Gives you the player hand/deck
|
|
|
|
* @return a deck
|
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public ProgrammingCardDeck getPlayerDeck() {
|
|
|
|
return playerDeck;
|
|
|
|
}
|
2020-03-10 16:02:34 +01:00
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
2020-03-24 11:57:59 +01:00
|
|
|
* Gives you the players power down status
|
|
|
|
* @return Whether the player is to power down
|
2020-03-12 11:24:20 +01:00
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public boolean getPowerDownNextRound() {
|
|
|
|
return powerDownNextRound;
|
|
|
|
}
|
2020-03-10 16:02:34 +01:00
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
2020-03-24 11:57:59 +01:00
|
|
|
* Sets the power down status
|
|
|
|
* @param powerDownStatus Whether the player is to take power down next round
|
2020-03-12 11:24:20 +01:00
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public void setPowerDownNextRound(boolean powerDownStatus) {
|
|
|
|
this.powerDownNextRound = powerDownStatus;
|
2020-03-10 16:02:34 +01:00
|
|
|
}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
2020-03-12 12:38:00 +01:00
|
|
|
* Sets the Players program to the given list of programing cards
|
|
|
|
* @param cardList list the size of 5 with programing cards
|
2020-03-12 11:24:20 +01:00
|
|
|
*/
|
2020-03-24 11:57:59 +01:00
|
|
|
public void setInProgram(List <ProgrammingCard> cardList) {
|
|
|
|
if (cardList.size() != 5) {
|
2020-03-12 12:38:00 +01:00
|
|
|
throw new IllegalArgumentException("list must contain 5 programing cards");
|
2020-03-24 11:57:59 +01:00
|
|
|
} else {
|
2020-03-12 12:38:00 +01:00
|
|
|
program = new ArrayList<>(cardList);
|
2020-03-12 11:24:20 +01:00
|
|
|
}
|
2020-03-10 16:02:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|