Examples of Seat


Examples of mage.game.Seat

  public synchronized boolean joinTable(UUID sessionId, String name, DeckCardLists deckList) throws 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());
    table.joinTable(player, seat);
    logger.info("player joined " + player.getId());
    //only add human players to sessionPlayerMap
    if (seat.getPlayer().isHuman()) {
      sessionPlayerMap.put(sessionId, player.getId());
    }

    return true;
  }
View Full Code Here

Examples of mage.game.Seat

    public synchronized boolean joinTournament(UUID userId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException {
        if (table.getState() != TableState.WAITING) {
            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.Seat

            if (!table.getMatch().getOptions().getPassword().equals(password)) {
                user.showUserMessage("Join Table", "Wrong password.");
                return false;
            }
        }
        Seat seat = table.getNextAvailableSeat(playerType);
        if (seat == null) {
            user.showUserMessage("Join Table", "No available seats.");
            return false;
        }
        Deck deck = Deck.load(deckList, false, 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) {
            String message = new StringBuilder("Could not create player ").append(name).append(" of type ").append(seat.getPlayerType()).toString();
            logger.warn(new StringBuilder("User: ").append(user.getName()).append(" => ").append(message).toString());
            user.showUserMessage("Join Table",message);
            return false;
        }
        if (!player.canJoinTable(table)) {
            user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
            return false;
        }
        match.addPlayer(player, deck);
        table.joinTable(player, seat);
        logger.trace(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(), false);
            userPlayerMap.put(userId, player.getId());
        }
        return true;
View Full Code Here

Examples of mage.game.Seat

    public void addPlayer(UUID userId, Player player, String playerType, Deck deck) throws 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);
View Full Code Here

Examples of org.codehaus.enunciate.examples.objc.schema.vehicles.Seat

        }
       
        Bus bus = new Bus();
        SeatRow rowA = new SeatRow();
        rowA.setRowName("A");
        Seat seatA1 = new Seat();
        seatA1.setNumber(1);
        Seat seatA2 = new Seat(); //empty element
        Seat seatA3 = new Seat();
        seatA3.setNumber(3);
        rowA.setSeats(Arrays.asList(seatA1, seatA2, seatA3));
        bus.setSeatRows(Arrays.asList(rowA));
        bus = processThroughXml(bus);
        assertNotNull(bus.getSeatRows());
        assertEquals(1, bus.getSeatRows().size());
View Full Code Here

Examples of org.drools.examples.manners.model.Seat

                Context context = (Context) tuple.get( contextDeclD );

                List list = new ArrayList( );
                while ( seating != null )
                {
                    Seat seat = new Seat( seating.getSeat1( ),
                                          seating.getGuest1( ).getName( ) );
                    seating = seating.getPrevSeat( );
                    list.add( seat );
                }

                for ( int i = list.size( ); i > 0; i-- )
                {
                    Seat seat = (Seat) list.get( i - 1 );
                    System.out.println( seat );
                    try
                    {
                        workingMemory.assertObject( seat );
                    }
View Full Code Here

Examples of org.drools.examples.manners.model.Seat

            if ( !( obj instanceof Seat ) )
            {
                continue;
            }

            Seat seat = ( Seat ) obj;
            if ( lastGuest == null )
            {
                lastGuest = guest4Seat( inList, seat );
            }

            Guest guest = guest4Seat( inList, seat );

            boolean hobbyFound = false;
            for ( int i = 0; !hobbyFound && i < lastGuest.getHobbies( ).size( ); i++ )
            {
                String hobby = ( String ) lastGuest.getHobbies( ).get( i );
                if ( guest.getHobbies( ).contains( hobby ) )
                {
                    hobbyFound = true;
                }
            }

            if ( !hobbyFound )
            {
                throw new RuntimeException( "seat: " + seat.getSeat( )
                                            + " no common hobby " + lastGuest
                                            + " -> " + guest );
            }
            seatCount++;
        }
View Full Code Here

Examples of org.drools.examples.model.Seat

                Context context = (Context) tuple.get( contextDeclD );

                List list = new ArrayList( );
                while ( seating != null )
                {
                    Seat seat = new Seat( seating.getSeat1( ),
                                          seating.getGuest1( ).getName( ) );
                    seating = seating.getPrevSeat( );
                    list.add( seat );
                }

                for ( int i = list.size( ); i > 0; i-- )
                {
                    Seat seat = (Seat) list.get( i - 1 );
                    try
                    {
                        workingMemory.assertObject( seat );
                    }
                    catch ( FactException e )
View Full Code Here

Examples of org.drools.examples.model.Seat

            if ( !(obj instanceof Seat) )
            {
                continue;
            }

            Seat seat = (Seat) obj;
            if ( lastGuest == null )
            {
                lastGuest = guest4Seat( inList,
                                        seat );
            }

            Guest guest = guest4Seat( inList,
                                      seat );

            boolean hobbyFound = false;
            for ( int i = 0; !hobbyFound && i < lastGuest.getHobbies( ).size( ); i++ )
            {
                String hobby = (String) lastGuest.getHobbies( ).get( i );
                if ( guest.getHobbies( ).contains( hobby ) )
                {
                    hobbyFound = true;
                }
            }

            if ( !hobbyFound )
            {
                throw new RuntimeException( "seat: " + seat.getSeat( ) + " no common hobby " + lastGuest + " -> " + guest );
            }
            seatCount++;
        }

        return seatCount;
View Full Code Here

Examples of org.drools.planner.examples.manners2009.domain.Seat

                        index = 3 * (edgeLength - 1) + (edgeLength - 1 - y);
                    } else {
                        index = Integer.MAX_VALUE;
                    }
                    if (index < table.getSeatList().size()) {
                        Seat seat = table.getSeatList().get(index);
                        SeatPanel seatPanel = new SeatPanel(seat);
                        tablePanel.add(seatPanel);
                        seatPanelMap.put(seat, seatPanel);
                    } else {
                        tablePanel.add(new JPanel());
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.