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

View File

@ -112,6 +112,8 @@ public class CardGame {
public String build(Item item) throws LogicException { public String build(Item item) throws LogicException {
if (item == null) { if (item == null) {
throw new LogicException("can not build item"); 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)) { } else if (item.requiresFireplace() && !items.contains(FIREPLACE)) {
throw new LogicException("need fireplace to build"); throw new LogicException("need fireplace to build");
} else if (items.contains(item)) { } else if (items.contains(item)) {