Package mage.game

Examples of mage.game.GameException


      Card card = CardImpl.createCard(cardName);
      if (card != null)
        deck.cards.add(CardImpl.createCard(cardName));
      else {
        if (!ignoreErrors)
          throw new GameException("Error loading card - " + cardName + " for deck - " + deck.getName());
      }
    }
    for (String cardName: deckCardLists.getSideboard()) {
      Card card = CardImpl.createCard(cardName);
      if (card != null)
        deck.sideboard.add(CardImpl.createCard(cardName));
      else {
        if (!ignoreErrors)
          throw new GameException("Error loading card - " + cardName + " for deck - " + deck.getName());
      }
    }

    return deck;
  }
View Full Code Here


        for (DeckCardInfo deckCardInfo: deckCardLists.getCards()) {
            Card card = createCard(deckCardInfo, mockCards);
            if (card != null) {
                deck.cards.add(card);
            } else if (!ignoreErrors) {
                throw new GameException("Error loading card - " + deckCardInfo.getCardName() + " for deck - " + deck.getName());
            }
        }
        for (DeckCardInfo deckCardInfo: deckCardLists.getSideboard()) {
            Card card = createCard(deckCardInfo, mockCards);
            if (card != null) {
                deck.sideboard.add(card);
            } else if (!ignoreErrors) {
                throw new GameException("Error loading card - " + deckCardInfo.getCardName() + " for deck - " + deck.getName());
            }
        }

        return deck;
    }
View Full Code Here

    if (table.getState() != TableState.WAITING) {
      return false;
    }
    Seat seat = table.getNextAvailableSeat();
    if (seat == null) {
      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");
    }
   
    Player player = createPlayer(name, deck, seat.getPlayerType());
    game.loadCards(deck.getCards(), player.getId());
    game.loadCards(deck.getSideboard(), player.getId());
View Full Code Here

            return false;
        }

        Seat seat = table.getNextAvailableSeat(playerType);
        if (seat == null) {
            throw new GameException("No available seats.");
        }
        User user = UserManager.getInstance().getUser(userId);
        if (user == null) {
            logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tournament userId = ").append(userId).toString());
            return false;
        }
        // check password
        if (!table.getTournament().getOptions().getPassword().isEmpty() && playerType.equals("Human")) {
            if (!table.getTournament().getOptions().getPassword().equals(password)) {
                user.showUserMessage("Join Table", "Wrong password.");
                return false;
            }
        }
        if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){
            user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
            return false;
        }
        Deck deck = null;
        if (!table.getTournament().getTournamentType().isLimited()) {
            if  (deckList != null) {
                deck = Deck.load(deckList, false, false);
            } else {
                user.showUserMessage("Join Table", "No valid deck selected!");
                return false;
            }
            if (!Main.isTestMode() && !table.getValidator().validate(deck)) {
                StringBuilder sb = new StringBuilder("You (").append(name).append(") have an invalid deck for the selected ").append(table.getValidator().getName()).append(" Format. \n\n");
                for (Map.Entry<String, String> entry : table.getValidator().getInvalid().entrySet()) {
                    sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
                }
                sb.append("\n\nSelect a deck that is appropriate for the selected format and try again!");
                user.showUserMessage("Join Table", sb.toString());
                if (isOwner(userId)) {
                    logger.debug("New table removed because owner submitted invalid deck tableId " + table.getId());
                    TableManager.getInstance().removeTable(table.getId());
                }
                return false;
            }
        }

        Player player = createPlayer(name, seat.getPlayerType(), skill);
        if (player != null) {
            if (!player.canJoinTable(table)) {
                user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
                return false;
            }
            tournament.addPlayer(player, seat.getPlayerType());
            TournamentPlayer tournamentPlayer = tournament.getPlayer(player.getId());
            if (deck != null && tournamentPlayer != null) {
                tournamentPlayer.submitDeck(deck);
            }
            table.joinTable(player, seat);           
            logger.trace("player " + player.getName() + " joined tableId: " + table.getId());
            //only inform human players and add them to sessionPlayerMap
            if (seat.getPlayer().isHuman()) {
                user.addTable(player.getId(), table);
                user.joinedTable(table.getRoomId(), table.getId(), true);
                userPlayerMap.put(userId, player.getId());
            }

            return true;
        } else {
            throw new GameException("Playertype " + seat.getPlayerType() + " could not be created.");
        }
    }
View Full Code Here

        if (table.getState() != TableState.WAITING) {
            return;
        }
        Seat seat = table.getNextAvailableSeat(playerType);
        if (seat == null) {
            throw new GameException("No available seats.");
        }
        match.addPlayer(player, deck);
        table.joinTable(player, seat);
        if (player.isHuman()) {
            userPlayerMap.put(userId, player.getId());
View Full Code Here

TOP

Related Classes of mage.game.GameException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.