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
|
|
|
|
* @return An RobotID
|
|
|
|
*/
|
|
|
|
public RobotID getRobotID(){return robotID;}
|
|
|
|
|
2020-03-12 12:38:00 +01:00
|
|
|
/**
|
|
|
|
* Set the players deck to the given deck
|
|
|
|
* @param playerDeck a deck of cards given to the player
|
|
|
|
*/
|
|
|
|
public void setPlayerDeck(ProgrammingCardDeck playerDeck){
|
|
|
|
this.playerDeck=playerDeck;
|
|
|
|
}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Gives you the Name of the player
|
|
|
|
* @return a player Name
|
|
|
|
*/
|
2020-03-10 16:02:34 +01:00
|
|
|
public String getName() {return name;}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Gives you the players program
|
|
|
|
* @return a list<ProgrammingCard>
|
|
|
|
*/
|
2020-03-10 16:02:34 +01:00
|
|
|
public List<ProgrammingCard> getProgram() {return program;}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Gives you the player hand/deck
|
|
|
|
* @return a deck
|
|
|
|
*/
|
2020-03-10 16:02:34 +01:00
|
|
|
public ProgrammingCardDeck getPlayerDeck() {return playerDeck;}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Gives you the players powerdown status
|
|
|
|
* @return a boolean
|
|
|
|
*/
|
2020-03-10 16:02:34 +01:00
|
|
|
public boolean getPowerDownNextRound() { return powerDownNextRound;}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
|
|
|
* Sets the prowerdown status
|
|
|
|
* @param powerDownStatus the boolean that determines if it goes to a powerdown or not
|
|
|
|
*/
|
2020-03-10 16:02:34 +01:00
|
|
|
public void setPowerDownNextRound(boolean powerDownStatus) { this.powerDownNextRound = powerDownStatus;}
|
|
|
|
|
2020-03-12 11:24:20 +01:00
|
|
|
/**
|
2020-03-12 12:38:00 +01:00
|
|
|
* Gets the program from the player
|
|
|
|
* @return List of programing cards
|
2020-03-12 11:24:20 +01:00
|
|
|
*/
|
2020-03-12 12:38:00 +01:00
|
|
|
public List <ProgrammingCard> getProgramFromPlayer(){
|
|
|
|
return program;
|
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-12 12:38:00 +01:00
|
|
|
public void setInProgram(List <ProgrammingCard> cardList){
|
|
|
|
if(cardList.size() != 5){
|
|
|
|
throw new IllegalArgumentException("list must contain 5 programing cards");
|
2020-03-12 11:24:20 +01:00
|
|
|
}
|
2020-03-12 12:38:00 +01:00
|
|
|
else {
|
|
|
|
program = new ArrayList<>(cardList);
|
2020-03-12 11:24:20 +01:00
|
|
|
}
|
2020-03-10 16:02:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|