From 8e0dfcda80b4dd04121bda40cfad48be9845bebb Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 1 Nov 2014 01:58:18 +0100 Subject: [PATCH] * Draft fixed a bug that mismatched the player draft order if a player was replaced by draftbot. --- Mage/src/mage/game/draft/DraftImpl.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Mage/src/mage/game/draft/DraftImpl.java b/Mage/src/mage/game/draft/DraftImpl.java index 7528bb29bb..3093c69e1a 100644 --- a/Mage/src/mage/game/draft/DraftImpl.java +++ b/Mage/src/mage/game/draft/DraftImpl.java @@ -30,6 +30,7 @@ package mage.game.draft; import java.util.Collection; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -52,7 +53,7 @@ import mage.players.PlayerList; public abstract class DraftImpl implements Draft { protected final UUID id; - protected final Map players = new HashMap<>(); + protected final Map players = new LinkedHashMap<>(); protected final PlayerList table = new PlayerList(); protected int numberBoosters; protected DraftCube draftCube; @@ -96,8 +97,7 @@ public abstract class DraftImpl implements Draft { DraftPlayer newDraftPlayer = new DraftPlayer(newPlayer); DraftPlayer oldDraftPlayer = players.get(oldPlayer.getId()); newDraftPlayer.setBooster(oldDraftPlayer.getBooster()); - Map newPlayers = new HashMap<>(); - PlayerList newTable = new PlayerList(); + Map newPlayers = new LinkedHashMap<>(); synchronized (players) { for(Map.Entry entry :players.entrySet()) { if (entry.getKey().equals(oldPlayer.getId())) { @@ -112,15 +112,15 @@ public abstract class DraftImpl implements Draft { } } synchronized (table) { - for(UUID playerId :table) { - if (playerId.equals(oldPlayer.getId())) { - newTable.add(newPlayer.getId()); - } else { - newTable.add(playerId); - } + UUID currentId = table.get(); + if (currentId.equals(oldPlayer.getId())) { + currentId = newPlayer.getId(); } table.clear(); - table.addAll(newTable); + for(UUID playerId : players.keySet()) { + table.add(playerId); + } + table.setCurrent(currentId); } if (oldDraftPlayer.isPicking()) { newDraftPlayer.setPicking();