mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-01 07:39:35 +01:00
Added comments to Player
This commit is contained in:
parent
9c5a50d74a
commit
4f9d58152c
@ -5,6 +5,10 @@ import inf112.fiasko.roborally.element_properties.RobotID;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This Class represents a player
|
||||
*/
|
||||
|
||||
public class Player {
|
||||
private final RobotID robotID;
|
||||
private final String name;
|
||||
@ -12,11 +16,21 @@ public class Player {
|
||||
private ProgrammingCardDeck playerDeck;
|
||||
private List <ProgrammingCard> program = new ArrayList();
|
||||
|
||||
// Constructor for the player class, it get assigned a Robot, a player nam and a deck
|
||||
/**
|
||||
* Instantiates a new player
|
||||
* @param robotID the global identifier of the robot
|
||||
* @param name the unique name of the player
|
||||
* @param playerDeck the hand of cards dealt to the player
|
||||
*/
|
||||
public Player(RobotID robotID, String name, ProgrammingCardDeck playerDeck) {
|
||||
this.robotID = robotID;
|
||||
this.name = name;
|
||||
this.playerDeck = playerDeck;
|
||||
program.add(0, null); //sets the initial values in program to null
|
||||
program.add(1, null);
|
||||
program.add(2, null);
|
||||
program.add(3, null);
|
||||
program.add(4, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,22 +39,42 @@ public class Player {
|
||||
*/
|
||||
public RobotID getRobotID(){return robotID;}
|
||||
|
||||
/**
|
||||
* Gives you the Name of the player
|
||||
* @return a player Name
|
||||
*/
|
||||
public String getName() {return name;}
|
||||
|
||||
/**
|
||||
* Gives you the players program
|
||||
* @return a list<ProgrammingCard>
|
||||
*/
|
||||
public List<ProgrammingCard> getProgram() {return program;}
|
||||
|
||||
/**
|
||||
* Gives you the player hand/deck
|
||||
* @return a deck
|
||||
*/
|
||||
public ProgrammingCardDeck getPlayerDeck() {return playerDeck;}
|
||||
|
||||
/**
|
||||
* Gives you the players powerdown status
|
||||
* @return a boolean
|
||||
*/
|
||||
public boolean getPowerDownNextRound() { return powerDownNextRound;}
|
||||
|
||||
/**
|
||||
* Sets the prowerdown status
|
||||
* @param powerDownStatus the boolean that determines if it goes to a powerdown or not
|
||||
*/
|
||||
public void setPowerDownNextRound(boolean powerDownStatus) { this.powerDownNextRound = powerDownStatus;}
|
||||
|
||||
/**
|
||||
* Places a card in to the player program
|
||||
* @param card the card that is placed in to the player program
|
||||
*/
|
||||
public void setCardInProgram(ProgrammingCard card) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (program.size() == 0) {
|
||||
program.add(i, card);
|
||||
return;
|
||||
}
|
||||
if (program.get(i) == null) {
|
||||
program.add(i, card);
|
||||
return;
|
||||
@ -49,10 +83,20 @@ public class Player {
|
||||
throw new IllegalArgumentException("Program deck is full,tried to add to many cards");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes a card by the given index from the player program and returns it.
|
||||
* @param cardNr the index of the card that is being removed
|
||||
* @return the card that was removed from the program
|
||||
*/
|
||||
public ProgrammingCard removeProgramCard(int cardNr) {
|
||||
if(cardNr<5 && cardNr>-1) {
|
||||
program.add(cardNr, null);
|
||||
return program.remove(cardNr + 1);
|
||||
}
|
||||
else{
|
||||
throw new IllegalArgumentException("cant remove more then index 4 or remove negatives");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user