Skip to content

Commit

Permalink
enhance empty players creation
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed Jan 1, 2024
1 parent a786bd1 commit 9e7fd80
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/main/java/armameeldoparti/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -94,20 +94,14 @@ public static void main(String[] args) {
* Populates the players sets with empty players.
*/
private static void populatePlayersSets() {
for (Position position : Position.values()) {
List<Player> playersSet = new ArrayList<>();
Arrays.stream(Position.values())
.forEach(position -> CommonFields.getPlayersSets()
.put(position, IntStream.range(0, CommonFields.getPlayersAmountMap()
.get(position) * 2)
.mapToObj(i -> new Player("", position))
.collect(Collectors.toList())));
}

int totalPlayersInPosition = CommonFields.getPlayersAmountMap()
.get(position) * 2;

for (int i = 0; i < totalPlayersInPosition; i++) {
playersSet.add(new Player("", position));
}

CommonFields.getPlayersSets()
.put(position, playersSet);
}
}

/**
* Gets the number of players for each position per team using regular expressions.
Expand Down

0 comments on commit 9e7fd80

Please sign in to comment.