fixing Method checkResourceToBuild
This commit is contained in:
parent
da6913d997
commit
4c56518ba0
|
@ -95,10 +95,17 @@ public class Player {
|
||||||
|
|
||||||
|
|
||||||
//returns true if player has enough resources else false
|
//returns true if player has enough resources else false
|
||||||
private boolean checkRessourceToBuild(List<Config.Resource> liste) {
|
private boolean checkResourceToBuild(List<Config.Resource> list) {
|
||||||
for (Config.Resource resource : liste) {
|
HashMap<Config.Resource, Integer> costs = new HashMap<>();
|
||||||
int possesion = resources.get(resource);
|
for(Config.Resource resource : list){
|
||||||
if (possesion == 0) {
|
if(costs.containsKey(resource)){
|
||||||
|
costs.put(resource, costs.get(resource) + 1);
|
||||||
|
} else {
|
||||||
|
costs.put(resource, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Config.Resource resource : costs.keySet()) {
|
||||||
|
if (resources.get(resource) < costs.get(resource)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,5 +113,4 @@ public class Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,11 +479,11 @@ public class SiedlerGame {
|
||||||
*/
|
*/
|
||||||
public boolean tradeWithBankFourToOne(Resource offer, Resource want) {
|
public boolean tradeWithBankFourToOne(Resource offer, Resource want) {
|
||||||
Player player = allPlayers.get(activePlayer);
|
Player player = allPlayers.get(activePlayer);
|
||||||
if(player.getSpecificResource(offer) >= FOUR_TO_ONE_TRADE_OFFER && addResourcesToPlayer(player, want, FOUR_TO_ONE_TRADE_WANT)){
|
if(player.getSpecificResource(offer) >= FOUR_TO_ONE_TRADE_OFFER && addResourcesToPlayer(player, want, FOUR_TO_ONE_TRADE_WANT)){
|
||||||
substractResourceFromPlayer(player, offer, FOUR_TO_ONE_TRADE_OFFER);
|
substractResourceFromPlayer(player, offer, FOUR_TO_ONE_TRADE_OFFER);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue