mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-08 02:59:36 +01:00
fixed some methods in player
This commit is contained in:
parent
a2f861077b
commit
bbfbdb0539
@ -14,23 +14,16 @@ public class Player {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private boolean powerDownNextRound = false;
|
private boolean powerDownNextRound = false;
|
||||||
private ProgrammingCardDeck playerDeck;
|
private ProgrammingCardDeck playerDeck;
|
||||||
private List <ProgrammingCard> program = new ArrayList();
|
private List <ProgrammingCard> program;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new player
|
* Instantiates a new player
|
||||||
* @param robotID the global identifier of the robot
|
* @param robotID the global identifier of the robot
|
||||||
* @param name the unique name of the player
|
* @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) {
|
public Player(RobotID robotID, String name) {
|
||||||
this.robotID = robotID;
|
this.robotID = robotID;
|
||||||
this.name = name;
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +32,14 @@ public class Player {
|
|||||||
*/
|
*/
|
||||||
public RobotID getRobotID(){return robotID;}
|
public RobotID getRobotID(){return robotID;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives you the Name of the player
|
* Gives you the Name of the player
|
||||||
* @return a player Name
|
* @return a player Name
|
||||||
@ -70,32 +71,23 @@ public class Player {
|
|||||||
public void setPowerDownNextRound(boolean powerDownStatus) { this.powerDownNextRound = powerDownStatus;}
|
public void setPowerDownNextRound(boolean powerDownStatus) { this.powerDownNextRound = powerDownStatus;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Places a card in to the player program
|
* Gets the program from the player
|
||||||
* @param card the card that is placed in to the player program
|
* @return List of programing cards
|
||||||
*/
|
*/
|
||||||
public void setCardInProgram(ProgrammingCard card) {
|
public List <ProgrammingCard> getProgramFromPlayer(){
|
||||||
for (int i = 0; i < 5; i++) {
|
return program;
|
||||||
if (program.get(i) == null) {
|
|
||||||
program.add(i, card);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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.
|
* Sets the Players program to the given list of programing cards
|
||||||
* @param cardNr the index of the card that is being removed
|
* @param cardList list the size of 5 with programing cards
|
||||||
* @return the card that was removed from the program
|
|
||||||
*/
|
*/
|
||||||
public ProgrammingCard removeProgramCard(int cardNr) {
|
public void setInProgram(List <ProgrammingCard> cardList){
|
||||||
if(cardNr<5 && cardNr>-1) {
|
if(cardList.size() != 5){
|
||||||
program.add(cardNr, null);
|
throw new IllegalArgumentException("list must contain 5 programing cards");
|
||||||
return program.remove(cardNr + 1);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalArgumentException("cant remove more then index 4 or remove negatives");
|
program = new ArrayList<>(cardList);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user