From adbd1bca9481ae2f6032b3c65b6ef6ace0350657 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 6 Feb 2015 00:23:01 +0100 Subject: [PATCH] * Imporoved release of draft object during draft tournament. --- .../src/main/java/mage/server/TableController.java | 9 ++++++--- .../src/main/java/mage/server/draft/DraftController.java | 6 ++++++ Mage/src/mage/game/tournament/Tournament.java | 2 ++ Mage/src/mage/game/tournament/TournamentImpl.java | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index 9d7ebc31d2..11ec5a1a55 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -823,10 +823,13 @@ public class TableController { } public void endDraft(Draft draft) { - for (DraftPlayer player: draft.getPlayers()) { - player.prepareDeck(); - tournament.getPlayer(player.getPlayer().getId()).setDeck(player.getDeck()); + if (!draft.isAbort()) { + for (DraftPlayer player: draft.getPlayers()) { + player.prepareDeck(); + tournament.getPlayer(player.getPlayer().getId()).setDeck(player.getDeck()); + } } + tournament.clearDraft(); // free the draft resources after draft step has ended tournament.nextStep(); } diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftController.java b/Mage.Server/src/main/java/mage/server/draft/DraftController.java index c2efed6945..b96417b679 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftController.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftController.java @@ -198,6 +198,7 @@ public class DraftController { draftSession.removeDraft(); } TableManager.getInstance().endDraft(tableId, draft); + DraftManager.getInstance().removeDraft(draft.getId()); } public void kill(UUID userId) { @@ -259,5 +260,10 @@ public class DraftController { public void abortDraft() { draft.setAbort(true); + try { + endDraft(); + } catch(MageException ex) { + + } } } diff --git a/Mage/src/mage/game/tournament/Tournament.java b/Mage/src/mage/game/tournament/Tournament.java index f9398aeebf..7aba250105 100644 --- a/Mage/src/mage/game/tournament/Tournament.java +++ b/Mage/src/mage/game/tournament/Tournament.java @@ -95,5 +95,7 @@ public interface Tournament { void cleanUpOnTournamentEnd(); boolean isAbort(); void setAbort(boolean abort); + + void clearDraft(); Draft getDraft(); } diff --git a/Mage/src/mage/game/tournament/TournamentImpl.java b/Mage/src/mage/game/tournament/TournamentImpl.java index 3b15e9e90c..85c2e51ec8 100644 --- a/Mage/src/mage/game/tournament/TournamentImpl.java +++ b/Mage/src/mage/game/tournament/TournamentImpl.java @@ -503,6 +503,11 @@ public abstract class TournamentImpl implements Tournament { this.stepStartTime = stepStartTime; } + @Override + public void clearDraft() { + draft = null; + } + @Override public Draft getDraft() { return draft;