added deck validation feedback to client + queue all RMI messages

This commit is contained in:
BetaSteward 2011-05-31 00:10:44 -04:00
parent 10edbc8d9b
commit 14891b1b77
62 changed files with 374 additions and 116 deletions

View file

@ -42,6 +42,7 @@ import java.util.logging.Level;
import mage.cards.decks.DeckCardLists;
import mage.game.GameException;
import mage.MageException;
import mage.cards.decks.InvalidDeckException;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.interfaces.Server;
@ -211,6 +212,9 @@ public class ServerImpl extends RemoteServer implements Server {
return ret;
}
}
catch (InvalidDeckException ex) {
throw ex;
}
catch (GameException ex) {
throw ex;
}

View file

@ -57,6 +57,7 @@ import org.apache.log4j.Logger;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import mage.cards.decks.InvalidDeckException;
/**
*
@ -143,7 +144,7 @@ public class TableController {
return true;
}
public synchronized boolean joinTable(UUID sessionId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException {
public synchronized boolean joinTable(UUID sessionId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException {
if (table.getState() != TableState.WAITING) {
return false;
}
@ -152,8 +153,8 @@ public class TableController {
throw new GameException("No available seats.");
}
Deck deck = Deck.load(deckList);
if (!Main.server.isTestMode() && !validDeck(deck)) {
throw new GameException(name + " has an invalid deck for this format");
if (!Main.server.isTestMode() && !table.getValidator().validate(deck)) {
throw new InvalidDeckException(name + " has an invalid deck for this format", table.getValidator().getInvalid());
}
Player player = createPlayer(name, seat.getPlayerType(), skill);
@ -183,13 +184,13 @@ public class TableController {
}
}
public synchronized boolean submitDeck(UUID sessionId, DeckCardLists deckList) throws GameException {
public synchronized boolean submitDeck(UUID sessionId, DeckCardLists deckList) throws MageException {
if (table.getState() != TableState.SIDEBOARDING && table.getState() != TableState.CONSTRUCTING) {
return false;
}
Deck deck = Deck.load(deckList);
if (!Main.server.isTestMode() && !validDeck(deck)) {
throw new GameException("Invalid deck for this format");
if (!Main.server.isTestMode() && !table.getValidator().validate(deck)) {
throw new InvalidDeckException("Invalid deck for this format", table.getValidator().getInvalid());
}
submitDeck(sessionId, deck);
return true;
@ -225,10 +226,6 @@ public class TableController {
return true;
}
private boolean validDeck(Deck deck) {
return table.getValidator().validate(deck);
}
private Player createPlayer(String name, String playerType, int skill) {
Player player;
if (options == null) {

View file

@ -95,7 +95,7 @@ public class TableManager {
return tables.values();
}
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException {
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException {
if (controllers.containsKey(tableId))
return controllers.get(tableId).joinTable(sessionId, name, playerType, skill, deckList);
return false;
@ -107,7 +107,7 @@ public class TableManager {
return false;
}
public boolean submitDeck(UUID sessionId, UUID tableId, DeckCardLists deckList) throws GameException {
public boolean submitDeck(UUID sessionId, UUID tableId, DeckCardLists deckList) throws MageException {
if (controllers.containsKey(tableId))
return controllers.get(tableId).submitDeck(sessionId, deckList);
return false;

View file

@ -45,7 +45,7 @@ import mage.view.TableView;
public interface GamesRoom extends Room {
public List<TableView> getTables();
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException;
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException;
public boolean joinTournamentTable(UUID sessionId, UUID tableId, String name, String playerType, int skill) throws GameException;
public TableView createTable(UUID sessionId, MatchOptions options);
public TableView createTournamentTable(UUID sessionId, TournamentOptions options);

View file

@ -64,7 +64,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
}
@Override
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException {
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException {
if (tables.containsKey(tableId)) {
return TableManager.getInstance().joinTable(sessionId, tableId, name, playerType, skill, deckList);
} else {