mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Fixed a bug that while a match or tournament was just starting a player could still leave the table, setting the table / tournament / match to an undefined state. Now the player can only leave the Match / Tournament if it has started properly.
This commit is contained in:
parent
3f5f6a6166
commit
fec0744315
10 changed files with 159 additions and 100 deletions
|
|
@ -86,7 +86,7 @@ public interface MageServer {
|
|||
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
boolean watchTournamentTable(String sessionId, UUID tableId) throws MageException;
|
||||
void leaveTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
boolean leaveTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void swapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
|
||||
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
|
@ -106,7 +106,7 @@ public interface MageServer {
|
|||
UUID getMainRoomId() throws MageException;
|
||||
|
||||
//game methods
|
||||
void startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
boolean startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void joinGame(UUID gameId, String sessionId) throws MageException;
|
||||
void watchGame(UUID gameId, String sessionId) throws MageException;
|
||||
void stopWatching(UUID gameId, String sessionId) throws MageException;
|
||||
|
|
@ -127,7 +127,7 @@ public interface MageServer {
|
|||
void restorePriority(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
//tournament methods
|
||||
void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
boolean startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
||||
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
|
||||
TournamentView getTournament(UUID tournamentId) throws MageException;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,20 @@
|
|||
|
||||
package mage.remote;
|
||||
|
||||
import java.net.Authenticator;
|
||||
import java.net.ConnectException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.decks.InvalidDeckException;
|
||||
|
|
@ -45,9 +59,22 @@ import mage.interfaces.MageServer;
|
|||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.view.*;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameTypeView;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.RoomUsersView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentTypeView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserDataView;
|
||||
import mage.view.UserView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.*;
|
||||
import org.jboss.remoting.CannotConnectException;
|
||||
import org.jboss.remoting.Client;
|
||||
import org.jboss.remoting.ConnectionListener;
|
||||
import org.jboss.remoting.ConnectionValidator;
|
||||
import org.jboss.remoting.InvokerLocator;
|
||||
import org.jboss.remoting.Remoting;
|
||||
import org.jboss.remoting.callback.Callback;
|
||||
import org.jboss.remoting.callback.HandleCallbackException;
|
||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||
|
|
@ -55,11 +82,6 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
|
|||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||
import org.jboss.remoting.transporter.TransporterClient;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -924,8 +946,7 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean leaveTable(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.leaveTable(sessionId, roomId, tableId);
|
||||
if (isConnected() && server.leaveTable(sessionId, roomId, tableId)) {
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
|
|
@ -940,8 +961,7 @@ public class SessionImpl implements Session {
|
|||
public boolean startMatch(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.startMatch(sessionId, roomId, tableId);
|
||||
return true;
|
||||
return (server.startMatch(sessionId, roomId, tableId));
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
|
|
@ -952,8 +972,7 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean startTournament(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.startTournament(sessionId, roomId, tableId);
|
||||
if (isConnected() && server.startTournament(sessionId, roomId, tableId)) {
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ public class TableView implements Serializable {
|
|||
StringBuilder sb = new StringBuilder("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats());
|
||||
switch (table.getState()) {
|
||||
case WAITING:
|
||||
case READY_TO_START:
|
||||
case STARTING:
|
||||
sb.append(" Constr. Time: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime()/60).append(" Min.");
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue