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