Package mage.view

Examples of mage.view.TableView


      tableWaitingDialog.showDialog(roomId, newTableDialog.getTable().getTableId());
    }
}//GEN-LAST:event_btnNewTableActionPerformed

  private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
    TableView table;
    try {
      List<String> playerTypes = new ArrayList<String>();
      playerTypes.add("Human");
      playerTypes.add("Computer - default");
      table = session.createTable(
          roomId,
          "Two Player Duel",
          "Constructed",
          playerTypes,
          null, null
      );
      session.joinTable(
          roomId,
          table.getTableId(),
          "Human",
          DeckCardLists.load("test.dck")
      );
      session.joinTable(
          roomId,
          table.getTableId(),
          "Computer",
          DeckCardLists.load("test.dck")
      );
      hideTables();
      session.startGame(roomId, table.getTableId());
    } catch (Exception ex) {
      handleError(ex);
    }
  }//GEN-LAST:event_btnQuickStartActionPerformed
View Full Code Here


    session.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
    }

  @Override
  public void update(Observable arg0, Object arg1) {
    TableView table = session.getTable(roomId, tableId);
    if (table != null) {
      if (table.getTableState() == TableState.STARTING) {
        this.btnStart.setEnabled(true);
        this.btnMoveDown.setEnabled(true);
        this.btnMoveUp.setEnabled(true);
      } else {
        this.btnStart.setEnabled(false);
View Full Code Here

            GameTypeView gameTypeView = session.getGameTypes().get(0);
            log.info("Game type view: " + gameTypeView.getName());
            MatchOptions options = createGameOptions(gameTypeView, session);

            TableView table = session.createTable(roomId, options);

            if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
                log.error("Error while joining table");
                Assert.assertTrue("Error while joining table", false);
                return;
            }

            /*** Connect with a second player ***/
            Connection connection2 = createConnection(TEST_USER_NAME_2 + i);
            SimpleMageClient mageClient2 = new SimpleMageClient();
            Session session2 = new SessionImpl(mageClient2);
            session2.connect(connection2);
            UUID roomId2 = session2.getMainRoomId();

            // connect to the table with the same deck
            if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
                log.error("Error while joining table");
                Assert.assertTrue("Error while joining table", false);
                return;
            }

            /*** Start game ***/
            session.startMatch(roomId, table.getTableId());

            Thread.sleep(100);
        }
    }
View Full Code Here

        GameTypeView gameTypeView = session.getGameTypes().get(0);
        log.info("Game type view: " + gameTypeView.getName());
        MatchOptions options = createGameOptions(gameTypeView, session);

        TableView table = session.createTable(roomId, options);

        if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
            log.error("Error while joining table");
            Assert.assertTrue("Error while joining table", false);
            return true;
        }

        /*** Connect with a second player ***/
        Connection connection2 = createConnection(TEST_USER_NAME_2 + i);
        SimpleMageClient mageClient2 = new SimpleMageClient();
        Session session2 = new SessionImpl(mageClient2);
        session2.connect(connection2);

        mageClient2.setSession(session2);
        UUID roomId2 = session2.getMainRoomId();

        // connect to the table with the same deck
        if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
            log.error("Error while joining table");
            Assert.assertTrue("Error while joining table", false);
            return true;
        }

        /*** Start game ***/
        session.startMatch(roomId, table.getTableId());

        while (!mageClient.isGameOver()) {
            Thread.sleep(1000);
        }
        return false;
View Full Code Here

  @Override
  public List<TableView> getTables() {
    ArrayList<TableView> tableList = new ArrayList<TableView>();
    for (Table table: tables.values()) {
      tableList.add(new TableView(table));
    }
    return tableList;
  }
View Full Code Here

  @Override
  public TableView createTable(UUID sessionId, String gameType, String deckType, List<String> playerTypes, MultiplayerAttackOption attackOption, RangeOfInfluence range) {
    Table table = TableManager.getInstance().createTable(sessionId, gameType, deckType, playerTypes, attackOption, range);
    tables.put(table.getId(), table);
    return new TableView(table);
  }
View Full Code Here

    return new TableView(table);
  }

  @Override
  public TableView getTable(UUID tableId) {
    return new TableView(tables.get(tableId));
  }
View Full Code Here

  }

  @Override
  public TableView createTable(UUID sessionId, UUID roomId, String gameType, String deckType, List<String> playerTypes, MultiplayerAttackOption attackOption, RangeOfInfluence range) throws MageException {
    try {
      TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTable(sessionId, gameType, deckType, playerTypes, attackOption, range);
      logger.info("Table " + table.getTableId() + " created");
      return table;
    }
    catch (Exception ex) {
      handleException(ex);
    }
View Full Code Here

    public TableView createTable(final String sessionId, final UUID roomId, final MatchOptions options) throws MageException {
        return executeWithResult("createTable", sessionId, new ActionWithTableViewResult() {
            @Override
            public TableView execute() throws MageException {
                UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
                TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTable(userId, options);
                if (logger.isDebugEnabled()) {
                    User user = UserManager.getInstance().getUser(userId);
                    if (user != null) {
                        logger.debug("TABLE created - tableId: " + table.getTableId() + " " + table.getTableName());
                        logger.debug("- " + user.getName() + " userId: " + user.getId());
                        logger.debug("- chatId: " + TableManager.getInstance().getChatId(table.getTableId()));                       
                    }
                }
                LogServiceImpl.instance.log(LogKeys.KEY_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString());
                return table;
            }
        });
    }
View Full Code Here

                                user.showUserMessage("Create tournament", "It's only allowed to use a maximum of " + max + " AI players.");
                            }
                            throw new MageException("No message");
                        }
                    }
                    TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTournamentTable(userId, options);
                    logger.debug("Tournament table " + table.getTableId() + " created");
                    LogServiceImpl.instance.log(LogKeys.KEY_TOURNAMENT_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString());
                    return table;
                } catch (Exception ex) {
                    handleException(ex);
                }
                return null;
View Full Code Here

TOP

Related Classes of mage.view.TableView

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.