mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-24 01:15:03 +00:00
Only output win when winning
This commit is contained in:
parent
72c9922c44
commit
f94ddddc9b
@ -111,4 +111,4 @@ OK
|
|||||||
axe
|
axe
|
||||||
axe
|
axe
|
||||||
fireplace
|
fireplace
|
||||||
OK
|
win
|
||||||
|
@ -74,7 +74,7 @@ shack
|
|||||||
fireplace
|
fireplace
|
||||||
club
|
club
|
||||||
axe
|
axe
|
||||||
OK
|
win
|
||||||
Error, can not get buildings: game not started
|
Error, can not get buildings: game not started
|
||||||
Error, can not get resources: game not started
|
Error, can not get resources: game not started
|
||||||
Error, can not get buildable items: game not started
|
Error, can not get buildable items: game not started
|
||||||
|
@ -120,7 +120,7 @@ public class CardGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean build(Item item) throws InvalidInputException {
|
public String build(Item item) throws InvalidInputException {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
throw new InvalidInputException("can not build item");
|
throw new InvalidInputException("can not build item");
|
||||||
} else if (item.requiresFireplace() && !items.contains(FIREPLACE)) {
|
} else if (item.requiresFireplace() && !items.contains(FIREPLACE)) {
|
||||||
@ -136,6 +136,7 @@ public class CardGame {
|
|||||||
if (item.equals(STEAMBOAT) || item.equals(BALLOON)) {
|
if (item.equals(STEAMBOAT) || item.equals(BALLOON)) {
|
||||||
// player won
|
// player won
|
||||||
win();
|
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;
|
||||||
@ -145,9 +146,9 @@ public class CardGame {
|
|||||||
if (currentCardStack != null && currentCardStack.isEmpty() && getBuildableItems().isEmpty()) {
|
if (currentCardStack != null && currentCardStack.isEmpty() && getBuildableItems().isEmpty()) {
|
||||||
currentCardStack = null; // game over
|
currentCardStack = null; // game over
|
||||||
}
|
}
|
||||||
return true;
|
return "OK";
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,11 @@ public final class Build extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(CardGame game) throws InvalidInputException {
|
public void apply(CardGame game) throws InvalidInputException {
|
||||||
if (game.build(item)) {
|
final String result = game.build(item);
|
||||||
Terminal.printLine("OK");
|
if (result == null) {
|
||||||
} else {
|
|
||||||
Terminal.printError("could not build item");
|
Terminal.printError("could not build item");
|
||||||
|
} else {
|
||||||
|
Terminal.printLine(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user