mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
more draft/sealed fixes
This commit is contained in:
parent
e189543699
commit
fabcc28e46
16 changed files with 171 additions and 86 deletions
|
@ -276,7 +276,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
tOptions.setTournamentType(tournamentType.getName());
|
||||
tOptions.getPlayerTypes().add("Human");
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
tOptions.getPlayerTypes().add(player.getPlayerType());
|
||||
tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem());
|
||||
}
|
||||
if (tournamentType.isDraft()) {
|
||||
DraftOptions options = new DraftOptions();
|
||||
|
@ -347,12 +347,33 @@ public class NewTournamentDialog extends MageDialog {
|
|||
pack.setModel(new DefaultComboBoxModel(Sets.getInstance().values().toArray()));
|
||||
pnlPacks.add(pack);
|
||||
packs.add(pack);
|
||||
pack.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
packActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void packActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
boolean start = false;
|
||||
int selectedIndex = 0;
|
||||
for (JComboBox pack: packs) {
|
||||
if (!start) {
|
||||
if (evt.getSource().equals(pack)) {
|
||||
start = true;
|
||||
selectedIndex = pack.getSelectedIndex();
|
||||
}
|
||||
}
|
||||
else {
|
||||
pack.setSelectedIndex(selectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createPlayers(int numPlayers) {
|
||||
if (numPlayers > players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
|
@ -373,12 +394,33 @@ public class NewTournamentDialog extends MageDialog {
|
|||
this.pnlOtherPlayers.removeAll();
|
||||
for (TournamentPlayerPanel panel: players) {
|
||||
this.pnlOtherPlayers.add(panel);
|
||||
panel.getPlayerType().addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
playerActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void playerActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
boolean start = false;
|
||||
int selectedIndex = 0;
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
if (!start) {
|
||||
if (evt.getSource().equals(player.getPlayerType())) {
|
||||
start = true;
|
||||
selectedIndex = player.getPlayerType().getSelectedIndex();
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.getPlayerType().setSelectedIndex(selectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TableView getTable() {
|
||||
return table;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ package mage.client.table;
|
|||
|
||||
import java.util.UUID;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.remote.Session;
|
||||
|
||||
|
@ -59,8 +60,8 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
|||
this.lblPlayerNum.setText("Player " + playerNum);
|
||||
}
|
||||
|
||||
public String getPlayerType() {
|
||||
return (String) this.cbPlayerType.getSelectedItem();
|
||||
public JComboBox getPlayerType() {
|
||||
return this.cbPlayerType;
|
||||
}
|
||||
|
||||
public boolean joinTournamentTable(UUID roomId, UUID tableId) {
|
||||
|
|
|
@ -57,6 +57,7 @@ import mage.choices.ChoiceImpl;
|
|||
import mage.filter.common.FilterCreatureForCombat;
|
||||
import mage.game.Game;
|
||||
import mage.game.Table;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.target.Target;
|
||||
|
@ -482,8 +483,8 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sideboard(Table table, Deck deck) {
|
||||
table.fireSideboardEvent(playerId, deck);
|
||||
public void sideboard(Match match, Deck deck) {
|
||||
match.fireSideboardEvent(playerId, deck);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#Generated by Maven
|
||||
#Sat Feb 12 11:24:53 MSK 2011
|
||||
version=0.6
|
||||
groupId=org.mage
|
||||
artifactId=Mage-Tournament-BoosterDraft
|
Binary file not shown.
Binary file not shown.
|
@ -66,7 +66,6 @@ import mage.game.match.MatchOptions;
|
|||
import mage.game.match.MatchPlayer;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.game.tournament.TournamentPlayer;
|
||||
import mage.players.Player;
|
||||
import mage.server.game.DeckValidatorFactory;
|
||||
import mage.server.game.GameFactory;
|
||||
|
@ -85,15 +84,12 @@ public class TableController {
|
|||
|
||||
private final static Logger logger = Logging.getLogger(TableController.class.getName());
|
||||
|
||||
private static final int SIDEBOARD_TIME = 180;
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID chatId;
|
||||
private Table table;
|
||||
private Match match;
|
||||
private MatchOptions options;
|
||||
private Tournament tournament;
|
||||
private TournamentOptions tournamentOptions;
|
||||
private ConcurrentHashMap<UUID, UUID> sessionPlayerMap = new ConcurrentHashMap<UUID, UUID>();
|
||||
|
||||
public TableController(UUID sessionId, MatchOptions options) {
|
||||
|
@ -108,24 +104,19 @@ public class TableController {
|
|||
public TableController(UUID sessionId, TournamentOptions options) {
|
||||
this.sessionId = sessionId;
|
||||
chatId = ChatManager.getInstance().createChatSession();
|
||||
this.tournamentOptions = options;
|
||||
tournament = TournamentFactory.getInstance().createTournament(options.getTournamentType(), options);
|
||||
table = new Table(options.getTournamentType(), options.getName(), DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), true);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
table.addTableEventListener(
|
||||
match.addTableEventListener(
|
||||
new Listener<TableEvent> () {
|
||||
@Override
|
||||
public void event(TableEvent event) {
|
||||
switch (event.getEventType()) {
|
||||
case SIDEBOARD:
|
||||
sideboard(event.getPlayerId(), event.getDeck());
|
||||
sideboard(event.getPlayerId(), event.getDeck(), event.getTimeout());
|
||||
break;
|
||||
// case CONSTRUCT:
|
||||
// construct(event.getPlayerId(), event.getDeck());
|
||||
// break;
|
||||
case SUBMIT_DECK:
|
||||
submitDeck(event.getPlayerId(), event.getDeck());
|
||||
break;
|
||||
|
@ -209,8 +200,7 @@ public class TableController {
|
|||
|
||||
private void submitDeck(UUID sessionId, Deck deck) {
|
||||
if (table.getState() == TableState.SIDEBOARDING) {
|
||||
MatchPlayer player = match.getPlayer(sessionPlayerMap.get(sessionId));
|
||||
player.submitDeck(deck);
|
||||
match.submitDeck(sessionPlayerMap.get(sessionId), deck);
|
||||
}
|
||||
else {
|
||||
TournamentManager.getInstance().submitDeck(tournament.getId(), sessionId, deck);
|
||||
|
@ -262,7 +252,13 @@ public class TableController {
|
|||
}
|
||||
|
||||
public synchronized void startMatch(UUID sessionId) {
|
||||
if (sessionId.equals(this.sessionId) && table.getState() == TableState.STARTING) {
|
||||
if (sessionId.equals(this.sessionId)) {
|
||||
startMatch();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void startMatch() {
|
||||
if (table.getState() == TableState.STARTING) {
|
||||
try {
|
||||
match.startMatch();
|
||||
startGame(null);
|
||||
|
@ -284,7 +280,6 @@ public class TableController {
|
|||
|
||||
public synchronized void startTournament(UUID sessionId) {
|
||||
if (sessionId.equals(this.sessionId) && table.getState() == TableState.STARTING) {
|
||||
table.initTournament();
|
||||
TournamentManager.getInstance().createTournamentSession(tournament, sessionPlayerMap, table.getId());
|
||||
SessionManager sessionManager = SessionManager.getInstance();
|
||||
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
|
@ -302,42 +297,19 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
|
||||
private void sideboard() {
|
||||
table.sideboard();
|
||||
for (MatchPlayer player: match.getPlayers()) {
|
||||
player.setSideboarding();
|
||||
player.getPlayer().sideboard(table, player.getDeck());
|
||||
}
|
||||
while (!match.isDoneSideboarding()){}
|
||||
}
|
||||
|
||||
private void sideboard(UUID playerId, Deck deck) {
|
||||
private void sideboard(UUID playerId, Deck deck, int timeout) {
|
||||
SessionManager sessionManager = SessionManager.getInstance();
|
||||
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
if (entry.getValue().equals(playerId)) {
|
||||
sessionManager.getSession(entry.getKey()).sideboard(deck, table.getId(), SIDEBOARD_TIME);
|
||||
sessionManager.getSession(entry.getKey()).sideboard(deck, table.getId(), timeout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public void construct() {
|
||||
// table.construct();
|
||||
// for (TournamentPlayer player: tournament.getPlayers()) {
|
||||
// player.setConstructing();
|
||||
// player.getPlayer().construct(table, player.getDeck());
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void construct(UUID playerId, Deck deck) {
|
||||
// SessionManager sessionManager = SessionManager.getInstance();
|
||||
// for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
// if (entry.getValue().equals(playerId)) {
|
||||
// sessionManager.getSession(entry.getKey()).construct(deck, table.getId(), CONSTRUCT_TIME);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public void construct() {
|
||||
table.construct();
|
||||
}
|
||||
|
||||
public void endGame() {
|
||||
UUID choosingPlayerId = match.getChooser();
|
||||
|
@ -347,7 +319,8 @@ public class TableController {
|
|||
GameManager.getInstance().removeGame(match.getGame().getId());
|
||||
try {
|
||||
if (!match.isMatchOver()) {
|
||||
sideboard();
|
||||
table.sideboard();
|
||||
match.sideboard();
|
||||
startGame(choosingPlayerId);
|
||||
}
|
||||
} catch (GameException ex) {
|
||||
|
@ -433,4 +406,5 @@ public class TableController {
|
|||
public Match getMatch() {
|
||||
return match;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,13 @@ public class TableManager {
|
|||
return tableController.getTable();
|
||||
}
|
||||
|
||||
public Table createTable(MatchOptions options) {
|
||||
TableController tableController = new TableController(UUID.randomUUID(), options);
|
||||
controllers.put(tableController.getTable().getId(), tableController);
|
||||
tables.put(tableController.getTable().getId(), tableController.getTable());
|
||||
return tableController.getTable();
|
||||
}
|
||||
|
||||
public Table createTournamentTable(UUID sessionId, TournamentOptions options) {
|
||||
TableController tableController = new TableController(sessionId, options);
|
||||
controllers.put(tableController.getTable().getId(), tableController);
|
||||
|
@ -127,6 +134,10 @@ public class TableManager {
|
|||
controllers.get(tableId).startMatch(sessionId);
|
||||
}
|
||||
|
||||
public void startMatch(UUID roomId, UUID tableId) {
|
||||
controllers.get(tableId).startMatch();
|
||||
}
|
||||
|
||||
public void startTournament(UUID sessionId, UUID roomId, UUID tableId) {
|
||||
controllers.get(tableId).startTournament(sessionId);
|
||||
}
|
||||
|
@ -161,11 +172,12 @@ public class TableManager {
|
|||
}
|
||||
}
|
||||
|
||||
// public void construct(UUID tableId) {
|
||||
// controllers.get(tableId).construct();
|
||||
// }
|
||||
public void construct(UUID tableId) {
|
||||
controllers.get(tableId).construct();
|
||||
}
|
||||
|
||||
public void addPlayer(UUID sessionId, UUID tableId, Player player, String playerType, Deck deck) throws GameException {
|
||||
controllers.get(tableId).addPlayer(sessionId, player, playerType, deck);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,8 +66,6 @@ public class TournamentController {
|
|||
private ConcurrentHashMap<UUID, UUID> sessionPlayerMap = new ConcurrentHashMap<UUID, UUID>();
|
||||
private ConcurrentHashMap<UUID, TournamentSession> tournamentSessions = new ConcurrentHashMap<UUID, TournamentSession>();
|
||||
|
||||
private static final int CONSTRUCT_TIME = 600;
|
||||
|
||||
public TournamentController(Tournament tournament, ConcurrentHashMap<UUID, UUID> sessionPlayerMap, UUID tableId) {
|
||||
sessionId = UUID.randomUUID();
|
||||
this.sessionPlayerMap = sessionPlayerMap;
|
||||
|
@ -96,6 +94,9 @@ public class TournamentController {
|
|||
case SUBMIT_DECK:
|
||||
submitDeck(event.getPlayerId(), event.getDeck());
|
||||
break;
|
||||
case CONSTRUCT:
|
||||
construct();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,12 +171,12 @@ public class TournamentController {
|
|||
private void startMatch(TournamentPairing pair, MatchOptions matchOptions) {
|
||||
try {
|
||||
TableManager tableManager = TableManager.getInstance();
|
||||
Table table = tableManager.createTable(sessionId, matchOptions);
|
||||
Table table = tableManager.createTable(matchOptions);
|
||||
TournamentPlayer player1 = pair.getPlayer1();
|
||||
TournamentPlayer player2 = pair.getPlayer2();
|
||||
tableManager.addPlayer(getPlayerSessionId(player1.getPlayer().getId()), table.getId(), player1.getPlayer(), player1.getPlayerType(), player1.getDeck());
|
||||
tableManager.addPlayer(getPlayerSessionId(player2.getPlayer().getId()), table.getId(), player2.getPlayer(), player2.getPlayerType(), player2.getDeck());
|
||||
tableManager.startMatch(sessionId, null, table.getId());
|
||||
tableManager.startMatch(null, table.getId());
|
||||
pair.setMatch(tableManager.getMatch(table.getId()));
|
||||
} catch (GameException ex) {
|
||||
Logger.getLogger(TournamentController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
@ -186,12 +187,15 @@ public class TournamentController {
|
|||
TableManager.getInstance().startDraft(tableId, draft);
|
||||
}
|
||||
|
||||
private void construct() {
|
||||
TableManager.getInstance().construct(tableId);
|
||||
}
|
||||
|
||||
private synchronized void construct(UUID sessionId, Deck deck, int timeout) {
|
||||
if (tournamentSessions.containsKey(sessionId))
|
||||
tournamentSessions.get(sessionId).construct(deck, timeout);
|
||||
}
|
||||
|
||||
|
||||
public void submitDeck(UUID sessionId, Deck deck) {
|
||||
tournamentSessions.get(sessionPlayerMap.get(sessionId)).submitDeck(deck);
|
||||
}
|
||||
|
|
|
@ -84,10 +84,18 @@ public class Table implements Serializable {
|
|||
state = TableState.DUELING;
|
||||
}
|
||||
|
||||
public void initTournament() {
|
||||
state = TableState.DUELING;
|
||||
}
|
||||
|
||||
public void initDraft() {
|
||||
state = TableState.DRAFTING;
|
||||
}
|
||||
|
||||
public void construct() {
|
||||
state = TableState.CONSTRUCTING;
|
||||
}
|
||||
|
||||
public void endGame() {
|
||||
state = TableState.FINISHED;
|
||||
}
|
||||
|
@ -157,24 +165,8 @@ public class Table implements Serializable {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
public void fireSideboardEvent(UUID playerId, Deck deck) {
|
||||
tableEventSource.fireTableEvent(EventType.SIDEBOARD, playerId, deck);
|
||||
}
|
||||
|
||||
public void fireConstructEvent(UUID playerId, Deck deck) {
|
||||
tableEventSource.fireTableEvent(EventType.CONSTRUCT, playerId, deck);
|
||||
}
|
||||
|
||||
public void fireSubmitDeckEvent(UUID playerId, Deck deck) {
|
||||
tableEventSource.fireTableEvent(EventType.SUBMIT_DECK, playerId, deck);
|
||||
}
|
||||
|
||||
public void addTableEventListener(Listener<TableEvent> listener) {
|
||||
tableEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
public void initTournament() {
|
||||
state = TableState.CONSTRUCTING;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
|||
private Deck deck;
|
||||
private TournamentPairing pair;
|
||||
private MatchOptions options;
|
||||
private int timeout;
|
||||
|
||||
public TableEvent(EventType eventType) {
|
||||
super(eventType);
|
||||
|
@ -70,11 +71,12 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
|||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public TableEvent(EventType eventType, UUID playerId, Deck deck) {
|
||||
public TableEvent(EventType eventType, UUID playerId, Deck deck, int timeout) {
|
||||
super(playerId);
|
||||
this.playerId = playerId;
|
||||
this.deck = deck;
|
||||
this.eventType = eventType;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public TableEvent(EventType eventType, String message, Draft draft) {
|
||||
|
@ -126,4 +128,8 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
|||
public MatchOptions getMatchOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
|||
dispatcher.fireEvent(new TableEvent(eventType, message, cards, game));
|
||||
}
|
||||
|
||||
public void fireTableEvent(EventType eventType, UUID playerId, Deck deck) {
|
||||
dispatcher.fireEvent(new TableEvent(eventType, playerId, deck));
|
||||
public void fireTableEvent(EventType eventType, UUID playerId, Deck deck, int timeout) {
|
||||
dispatcher.fireEvent(new TableEvent(eventType, playerId, deck, timeout));
|
||||
}
|
||||
|
||||
public void fireTableEvent(EventType eventType, TournamentPairing pair, MatchOptions options) {
|
||||
|
|
|
@ -33,6 +33,8 @@ import java.util.UUID;
|
|||
import mage.cards.decks.Deck;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameException;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.TableEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
@ -46,8 +48,10 @@ public interface Match {
|
|||
public List<MatchPlayer> getPlayers();
|
||||
public MatchPlayer getPlayer(UUID playerId);
|
||||
public void addPlayer(Player player, Deck deck);
|
||||
public void submitDeck(UUID playerId, Deck deck);
|
||||
public void startMatch() throws GameException;
|
||||
public void startGame() throws GameException;
|
||||
public void sideboard();
|
||||
public void endGame();
|
||||
public Game getGame();
|
||||
public List<Game> getGames();
|
||||
|
@ -56,4 +60,7 @@ public interface Match {
|
|||
public boolean isDoneSideboarding();
|
||||
public UUID getChooser();
|
||||
|
||||
public void addTableEventListener(Listener<TableEvent> listener);
|
||||
public void fireSideboardEvent(UUID playerId, Deck deck);
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ import java.util.logging.Logger;
|
|||
import mage.cards.decks.Deck;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameException;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.TableEvent;
|
||||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.events.TableEventSource;
|
||||
import mage.players.Player;
|
||||
import mage.util.Logging;
|
||||
|
||||
|
@ -45,11 +49,14 @@ import mage.util.Logging;
|
|||
public abstract class MatchImpl implements Match {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(MatchImpl.class.getName());
|
||||
private static final int SIDEBOARD_TIME = 180;
|
||||
|
||||
protected UUID id = UUID.randomUUID();
|
||||
protected List<MatchPlayer> players = new ArrayList<MatchPlayer>();
|
||||
protected List<Game> games = new ArrayList<Game>();
|
||||
protected MatchOptions options;
|
||||
|
||||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
|
||||
public MatchImpl(MatchOptions options) {
|
||||
this.options = options;
|
||||
|
@ -151,6 +158,26 @@ public abstract class MatchImpl implements Match {
|
|||
return loserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTableEventListener(Listener<TableEvent> listener) {
|
||||
tableEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sideboard() {
|
||||
for (MatchPlayer player: this.players) {
|
||||
player.setSideboarding();
|
||||
player.getPlayer().sideboard(this, player.getDeck());
|
||||
}
|
||||
synchronized(this) {
|
||||
while (!isDoneSideboarding()) {
|
||||
try {
|
||||
this.wait();
|
||||
} catch (InterruptedException ex) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDoneSideboarding() {
|
||||
for (MatchPlayer player: this.players) {
|
||||
|
@ -160,4 +187,23 @@ public abstract class MatchImpl implements Match {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireSideboardEvent(UUID playerId, Deck deck) {
|
||||
MatchPlayer player = getPlayer(playerId);
|
||||
if (player != null) {
|
||||
tableEventSource.fireTableEvent(EventType.SIDEBOARD, playerId, deck, SIDEBOARD_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitDeck(UUID playerId, Deck deck) {
|
||||
MatchPlayer player = getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.submitDeck(deck);
|
||||
}
|
||||
synchronized (this) {
|
||||
this.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.util.logging.Logger;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.Table;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.PlayerQueryEvent;
|
||||
import mage.game.events.PlayerQueryEventSource;
|
||||
|
@ -63,8 +64,10 @@ public abstract class TournamentImpl implements Tournament {
|
|||
protected String matchName;
|
||||
protected TournamentOptions options;
|
||||
|
||||
protected transient TableEventSource tableEventSource = new TableEventSource();
|
||||
protected transient PlayerQueryEventSource playerQueryEventSource = new PlayerQueryEventSource();
|
||||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
protected PlayerQueryEventSource playerQueryEventSource = new PlayerQueryEventSource();
|
||||
|
||||
private static final int CONSTRUCT_TIME = 600;
|
||||
|
||||
public TournamentImpl(TournamentOptions options) {
|
||||
this.options = options;
|
||||
|
@ -209,7 +212,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
|
||||
@Override
|
||||
public void fireSubmitDeckEvent(UUID playerId, Deck deck) {
|
||||
tableEventSource.fireTableEvent(EventType.SUBMIT_DECK, playerId, deck);
|
||||
tableEventSource.fireTableEvent(EventType.SUBMIT_DECK, playerId, deck, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -220,10 +223,11 @@ public abstract class TournamentImpl implements Tournament {
|
|||
@Override
|
||||
public void fireConstructEvent(UUID playerId, Deck deck) {
|
||||
TournamentPlayer player = players.get(playerId);
|
||||
playerQueryEventSource.construct(playerId, "Construct", deck, 600);
|
||||
playerQueryEventSource.construct(playerId, "Construct", deck, CONSTRUCT_TIME);
|
||||
}
|
||||
|
||||
public void construct() {
|
||||
tableEventSource.fireTableEvent(EventType.CONSTRUCT);
|
||||
for (TournamentPlayer player: players.values()) {
|
||||
player.setConstructing();
|
||||
player.getPlayer().construct(this, player.getDeck());
|
||||
|
|
|
@ -56,6 +56,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.Game;
|
||||
import mage.game.Table;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.target.Target;
|
||||
|
@ -154,7 +155,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
public abstract void selectBlockers(Game game);
|
||||
public abstract void assignDamage(int damage, List<UUID> targets, UUID sourceId, Game game);
|
||||
public abstract int getAmount(int min, int max, String message, Game game);
|
||||
public abstract void sideboard(Table table, Deck deck);
|
||||
public abstract void sideboard(Match match, Deck deck);
|
||||
public abstract void construct(Tournament tournament, Deck deck);
|
||||
public abstract void pickCard(List<Card> cards, Deck deck, Draft draft);
|
||||
|
||||
|
|
Loading…
Reference in a new issue