refactoring Method storeResourcesToBank
This commit is contained in:
parent
038bc65b3d
commit
b758e08fdb
|
@ -12,10 +12,8 @@ public class Bank {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeResourceToBank(List<Config.Resource> resourceToGive) {
|
public void storeResourceToBank(Config.Resource resource, int numberOfResources) {
|
||||||
for (Config.Resource resource : resourceToGive) {
|
resources.put(resource,resources.get(resource)+numberOfResources);
|
||||||
resources.put(resource,resources.get(resource)+1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getResourceFromBank(Config.Resource resource,int numberOfResources) {
|
public boolean getResourceFromBank(Config.Resource resource,int numberOfResources) {
|
||||||
|
|
|
@ -86,11 +86,7 @@ public class SiedlerGame {
|
||||||
|
|
||||||
private boolean substractResourceFromPlayer(Player player, Resource resource, int numberToSubstract){
|
private boolean substractResourceFromPlayer(Player player, Resource resource, int numberToSubstract){
|
||||||
if(player.substractResource(resource, numberToSubstract)){
|
if(player.substractResource(resource, numberToSubstract)){
|
||||||
ArrayList<Config.Resource> resourcesForBank = new ArrayList<>();
|
bank.storeResourceToBank(resource, numberToSubstract);
|
||||||
for(int i = 0; i < numberToSubstract; i++){
|
|
||||||
resourcesForBank.add(resource);
|
|
||||||
}
|
|
||||||
bank.storeResourceToBank(resourcesForBank);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue