mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Fikser tre bugs i inlevering av kort
Initialiserer lockedPlayerDeck Gjør det mulig å trekke 0 kort fra en kortstokk til en annen for å unngå problemer når lockedPlayerDeck er tomt Tolker døde roboter som roboter med 0 skade når brukte kort skal leveres inn
This commit is contained in:
parent
db5b4c503a
commit
944f9cd55c
@ -55,8 +55,8 @@ public abstract class Deck<T> implements IDeck<T> {
|
||||
@Override
|
||||
public void draw(IDeck<T> other, int n) {
|
||||
Deck<T> otherDeck = (Deck<T>) other;
|
||||
if (n < 1 || n > otherDeck.size()) {
|
||||
throw new IllegalArgumentException("n can't be below 1 or over the size of the other card deck");
|
||||
if (n < 0 || n > otherDeck.size()) {
|
||||
throw new IllegalArgumentException("n can't be below 0 or over the size of the other card deck");
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
draw(other);
|
||||
|
@ -23,6 +23,7 @@ public class Player {
|
||||
*/
|
||||
public Player(RobotID robotID, String name) {
|
||||
this.playerDeck = new ProgrammingCardDeck(new ArrayList<>());
|
||||
this.lockedPlayerDeck = new ProgrammingCardDeck(new ArrayList<>());
|
||||
this.robotID = robotID;
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -223,7 +223,6 @@ public class RoboRallyGame implements IRoboRallyGame {
|
||||
private void initializeGame(String boardName) {
|
||||
try {
|
||||
List<Robot> robots = new ArrayList<>();
|
||||
//TODO: Find correct robot spawn positions
|
||||
int posX = 1;
|
||||
for (Player player : playerList) {
|
||||
Position spawn = new Position(posX,1);
|
||||
@ -311,7 +310,12 @@ public class RoboRallyGame implements IRoboRallyGame {
|
||||
List<ProgrammingCard> playerProgram = player.getProgram();
|
||||
ProgrammingCardDeck playerDeck = player.getPlayerDeck();
|
||||
ProgrammingCardDeck lockedPlayerDeck = player.getLockedPlayerDeck();
|
||||
int robotDamage = gameBoard.getRobotDamage(player.getRobotID());
|
||||
int robotDamage;
|
||||
if (!gameBoard.isRobotAlive(player.getRobotID())) {
|
||||
robotDamage = 0;
|
||||
} else {
|
||||
robotDamage = gameBoard.getRobotDamage(player.getRobotID());
|
||||
}
|
||||
|
||||
//The player has no locked cards. All previously locked cards should go into the free deck
|
||||
if (robotDamage <= 4) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user