From 9c6dc788424ca346e31135c98bb3ff94c3f13e55 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Wed, 18 Jul 2012 12:12:12 +0400 Subject: [PATCH] Shuffling player seats in multi player --- .../java/mage/client/dialog/TableWaitingDialog.java | 9 +++++++-- Mage/src/mage/game/match/MatchImpl.java | 10 +++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java index 5b9ea99c66..7093443f52 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java @@ -389,10 +389,15 @@ class UpdateSeatsTask extends SwingWorker { } else { int current = getPlayersCount(tableView); if (current != count) { - count = current; if (count > 0) { - MageTray.getInstance().blink(); + if (current > count) { + MageTray.getInstance().displayMessage("New player joined your game."); + } else { + MageTray.getInstance().displayMessage("A player left your game."); + } + MageTray.getInstance().blink(); } + count = current; } } dialog.update(tableView); diff --git a/Mage/src/mage/game/match/MatchImpl.java b/Mage/src/mage/game/match/MatchImpl.java index 24db7ccbdc..5150956907 100644 --- a/Mage/src/mage/game/match/MatchImpl.java +++ b/Mage/src/mage/game/match/MatchImpl.java @@ -28,9 +28,6 @@ package mage.game.match; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.cards.decks.Deck; import mage.game.Game; import mage.game.GameException; @@ -40,6 +37,8 @@ import mage.game.events.TableEvent.EventType; import mage.game.events.TableEventSource; import mage.players.Player; +import java.util.*; + /** * * @author BetaSteward_at_googlemail.com @@ -132,6 +131,7 @@ public abstract class MatchImpl implements Match { } protected void initGame(Game game) throws GameException { + shufflePlayers(); for (MatchPlayer matchPlayer: this.players) { matchPlayer.getPlayer().init(game); game.loadCards(matchPlayer.getDeck().getCards(), matchPlayer.getPlayer().getId()); @@ -140,6 +140,10 @@ public abstract class MatchImpl implements Match { } } + protected void shufflePlayers() { + Collections.shuffle(this.players, new Random()); + } + @Override public void endGame() { Game game = getGame();