From 58f30fbf3917cc5f7f20d7f711f05b2509076aad Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Tue, 3 Mar 2020 18:12:37 +0100 Subject: [PATCH] Only print buildable items that require a fireplace if one exists --- game1_output.txt | 2 -- game2_output.txt | 2 -- src/edu/kit/informatik/model/CardGame.java | 3 +++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/game1_output.txt b/game1_output.txt index 82961c8..73cf9cc 100644 --- a/game1_output.txt +++ b/game1_output.txt @@ -98,13 +98,11 @@ wood wood wood axe -ballon club fireplace hangglider sailingraft shack -steamboat Error, need fireplace to build OK Error, already built diff --git a/game2_output.txt b/game2_output.txt index b2f0841..87efd12 100644 --- a/game2_output.txt +++ b/game2_output.txt @@ -48,13 +48,11 @@ plastic plastic plastic axe -ballon club fireplace hangglider sailingraft shack -steamboat OK OK OK diff --git a/src/edu/kit/informatik/model/CardGame.java b/src/edu/kit/informatik/model/CardGame.java index 5116c96..0eeb1ae 100644 --- a/src/edu/kit/informatik/model/CardGame.java +++ b/src/edu/kit/informatik/model/CardGame.java @@ -151,6 +151,9 @@ public class CardGame { } private boolean canBuild(Item item) { + if (item.requiresFireplace() && !items.contains(FIREPLACE)) { + return false; + } final Card[] resourcesNeeded = item.resourcesNeeded(); for (final Card resource : resources) { for (int j = 0; j < resourcesNeeded.length; j++) {