mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-09 18:30:38 +00:00
Print lose if no moves available
This commit is contained in:
parent
f94ddddc9b
commit
e13ee8430f
@ -78,4 +78,5 @@ survived
|
||||
tiger
|
||||
survived
|
||||
thunderstorm
|
||||
lose
|
||||
Error, can not get resources: game not started
|
||||
|
@ -77,7 +77,7 @@ public class CardGame {
|
||||
items.remove(FIREPLACE);
|
||||
}
|
||||
if (currentCardStack.isEmpty() && getBuildableItems().isEmpty()) {
|
||||
currentCardStack = null; // game over
|
||||
endGame(); // TODO: somehow print "lose" ??? (after the card!) [awaiting ILIAS..]
|
||||
}
|
||||
return card;
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class CardGame {
|
||||
// remove item used to escape
|
||||
items.remove(items.size() - 1);
|
||||
if (roll >= minimumNeeded) {
|
||||
win();
|
||||
endGame();
|
||||
return "win";
|
||||
} else {
|
||||
return "lose";
|
||||
@ -135,16 +135,16 @@ public class CardGame {
|
||||
items.add(item);
|
||||
if (item.equals(STEAMBOAT) || item.equals(BALLOON)) {
|
||||
// player won
|
||||
win();
|
||||
endGame();
|
||||
return "win";
|
||||
} else if (item.equals(SAILING_RAFT) || item.equals(HANG_GLIDER)) {
|
||||
// need at least a 4/d6
|
||||
fightingAnimal = false;
|
||||
awaitedDiceSize = 6;
|
||||
minimumDiceRoll = 4;
|
||||
}
|
||||
if (currentCardStack != null && currentCardStack.isEmpty() && getBuildableItems().isEmpty()) {
|
||||
currentCardStack = null; // game over
|
||||
} else if (currentCardStack != null && currentCardStack.isEmpty() && getBuildableItems().isEmpty()) {
|
||||
endGame();
|
||||
return "lose";
|
||||
}
|
||||
return "OK";
|
||||
} else {
|
||||
@ -198,7 +198,7 @@ public class CardGame {
|
||||
return Arrays.stream(Item.values()).filter(this::canBuild).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private void win() {
|
||||
private void endGame() {
|
||||
currentCardStack = null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user