Examples of GameException


Examples of mage.game.GameException

        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

Examples of mage.game.GameException

    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

Examples of mage.game.GameException

            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

Examples of mage.game.GameException

        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

Examples of org.scotlandyard.engine.GameException

  public static Game getNewInstance(final String identifier,
      final User creator, final BoardMap boardMap) throws GameException {
    final Game game = new GameImpl(identifier, creator, boardMap);

    if (creator!=null && GameEngine.instance().getUser(creator.getEmail()) == null) {
      throw new GameException(
          "the user can not create a game before login is made");
    }
    // add the game to the list of available games
    GameEngine.instance().getLobby().addGame(game);
    return game;
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  }

  @Override
  public void addDetective(final Detective detective) throws GameException {
    if (detective == null) {
      throw new GameException("Can not add a null detective to the list");
    }
    if (this.getPlayer(detective.getEmail()) != null) {
      throw new GameException("Can not join a game twice");
    }
    detectives.put(detective.getEmail(), detective);
    playerTokens.put(detective, new EnumMap<TransportationMethod, Token>(
        TransportationMethod.class));
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  }


  public Player getWhoOccupiesPosition(final Coordinate coordinate) throws GameException {
    if(coordinate==null){
      throw new GameException("coordinate has not been initialized");
    }
    if(this.getBoardMap()==null){
      throw new GameException("the current board map for the game has not been initialized");
    }
    if(coordinate.getBoardMap()==null){
      throw new GameException("the board map of the coordinate has not been initialized yet");
    }
    if(!coordinate.getBoardMap().equals(this.getBoardMap())){
      throw new GameException("the board map of the coordinate ["+coordinate.getBoardMap().toString()+"] is"+
                  "the same as the board map of the game ["+this.getBoardMap().toString()+"]");
    }
    Player temp = null;
    for(Player player:this.getPlayers()){
      if(player.getPosition(this)!=null && player.getPosition(this).equals(coordinate)){
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  @Override
  public boolean removePlayer(final Player player) throws GameException{
    final MrX temp =null;
    if(player==null){
      throw new GameException("can not remove null player");
    }
    if (mrX!=null && mrX.getEmail().equals(player.getEmail())) {
      mrX=temp;
    } else {
      if(detectives.remove(player.getEmail())==null){
        throw new GameException("this player does not exist to be removed");
      }
    }
    playerPositions.remove(player);
    playerTokens.remove(player);
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  }

  @Override
  public void setMrX(final Player player) throws GameException {
    if (player != null && this.getPlayer(player.getEmail()) != null) {
      throw new GameException("Can not join a game twice");
    }
    if (mrX != null) {
      throw new GameException(
          "Mr X is already set, and shall not be changed");
    }
    mrX = (MrX) player;
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  @Override
  public void setPlayerPosition(final PlayerPosition playerPosition)
      throws GameException {
    if(playerPosition.getPlayer()==null){
      throw new GameException("player must be set");
    }
    if(playerPosition.getPosition()==null){
      throw new GameException("position can not be null");
    }
    if(playerPosition.getPosition().getBoardMap()==null){
      throw new GameException("position map must be set first");
    }
    if(!playerPosition.getPosition().getBoardMap().equals(this.getBoardMap())){
      throw new GameException("the map of the position ["+playerPosition.getPosition().getBoardMap().getName()+"] is different from the map of the game ["+this.getBoardMap().getName()+"]");
    }

    final Coordinate coordinate = playerPosition.getPosition();
    final Player player = this.getWhoOccupiesPosition(coordinate);

    if(player!=null){
      if(!getMrX().equals(player)){
        throw new GameException("this position has been already occupied by other detective");

      }else if(getMrX().equals(player) && !getMrX().equals(playerPosition.getPlayer())){
        //has Mr X been caught?
        this.playerPositions.put(playerPosition.getPlayer(), playerPosition);
        this.setGameStatus(GameStatus.FINISHED);
        throw new GameException("Game is finished, detective ["+playerPosition.getPlayer().getName()+"] has captured Mr X");
      }
    }
    playerPosition.getPlayer().setPosition(this, playerPosition.getPosition());
    this.playerPositions.put(playerPosition.getPlayer(), playerPosition);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.