137 lines
3.4 KiB
Java
Raw Normal View History

package inf112.fiasko.roborally.objects;
2020-04-14 15:54:09 +02:00
import inf112.fiasko.roborally.elementproperties.RobotID;
import java.util.ArrayList;
import java.util.List;
2020-03-12 11:24:20 +01:00
/**
* This class represents a player
2020-03-12 11:24:20 +01:00
*/
public class Player {
2020-04-06 17:09:43 +02:00
private RobotID robotID;
private String name;
private boolean powerDownNextRound = false;
private ProgrammingCardDeck playerDeck;
private ProgrammingCardDeck lockedPlayerDeck;
2020-03-12 12:38:00 +01:00
private List <ProgrammingCard> program;
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-04-08 03:16:18 +02:00
this.playerDeck = new ProgrammingCardDeck(new ArrayList<>());
this.lockedPlayerDeck = new ProgrammingCardDeck(new ArrayList<>());
this.robotID = robotID;
this.name = name;
}
/**
* Empty constructor required by kryo
*/
2020-04-06 17:09:43 +02:00
public Player(){}
/**
* Sets the robot id of the robot
* @param robotID The new id of the robot
*/
public void setRobotID(RobotID robotID) {
this.robotID = robotID;
2020-04-06 17:09:43 +02:00
}
/**
* Sets the name of the robot
* @param name The new name of the robot
*/
public void setName(String name) {
this.name = name;
}
/**
* Gives you the RobotID of a player
2020-03-24 11:57:59 +01:00
* @return A RobotID
*/
2020-03-24 11:57:59 +01:00
public RobotID getRobotID() {
return robotID;
}
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-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-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;
}
/**
* Gives you the player deck with locked cards
* @return a deck with locked cards
*/
public ProgrammingCardDeck getLockedPlayerDeck() {
return lockedPlayerDeck;
}
/**
* Set the players locked deck to the given deck
* @param lockedPlayerDeck A deck of locked cards kept by the player
*/
public void setLockedPlayerDeck(ProgrammingCardDeck lockedPlayerDeck) {
this.lockedPlayerDeck = lockedPlayerDeck;
}
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-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-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
}
}
}