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

@ -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) {