mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-24 01:15:03 +00:00
Allow tools to be built multiple times and buildings only once
This commit is contained in:
parent
1a93c5d061
commit
554a3a062e
@ -117,6 +117,8 @@ list-resources
|
||||
build?
|
||||
build steamboat
|
||||
build fireplace
|
||||
build fireplace
|
||||
build axe
|
||||
build axe
|
||||
list-buildings
|
||||
build steamboat
|
||||
|
@ -107,7 +107,10 @@ shack
|
||||
steamboat
|
||||
Error, need fireplace to build
|
||||
OK
|
||||
Error, already built
|
||||
OK
|
||||
OK
|
||||
axe
|
||||
axe
|
||||
fireplace
|
||||
OK
|
||||
|
@ -124,6 +124,8 @@ 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()) {
|
||||
throw new InvalidInputException("already built");
|
||||
} else if (canBuild(item)) {
|
||||
// remove used resources
|
||||
for (Card resource : item.resourcesNeeded()) {
|
||||
|
@ -41,6 +41,10 @@ public enum Item {
|
||||
return this.equals(STEAMBOAT) || this.equals(BALLOON);
|
||||
}
|
||||
|
||||
public boolean canBeBuiltMultipleTimes() {
|
||||
return this.equals(AXE) || this.equals(CLUB);
|
||||
}
|
||||
|
||||
public static Item parse(String input) {
|
||||
switch (input) {
|
||||
case "axe":
|
||||
|
Loading…
Reference in New Issue
Block a user