Package marauroa.common.game

Examples of marauroa.common.game.AccountResult


    Hash.random(4);

    try {
      this.connect(host, Integer.parseInt(port));
      if (createAccount) {
        AccountResult account = createAccount(username, password, "email@mailinator.com");
        if (account.getResult() == Result.OK_CREATED) {
          login(username, password);
          CharacterResult character = createCharacter(username, new RPObject());
          logger.info("Creating character: " + character.getResult());
        } else {
          if (account.getResult() == Result.FAILED_PLAYER_EXISTS) {
            login(username, password);
          } else {
            logger.error(account);
          }
        }
View Full Code Here


   * @return AccountResult
   */
  public AccountResult create() {
    final Result result = validate();
    if (result != null) {
      return new AccountResult(result, username);
    }

    return insertIntoDatabase();
  }
View Full Code Here

    try {
      if (accountDAO.hasPlayer(transaction, username)) {
        logger.warn("Account already exist: " + username);
        transactionPool.commit(transaction);
        return new AccountResult(Result.FAILED_PLAYER_EXISTS, username);
      }

      accountDAO.addPlayer(transaction, username, Hash.hash(password), email);

      transactionPool.commit(transaction);
      return new AccountResult(Result.OK_CREATED, username);
    } catch (final SQLException e) {
      logger.warn("SQL exception while trying to create a new account", e);
      transactionPool.rollback(transaction);
      return new AccountResult(Result.FAILED_EXCEPTION, username);
    }
  }
View Full Code Here

   * Create an account for a player.
   */
  public AccountResult createAccount(String username, String password, String email) {
    // check a minimum length for username and password.
    if ((username.length() < 4) || (password.length() < 4)) {
      return new AccountResult(Result.FAILED_STRING_SIZE, username);
    }

    DBTransaction transaction = transactionPool.beginWork();
    try {
      if (DAORegister.get().get(AccountDAO.class).hasPlayer(transaction, username)) {
        logger.warn("Account already exist: " + username);
        transactionPool.commit(transaction);
        return new AccountResult(Result.FAILED_PLAYER_EXISTS, username);
      }

      DAORegister.get().get(AccountDAO.class).addPlayer(transaction, username, Hash.hash(password), email);

      transactionPool.commit(transaction);
      return new AccountResult(Result.OK_CREATED, username);
    } catch (SQLException e) {
      transactionPool.rollback(transaction);
      return new AccountResult(Result.FAILED_EXCEPTION, username);
    }
  }
View Full Code Here

    CurrentBoard board = new CurrentBoard();
   
    ClientFramework client = new MarboardClientFramework(board);
        client.connect(server, 4851);
       
    AccountResult account = client.createAccount(username, password, "email@mailinator.com");
    if (account.getResult() == Result.OK_CREATED) {
      client.login(username, password);
      CharacterResult character = client.createCharacter(username, new RPObject());
      logger.info("Creating character: " + character.getResult());
    } else {
      if (account.getResult() == Result.FAILED_PLAYER_EXISTS) {
        client.login(username, password);
      } else {
        logger.error(account);
      }
    }
View Full Code Here

TOP

Related Classes of marauroa.common.game.AccountResult

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.