refactoring Method storeResourcesToBank

This commit is contained in:
schrom01 2021-12-07 13:57:33 +01:00
parent 038bc65b3d
commit b758e08fdb
2 changed files with 3 additions and 9 deletions

View File

@ -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) {

View File

@ -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;