mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Draft fixed a bug that mismatched the player draft order if a player was replaced by draftbot.
This commit is contained in:
parent
2a2c593dd8
commit
8e0dfcda80
1 changed files with 10 additions and 10 deletions
|
@ -30,6 +30,7 @@ package mage.game.draft;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -52,7 +53,7 @@ import mage.players.PlayerList;
|
||||||
public abstract class DraftImpl implements Draft {
|
public abstract class DraftImpl implements Draft {
|
||||||
|
|
||||||
protected final UUID id;
|
protected final UUID id;
|
||||||
protected final Map<UUID, DraftPlayer> players = new HashMap<>();
|
protected final Map<UUID, DraftPlayer> players = new LinkedHashMap<>();
|
||||||
protected final PlayerList table = new PlayerList();
|
protected final PlayerList table = new PlayerList();
|
||||||
protected int numberBoosters;
|
protected int numberBoosters;
|
||||||
protected DraftCube draftCube;
|
protected DraftCube draftCube;
|
||||||
|
@ -96,8 +97,7 @@ public abstract class DraftImpl implements Draft {
|
||||||
DraftPlayer newDraftPlayer = new DraftPlayer(newPlayer);
|
DraftPlayer newDraftPlayer = new DraftPlayer(newPlayer);
|
||||||
DraftPlayer oldDraftPlayer = players.get(oldPlayer.getId());
|
DraftPlayer oldDraftPlayer = players.get(oldPlayer.getId());
|
||||||
newDraftPlayer.setBooster(oldDraftPlayer.getBooster());
|
newDraftPlayer.setBooster(oldDraftPlayer.getBooster());
|
||||||
Map<UUID, DraftPlayer> newPlayers = new HashMap<>();
|
Map<UUID, DraftPlayer> newPlayers = new LinkedHashMap<>();
|
||||||
PlayerList newTable = new PlayerList();
|
|
||||||
synchronized (players) {
|
synchronized (players) {
|
||||||
for(Map.Entry<UUID, DraftPlayer> entry :players.entrySet()) {
|
for(Map.Entry<UUID, DraftPlayer> entry :players.entrySet()) {
|
||||||
if (entry.getKey().equals(oldPlayer.getId())) {
|
if (entry.getKey().equals(oldPlayer.getId())) {
|
||||||
|
@ -112,15 +112,15 @@ public abstract class DraftImpl implements Draft {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronized (table) {
|
synchronized (table) {
|
||||||
for(UUID playerId :table) {
|
UUID currentId = table.get();
|
||||||
if (playerId.equals(oldPlayer.getId())) {
|
if (currentId.equals(oldPlayer.getId())) {
|
||||||
newTable.add(newPlayer.getId());
|
currentId = newPlayer.getId();
|
||||||
} else {
|
|
||||||
newTable.add(playerId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
table.clear();
|
table.clear();
|
||||||
table.addAll(newTable);
|
for(UUID playerId : players.keySet()) {
|
||||||
|
table.add(playerId);
|
||||||
|
}
|
||||||
|
table.setCurrent(currentId);
|
||||||
}
|
}
|
||||||
if (oldDraftPlayer.isPicking()) {
|
if (oldDraftPlayer.isPicking()) {
|
||||||
newDraftPlayer.setPicking();
|
newDraftPlayer.setPicking();
|
||||||
|
|
Loading…
Reference in a new issue