Javadoc + code cleanup

This commit is contained in:
Arne Keller 2020-03-12 23:01:32 +01:00
parent b42d783127
commit ae79b31f3d
2 changed files with 25 additions and 14 deletions

View File

@ -1,12 +1,33 @@
package edu.kit.informatik.cardgame.model;
public enum Card {
/**
* Wood. Basic resource.
*/
WOOD,
/**
* Metal. Basic resource.
*/
METAL,
/**
* Plastic. Basic resource.
*/
PLASTIC,
/**
* Spider. Deadly animal.
*/
SPIDER,
/**
* Snake. Dangerous animal.
*/
SNAKE,
/**
* Tiger. Strong animal.
*/
TIGER,
/**
* Thunderstorm. Lifts up items and blows them away.
*/
THUNDERSTORM;
public CardCategory category() {
@ -22,18 +43,10 @@ public enum Card {
case THUNDERSTORM:
return CardCategory.CATASTROPHE;
default:
return null;
throw new IllegalArgumentException("no category defined for this card");
}
}
public boolean isResource() {
return this.equals(WOOD) || this.equals(METAL) || this.equals(PLASTIC);
}
public boolean needsDiceRoll() {
return this.diceSizeNeeded() > 0;
}
public int diceSizeNeeded() {
switch (this) {
case SPIDER:
@ -60,10 +73,6 @@ public enum Card {
}
}
public boolean isCatastrophe() {
return this.equals(THUNDERSTORM);
}
public int requiredAmount() {
switch (this) {
case WOOD:
@ -120,7 +129,7 @@ public enum Card {
case THUNDERSTORM:
return "thunderstorm";
default:
return null;
throw new IllegalArgumentException("toString not defined for this card value");
}
}
}

View File

@ -58,6 +58,8 @@ public class CardGame {
clearResources();
items.remove(Item.FIREPLACE);
break;
default:
throw new IllegalStateException("encountered unknown card category!");
}
checkLost();
return card;