Skip to content

Commit

Permalink
Fix ticking player elimination not being sensitive to immutable colle…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
haykam821 committed Jun 25, 2024
1 parent d0827e2 commit a47ee4d
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.github.haykam821.beaconbreakers.game.player.team;

import java.util.Collection;
import java.util.Iterator;
import java.util.HashSet;
import java.util.Set;

import io.github.haykam821.beaconbreakers.game.phase.BeaconBreakersActivePhase;
import io.github.haykam821.beaconbreakers.game.player.BeaconPlacement;
Expand Down Expand Up @@ -32,16 +33,18 @@ public final void setBeacon(BeaconPlacement beacon) {
}

public final void tick() {
Iterator<PlayerEntry> iterator = this.getPlayers().iterator();

while (iterator.hasNext()) {
PlayerEntry entry = iterator.next();
Set<PlayerEntry> removed = new HashSet<>();

for (PlayerEntry entry : this.getPlayers()) {
if (entry.tick()) {
this.getPhase().applyEliminationToPlayer(entry);
iterator.remove();
removed.add(entry);
}
}

for (PlayerEntry entry : removed) {
this.removePlayer(entry);
}
}

// Messages
Expand Down

0 comments on commit a47ee4d

Please sign in to comment.