mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-24 01:15:03 +00:00
Only print buildable items if they can be built in addition to existing
This commit is contained in:
parent
58f30fbf39
commit
6c8f172d3f
@ -115,6 +115,7 @@ build?
|
||||
build axe
|
||||
build club
|
||||
build fireplace
|
||||
build?
|
||||
build shack
|
||||
build sailingraft
|
||||
rollD6 1
|
||||
|
@ -56,6 +56,13 @@ shack
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
axe
|
||||
ballon
|
||||
club
|
||||
hangglider
|
||||
sailingraft
|
||||
shack
|
||||
steamboat
|
||||
OK
|
||||
OK
|
||||
lose
|
||||
|
@ -124,7 +124,7 @@ public class CardGame {
|
||||
throw new InvalidInputException("can not build item");
|
||||
} else if (item.requiresFireplace() && !items.contains(FIREPLACE)) {
|
||||
throw new InvalidInputException("need fireplace to build");
|
||||
} else if (items.contains(item) && !item.canBeBuiltMultipleTimes()) {
|
||||
} else if (items.contains(item) && !item.canHaveMoreThanOne()) {
|
||||
throw new InvalidInputException("already built");
|
||||
} else if (canBuild(item)) {
|
||||
// remove used resources
|
||||
@ -154,6 +154,9 @@ public class CardGame {
|
||||
if (item.requiresFireplace() && !items.contains(FIREPLACE)) {
|
||||
return false;
|
||||
}
|
||||
if (!item.canHaveMoreThanOne() && items.contains(item)) {
|
||||
return false;
|
||||
}
|
||||
final Card[] resourcesNeeded = item.resourcesNeeded();
|
||||
for (final Card resource : resources) {
|
||||
for (int j = 0; j < resourcesNeeded.length; j++) {
|
||||
|
@ -41,7 +41,7 @@ public enum Item {
|
||||
return this.equals(STEAMBOAT) || this.equals(BALLOON);
|
||||
}
|
||||
|
||||
public boolean canBeBuiltMultipleTimes() {
|
||||
public boolean canHaveMoreThanOne() {
|
||||
return this.equals(AXE) || this.equals(CLUB);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user