finished Method tradeWithBankFourToOne
Modified Class Bank to work with mentioned Method
This commit is contained in:
parent
2f9f93d862
commit
c4c30670b4
|
@ -21,10 +21,10 @@ public class Bank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tradeWithBank(Config.Resource resourceToReceive, Config.Resource resourceToGive) {
|
public boolean tradeWithBank(Config.Resource resourceToReceive, Config.Resource resourceToGive, int toWant, int toGive) {
|
||||||
if(resources.get(resourceToReceive) >= 1){
|
if(resources.get(resourceToReceive) >= toWant){
|
||||||
Integer newResourceReceived = resources.get(resourceToReceive) + 4;
|
Integer newResourceReceived = resources.get(resourceToReceive) + toGive;
|
||||||
Integer newResourcesGiven = resources.get(resourceToGive) - 1;
|
Integer newResourcesGiven = resources.get(resourceToGive) - toWant;
|
||||||
resources.put(resourceToReceive, newResourceReceived);
|
resources.put(resourceToReceive, newResourceReceived);
|
||||||
resources.put(resourceToGive, newResourcesGiven);
|
resources.put(resourceToGive, newResourcesGiven);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class SiedlerGame {
|
||||||
private SiedlerBoard board;
|
private SiedlerBoard board;
|
||||||
private Player[] allPlayers;
|
private Player[] allPlayers;
|
||||||
private int winPoints;
|
private int winPoints;
|
||||||
|
private Bank bank;
|
||||||
/**
|
/**
|
||||||
* Constructs a SiedlerGame game state object.
|
* Constructs a SiedlerGame game state object.
|
||||||
*
|
*
|
||||||
|
@ -38,6 +38,7 @@ public class SiedlerGame {
|
||||||
* three or players is not between two and four
|
* three or players is not between two and four
|
||||||
*/
|
*/
|
||||||
public SiedlerGame(int winPoints, int numberOfPlayers) {
|
public SiedlerGame(int winPoints, int numberOfPlayers) {
|
||||||
|
bank = new Bank();
|
||||||
board = new SiedlerBoard();
|
board = new SiedlerBoard();
|
||||||
board.createFixGamefield();
|
board.createFixGamefield();
|
||||||
allPlayers = new Player[numberOfPlayers];
|
allPlayers = new Player[numberOfPlayers];
|
||||||
|
@ -248,7 +249,7 @@ public class SiedlerGame {
|
||||||
*/
|
*/
|
||||||
public boolean tradeWithBankFourToOne(Resource offer, Resource want) {
|
public boolean tradeWithBankFourToOne(Resource offer, Resource want) {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return false;
|
return bank.tradeWithBank(want,offer, FOUR_TO_ONE_TRADE_WANT, FOUR_TO_ONE_TRADE_OFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue