mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Shuffling player seats in multi player
This commit is contained in:
parent
fce6756d77
commit
9c6dc78842
2 changed files with 14 additions and 5 deletions
|
@ -389,10 +389,15 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||||
} else {
|
} else {
|
||||||
int current = getPlayersCount(tableView);
|
int current = getPlayersCount(tableView);
|
||||||
if (current != count) {
|
if (current != count) {
|
||||||
count = current;
|
|
||||||
if (count > 0) {
|
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);
|
dialog.update(tableView);
|
||||||
|
|
|
@ -28,9 +28,6 @@
|
||||||
|
|
||||||
package mage.game.match;
|
package mage.game.match;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.GameException;
|
import mage.game.GameException;
|
||||||
|
@ -40,6 +37,8 @@ import mage.game.events.TableEvent.EventType;
|
||||||
import mage.game.events.TableEventSource;
|
import mage.game.events.TableEventSource;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -132,6 +131,7 @@ public abstract class MatchImpl implements Match {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initGame(Game game) throws GameException {
|
protected void initGame(Game game) throws GameException {
|
||||||
|
shufflePlayers();
|
||||||
for (MatchPlayer matchPlayer: this.players) {
|
for (MatchPlayer matchPlayer: this.players) {
|
||||||
matchPlayer.getPlayer().init(game);
|
matchPlayer.getPlayer().init(game);
|
||||||
game.loadCards(matchPlayer.getDeck().getCards(), matchPlayer.getPlayer().getId());
|
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
|
@Override
|
||||||
public void endGame() {
|
public void endGame() {
|
||||||
Game game = getGame();
|
Game game = getGame();
|
||||||
|
|
Loading…
Reference in a new issue