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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue