diff --git a/src/ch/zhaw/catan/Bank.java b/src/ch/zhaw/catan/Bank.java index 6b498c4..0eedb95 100644 --- a/src/ch/zhaw/catan/Bank.java +++ b/src/ch/zhaw/catan/Bank.java @@ -21,10 +21,10 @@ public class Bank { } } - public boolean tradeWithBank(Config.Resource resourceToReceive, Config.Resource resourceToGive) { - if(resources.get(resourceToReceive) >= 1){ - Integer newResourceReceived = resources.get(resourceToReceive) + 4; - Integer newResourcesGiven = resources.get(resourceToGive) - 1; + public boolean tradeWithBank(Config.Resource resourceToReceive, Config.Resource resourceToGive, int toWant, int toGive) { + if(resources.get(resourceToReceive) >= toWant){ + Integer newResourceReceived = resources.get(resourceToReceive) + toGive; + Integer newResourcesGiven = resources.get(resourceToGive) - toWant; resources.put(resourceToReceive, newResourceReceived); resources.put(resourceToGive, newResourcesGiven); return true; diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java index b76c075..a0d6431 100644 --- a/src/ch/zhaw/catan/SiedlerGame.java +++ b/src/ch/zhaw/catan/SiedlerGame.java @@ -27,7 +27,7 @@ public class SiedlerGame { private SiedlerBoard board; private Player[] allPlayers; private int winPoints; - + private Bank bank; /** * Constructs a SiedlerGame game state object. * @@ -38,6 +38,7 @@ public class SiedlerGame { * three or players is not between two and four */ public SiedlerGame(int winPoints, int numberOfPlayers) { + bank = new Bank(); board = new SiedlerBoard(); board.createFixGamefield(); allPlayers = new Player[numberOfPlayers]; @@ -248,7 +249,7 @@ public class SiedlerGame { */ public boolean tradeWithBankFourToOne(Resource offer, Resource want) { // TODO: Implement - return false; + return bank.tradeWithBank(want,offer, FOUR_TO_ONE_TRADE_WANT, FOUR_TO_ONE_TRADE_OFFER); } /**