Package marauroa.common.game

Examples of marauroa.common.game.CharacterResult


       * Create a character for that account.
       */
      RPObject template = new RPObject();
      template.put("state", "idle");

      CharacterResult character = client.createCharacter("testCharacter", template);
      assertEquals(character.getResult(),Result.OK_CREATED);
      assertEquals("testCharacter", character.getCharacter());

      /*
       * Choose that character.
       */
      boolean choosen = client.chooseCharacter("testCharacter");
View Full Code Here


            client.login("testUsername" + i, "password");

            RPObject template = new RPObject();
            template.put("client", "junit" + i);
            CharacterResult resChar = client.createCharacter("testCharacter", template);
            assertEquals("testCharacter", resChar.getCharacter());

            RPObject result = resChar.getTemplate();
            assertTrue(result.has("client"));
            assertEquals("junit" + i, result.get("client"));

            client.logout();
View Full Code Here

            client.login("testUsername" + i, "password");

            RPObject template = new RPObject();
            template.put("client", "junit" + i);
            CharacterResult resChar = client.createCharacter("testCharacter", template);
            assertEquals("testCharacter", resChar.getCharacter());

            RPObject result = resChar.getTemplate();
            assertTrue(result.has("client"));
            assertEquals("junit" + i, result.get("client"));

            String[] characters = client.getCharacters();
            assertEquals(1, characters.length);
View Full Code Here

    netMan.addMessage(msgCA);

    int received = 0;

    CharacterResult result = null;

    while (received != 2) {
      Message msg = getMessage(TIMEOUT_EXTENDED);

      switch (msg.getType()) {
        /* Account was created */
        case S2C_CREATECHARACTER_ACK:
          logger.debug("Create character ACK");

          MessageS2CCreateCharacterACK msgack = (MessageS2CCreateCharacterACK) msg;

          result = new CharacterResult(Result.OK_CREATED, msgack.getCharacter(), msgack
                  .getTemplate());
          received++;
          break;

        /* Server send the character list */
        case S2C_CHARACTERLIST:
          logger.debug("Received Character list");
          /*
           * We notify client of characters by calling the callback
           * method.
           */
          String[] characters = ((MessageS2CCharacterList) msg).getCharacters();
          onAvailableCharacters(characters);
          Map<String, RPObject> characterDetails = ((MessageS2CCharacterList) msg).getCharacterDetails();
          onAvailableCharacterDetails(characterDetails);

          received++;
          break;

        /* Account was not created. Reason explained on event and return. */
        case S2C_CREATECHARACTER_NACK:
          logger.debug("Create character NACK");
          MessageS2CCreateCharacterNACK reply = (MessageS2CCreateCharacterNACK) msg;

          result = new CharacterResult(reply.getResolutionCode(), character, template);
          return result;
      }
    }

    return result;
View Full Code Here

   *         if it is not the cause.
   */
  public CharacterResult createCharacter(String username, String character, RPObject template, String address) {
    try {
      if (!Boolean.parseBoolean(Configuration.getConfiguration().get("allow_account_creation", "true"))) {
        return new CharacterResult(Result.FAILED_CREATE_ON_MAIN_INSTEAD, character, template);
      }
    } catch (IOException e) {
      logger.error(e, e);
    }

    // check account creation limits
    try {
      if (DAORegister.get().get(CharacterDAO.class).isCharacterCreationLimitReached(username, address)) {
        return new CharacterResult(Result.FAILED_TOO_MANY, character, template);
      }
    } catch (SQLException e) {
      logger.error(e, e);
      return new CharacterResult(Result.FAILED_EXCEPTION, character, template);
    } catch (IOException e) {
      logger.error(e, e);
      return new CharacterResult(Result.FAILED_EXCEPTION, character, template);
    }
    return ruleProcessor.createCharacter(username, character, template);
  }
View Full Code Here

    /*
     * We request the creation of an character for a logged player. It
     * will also return a result of the character that we must forward to
     * player.
     */
    CharacterResult val = rpMan.createCharacter(username, character, template, address);
    Result result = val.getResult();

    if (result == Result.OK_CREATED) {
      /*
       * If the character is created notify player and send him a
       * Character list message.
       */
      logger.debug("Character (" + character + ") created for account " + username);
      MessageS2CCreateCharacterACK msgCreateCharacterACK = new MessageS2CCreateCharacterACK(
          channel, val.getCharacter(), val.getTemplate());
      msgCreateCharacterACK.setClientID(clientid);
      msgCreateCharacterACK.setProtocolVersion(protocolVersion);
      netMan.sendMessage(msgCreateCharacterACK);

      /*
 
View Full Code Here

    try {
      /*
       * We filter too short character names.
       */
      if(character.length()<4) {
        return new CharacterResult(Result.FAILED_STRING_SIZE, character, template);
      }
     
      RPObject player = new RPObject(template);

      player.put("name", character);
      player.put("version", "0.00");

      if (DAORegister.get().get(CharacterDAO.class).hasCharacter(transaction, character)) {
        logger.warn("Character already exist: " + character);
        return new CharacterResult(Result.FAILED_PLAYER_EXISTS, character, player);
      }

      DAORegister.get().get(CharacterDAO.class).addCharacter(transaction, username, character, player);
      transactionPool.commit(transaction);
      return new CharacterResult(Result.OK_CREATED, character, player);
    } catch (Exception e) {
      transactionPool.rollback(transaction);
      TestHelper.fail();
      return new CharacterResult(Result.FAILED_EXCEPTION, character, template);
    }
  }
View Full Code Here

    try {
      /*
       * We filter too short character names.
       */
      if(character.length()<4) {
        return new CharacterResult(Result.FAILED_STRING_SIZE, character, template);
      }
     
      RPObject player = new RPObject(template);

      player.put("name", character);
      player.put("version", "0.00");
      player.put("ATK", 50);

      if (DAORegister.get().get(CharacterDAO.class).hasCharacter(transaction, character)) {
        logger.warn("Character already exist: " + character);
        return new CharacterResult(Result.FAILED_PLAYER_EXISTS, character, player);
      }

      DAORegister.get().get(CharacterDAO.class).addCharacter(transaction, username, character, player);
      transactionPool.commit(transaction);
      return new CharacterResult(Result.OK_CREATED, character, player);
    } catch (Exception e) {
      transactionPool.rollback(transaction);
      TestHelper.fail();
      return new CharacterResult(Result.FAILED_EXCEPTION, character, template);
    }
  }
View Full Code Here

      client.login("testUsername", "password");

      RPObject template = new RPObject();
      template.put("client", "junit");

      CharacterResult res = client.createCharacter("testCharacter",
          template);
      assertEquals(res.getResult(), Result.OK_CREATED);
      assertEquals("testCharacter", res.getCharacter());

      RPObject result = res.getTemplate();
      assertTrue(result.has("client"));
      assertEquals("junit", result.get("client"));
      assertTrue(result.has("name"));
      assertEquals("testCharacter", result.get("name"));
View Full Code Here

      client.login("testUsername", "password");

      RPObject template = new RPObject();
      template.put("client", "junit");

      CharacterResult res = client.createCharacter("ter", template);
      assertTrue(res.getResult().failed());
      client.close();
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }
View Full Code Here

TOP

Related Classes of marauroa.common.game.CharacterResult

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.