diff --git a/Mage.Client/sounds/OnPlayerLeft.wav b/Mage.Client/sounds/OnPlayerLeft.wav index 78ba0a785b..d0a73d6577 100644 Binary files a/Mage.Client/sounds/OnPlayerLeft.wav and b/Mage.Client/sounds/OnPlayerLeft.wav differ diff --git a/Mage.Client/sounds/OnPlayerQuit.wav b/Mage.Client/sounds/OnPlayerQuit.wav new file mode 100644 index 0000000000..df359d5b9f Binary files /dev/null and b/Mage.Client/sounds/OnPlayerQuit.wav differ diff --git a/Mage.Client/sounds/OnPlayerQuitTournament.wav b/Mage.Client/sounds/OnPlayerQuitTournament.wav new file mode 100644 index 0000000000..e78a05fba5 Binary files /dev/null and b/Mage.Client/sounds/OnPlayerQuitTournament.wav differ diff --git a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java index 2b3f5f2338..b868bdb355 100644 --- a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java +++ b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java @@ -114,6 +114,9 @@ public class CallbackClientImpl implements CallbackClient { case PlayerLeft: AudioManager.playPlayerLeft(); break; + case PlayerQuitTournament: + AudioManager.playPlayerQuitTournament(); + break; case PlayerSubmittedDeck: AudioManager.playPlayerSubmittedDeck(); break; diff --git a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java index 0945953532..17e9b3067a 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java @@ -41,6 +41,7 @@ public class AudioManager { private MageClip playerSubmittedDeck = null; private MageClip playerWhispered = null; private MageClip playerLeft = null; + private MageClip playerQuitTournament = null; private MageClip playerWon = null; private MageClip playerLost = null; /** @@ -222,6 +223,14 @@ public class AudioManager { checkAndPlayClip(getManager().playerLeft); } + public static void playPlayerQuitTournament() { + if(audioManager.playerQuitTournament== null) { + audioManager.playerQuitTournament = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerQuitTournament.wav"), + AudioGroup.OtherSounds); + } + checkAndPlayClip(getManager().playerQuitTournament); + } + public static void playPlayerLost() { if(audioManager.playerLost == null) { audioManager.playerLost = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerLost.wav"), @@ -261,6 +270,7 @@ public class AudioManager { public void play(final Clip clip) { new Thread(new Runnable() { + @Override public void run() { clip.setFramePosition(0); clip.start(); diff --git a/Mage.Common/src/mage/view/ChatMessage.java b/Mage.Common/src/mage/view/ChatMessage.java index 873ebce28d..a0dbd1e1d8 100644 --- a/Mage.Common/src/mage/view/ChatMessage.java +++ b/Mage.Common/src/mage/view/ChatMessage.java @@ -53,7 +53,7 @@ public class ChatMessage implements Serializable { } public enum SoundToPlay { - PlayerLeft, PlayerSubmittedDeck, PlayerWhispered; + PlayerLeft, PlayerQuitTournament, PlayerSubmittedDeck, PlayerWhispered; } public ChatMessage(String username, String message, String time, MessageColor color) { diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index 415fc8fcf9..f0186b6ae6 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -70,6 +70,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import mage.game.Game; +import mage.view.ChatMessage; /** @@ -387,7 +388,12 @@ public class TableController { match.leave(playerId); } User user = UserManager.getInstance().getUser(userId); - user.removeTable(playerId); + if (user != null) { + ChatManager.getInstance().broadcast(chatId, user.getName(), "has left the table", ChatMessage.MessageColor.BLUE, true, ChatMessage.MessageType.STATUS, ChatMessage.SoundToPlay.PlayerLeft); + user.removeTable(playerId); + } else { + logger.debug("TableController.leaveTable user with this userId not found userId: " + userId); + } userPlayerMap.remove(userId); } else if (!table.getState().equals(TableState.FINISHED)) { if (table.isTournament()) { diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java index 47bf8aca3b..6b710076be 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java @@ -305,7 +305,7 @@ public class TournamentController { if (tPlayer != null) { if (started) { if (tPlayer.isInTournament()) { - ChatManager.getInstance().broadcast(chatId, "", tPlayer.getPlayer().getName() + " has quit the tournament", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerLeft); + ChatManager.getInstance().broadcast(chatId, "", tPlayer.getPlayer().getName() + " has quit the tournament", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerQuitTournament); String info; if (tournament.isDoneConstructing()) { info = new StringBuilder("during round ").append(tournament.getRounds().size()).toString();