mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-08 18:00:37 +00:00
Javadoc + code cleanup
This commit is contained in:
parent
b42d783127
commit
ae79b31f3d
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ public class CardGame {
|
||||
clearResources();
|
||||
items.remove(Item.FIREPLACE);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("encountered unknown card category!");
|
||||
}
|
||||
checkLost();
|
||||
return card;
|
||||
|
Loading…
Reference in New Issue
Block a user