Collection<Chips> betsFromFoldedPlayers) {
Collections.sort(allInPlayers);
LinkedList<MutableAllInPlayer> allInPlayersQueue = new LinkedList<MutableAllInPlayer>(allInPlayers);
while (!allInPlayersQueue.isEmpty()) {
MutableAllInPlayer allInPlayer = allInPlayersQueue.poll();
MutablePot currentPot = pots.element();
if (allInPlayer.getBetValue() > 0) {
pots.addFirst(currentPot.createPot());
currentPot.collectChips(allInPlayer.getBetValue());
for (Chips c : betsFromFoldedPlayers) {
if (c.getValue() > allInPlayer.getBetValue()) {
c.transferAmountTo(allInPlayer.getBetValue(), currentPot.getChips());
} else {
c.transferAllChipsTo(currentPot.getChips());
betsFromFoldedPlayers.remove(c);
}
}
}
pots.element().removeContributor(allInPlayer.getPlayer());
}
if (pots.element().getNbContributors() == 0) {
pots.removeFirst();
}
}