Only build items when not expecting dice roll

This commit is contained in:
Arne Keller 2020-03-11 11:13:25 +01:00
parent 1e95394391
commit e7c3a40ac0
2 changed files with 11 additions and 9 deletions

View File

@ -28,7 +28,7 @@ wood
spider
Error, roll dice, please
wood
Error, could not build item
Error, awaiting dice roll, can not build
Error, unknown command
EMPTY
Error, can not get buildable items: awaiting dice roll
@ -38,7 +38,7 @@ survived
snake
Error, roll dice, please
wood
Error, could not build item
Error, awaiting dice roll, can not build
Error, unknown command
EMPTY
Error, can not get buildable items: awaiting dice roll
@ -48,7 +48,7 @@ survived
tiger
Error, roll dice, please
wood
Error, could not build item
Error, awaiting dice roll, can not build
Error, unknown command
EMPTY
Error, can not get buildable items: awaiting dice roll
@ -166,16 +166,16 @@ sailingraft
shack
steamboat
spider
<e
<e
Error, awaiting dice roll, can not build
Error, can not get buildable items: awaiting dice roll
survived
OK
spider
<e
<e
Error, awaiting dice roll, can not build
Error, can not get buildable items: awaiting dice roll
survived
OK
spider
<e
<e
Error, awaiting dice roll, can not build
Error, can not get buildable items: awaiting dice roll
survived

View File

@ -112,6 +112,8 @@ public class CardGame {
public String build(Item item) throws LogicException {
if (item == null) {
throw new LogicException("can not build item");
} else if (awaitingDiceRoll()) {
throw new LogicException("awaiting dice roll, can not build");
} else if (item.requiresFireplace() && !items.contains(FIREPLACE)) {
throw new LogicException("need fireplace to build");
} else if (items.contains(item)) {