diff --git a/game1_output.txt b/game1_output.txt index 73cf9cc..3a0f466 100644 --- a/game1_output.txt +++ b/game1_output.txt @@ -111,4 +111,4 @@ OK axe axe fireplace -OK +win diff --git a/game2_output.txt b/game2_output.txt index b6acd5c..bfc6500 100644 --- a/game2_output.txt +++ b/game2_output.txt @@ -74,7 +74,7 @@ shack fireplace club axe -OK +win Error, can not get buildings: game not started Error, can not get resources: game not started Error, can not get buildable items: game not started diff --git a/src/edu/kit/informatik/model/CardGame.java b/src/edu/kit/informatik/model/CardGame.java index 0bfa414..7de1abc 100644 --- a/src/edu/kit/informatik/model/CardGame.java +++ b/src/edu/kit/informatik/model/CardGame.java @@ -120,7 +120,7 @@ public class CardGame { } } - public boolean build(Item item) throws InvalidInputException { + public String build(Item item) throws InvalidInputException { if (item == null) { throw new InvalidInputException("can not build item"); } else if (item.requiresFireplace() && !items.contains(FIREPLACE)) { @@ -136,6 +136,7 @@ public class CardGame { if (item.equals(STEAMBOAT) || item.equals(BALLOON)) { // player won win(); + return "win"; } else if (item.equals(SAILING_RAFT) || item.equals(HANG_GLIDER)) { // need at least a 4/d6 fightingAnimal = false; @@ -145,9 +146,9 @@ public class CardGame { if (currentCardStack != null && currentCardStack.isEmpty() && getBuildableItems().isEmpty()) { currentCardStack = null; // game over } - return true; + return "OK"; } else { - return false; + return null; } } diff --git a/src/edu/kit/informatik/ui/command/Build.java b/src/edu/kit/informatik/ui/command/Build.java index b0816d9..5aec171 100644 --- a/src/edu/kit/informatik/ui/command/Build.java +++ b/src/edu/kit/informatik/ui/command/Build.java @@ -21,10 +21,11 @@ public final class Build extends Command { @Override public void apply(CardGame game) throws InvalidInputException { - if (game.build(item)) { - Terminal.printLine("OK"); - } else { + final String result = game.build(item); + if (result == null) { Terminal.printError("could not build item"); + } else { + Terminal.printLine(result); } }