mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-24 09:24:57 +00:00
93 lines
2.1 KiB
Java
93 lines
2.1 KiB
Java
package edu.kit.informatik.model;
|
|
|
|
public enum Card {
|
|
WOOD,
|
|
METAL,
|
|
PLASTIC,
|
|
SPIDER,
|
|
SNAKE,
|
|
TIGER,
|
|
THUNDERSTORM;
|
|
|
|
public boolean isResource() {
|
|
return this.equals(WOOD) || this.equals(METAL) || this.equals(PLASTIC);
|
|
}
|
|
|
|
public boolean needsDiceRoll() {
|
|
return this.equals(SPIDER) || this.equals(SNAKE) || this.equals(TIGER);
|
|
}
|
|
|
|
public int diceSizeNeeded() {
|
|
switch (this) {
|
|
case SPIDER:
|
|
return 4;
|
|
case SNAKE:
|
|
return 6;
|
|
case TIGER:
|
|
return 8;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public int minimumDiceRollNeeded() {
|
|
switch (this) {
|
|
case SPIDER:
|
|
return 3;
|
|
case SNAKE:
|
|
return 4;
|
|
case TIGER:
|
|
return 5;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public boolean isCatastrophe() {
|
|
return this.equals(THUNDERSTORM);
|
|
}
|
|
|
|
public static Card parse(String input) {
|
|
switch (input) {
|
|
case "wood":
|
|
return WOOD;
|
|
case "metal":
|
|
return METAL;
|
|
case "plastic":
|
|
return PLASTIC;
|
|
case "spider":
|
|
return SPIDER;
|
|
case "snake":
|
|
return SNAKE;
|
|
case "tiger":
|
|
return TIGER;
|
|
case "thunderstorm":
|
|
return THUNDERSTORM;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
switch (this) {
|
|
case WOOD:
|
|
return "wood";
|
|
case METAL:
|
|
return "metal";
|
|
case PLASTIC:
|
|
return "plastic";
|
|
case SPIDER:
|
|
return "spider";
|
|
case SNAKE:
|
|
return "snake";
|
|
case TIGER:
|
|
return "tiger";
|
|
case THUNDERSTORM:
|
|
return "thunderstorm";
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
}
|