diff --git a/src/edu/kit/informatik/model/CardGame.java b/src/edu/kit/informatik/model/CardGame.java index f9be260..15b4bf7 100644 --- a/src/edu/kit/informatik/model/CardGame.java +++ b/src/edu/kit/informatik/model/CardGame.java @@ -51,7 +51,7 @@ public class CardGame { public Card draw() throws LogicException { if (currentCardStack == null || currentCardStack.isEmpty()) { throw new LogicException("no card to draw exists"); - } else if (awaitedDiceSize != null) { + } else if (awaitingDiceRoll()) { throw new LogicException("roll dice, please"); } final Card card = currentCardStack.removeFirst(); @@ -72,7 +72,7 @@ public class CardGame { } public String rollDice(int size, int roll) throws LogicException { - if (awaitedDiceSize == null) { + if (!awaitingDiceRoll()) { throw new LogicException("not expecting dice roll"); } else if (awaitedDiceSize != size) { throw new LogicException("unexpected dice size"); @@ -164,6 +164,10 @@ public class CardGame { return currentCardStack != null; } + private boolean awaitingDiceRoll() { + return awaitedDiceSize != null; + } + public Deque getResources() throws LogicException { if (!gameStarted()) { throw new LogicException("can not get resources: game not started"); @@ -184,6 +188,9 @@ public class CardGame { if (!gameStarted()) { throw new LogicException("can not get buildable items: game not started"); } + if (awaitingDiceRoll()) { + throw new LogicException("can not get buildable items: awaiting dice roll"); + } return Arrays.stream(Item.values()).filter(this::canBuild).collect(Collectors.toSet()); }