Package marauroa.common.game

Examples of marauroa.common.game.RPObject


   * @throws IOException
   */
  public RPObject loadCharacter(String username, String character) throws SQLException, IOException {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      RPObject res = loadCharacter(transaction, username, character);
      return res;
    } finally {
      TransactionPool.get().commit(transaction);
    }
  }
View Full Code Here


      int amount = inputSerializer.readInt();

      for (int i = 0; i < amount; i++) {
        try {
          RPObject object = factory.transform((RPObject) inputSerializer.readObject(new RPObject()));

          if (object != null) {
            /* Give the object a valid id and add it */
            zone.assignRPObjectID(object);
            zone.add(object);
 
View Full Code Here

       */
      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);
      }
View Full Code Here

  public boolean onActionAdd(RPObject object, RPAction action, List<RPAction> actionList) {
    return true;
  }

  public boolean onExit(RPObject object) throws RPObjectNotFoundException {
    RPObject result = world.remove(object.getID());
    TestHelper.assertNotNull(result);

    players.remove(object);
    return true;
  }
View Full Code Here

    return true;
  }

  public boolean onInit(RPObject object) throws RPObjectInvalidException {
    System.out.println("PreW: "+object);
    RPObject old=object;

    object.put("zoneid", "test");
    world.add(object);
   
    System.out.println("PostW("+(old==object?1:0)+"): "+object);
View Full Code Here

    try {
      client = new SimpleClient("log4j.properties");
      client.connect("localhost", PORT);
      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"));

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

    try {
      client = new SimpleClient("log4j.properties");
      client.connect("localhost", PORT);
      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) {
View Full Code Here

  protected void populate() {
    IRPZone zone = new MarauroaRPZone("test");
    addRPZone(zone);

    RPObject hidden = new RPObject();
    zone.assignRPObjectID(hidden);
    hidden.put("hidden", "You don't see this object");
    hidden.hide();
    zone.add(hidden);
  }
View Full Code Here

   * Populates the zone with some objects.
   *
   */
  @Before
  public void populateZone() {
    object = new RPObject();
    object.put("a", 1);
    object.put("b", "1");
    object.put("c", 2.0);
    object.put("d", "string of text");

    object.addSlot("lhand");
    object.addSlot("rhand");

    RPClassTestHelper.generateRPClasses();
    RPEvent chat = new RPEvent("chat");
    chat.put("text", "Hi there");
    object.addEvent(chat);

    chat = new RPEvent("chat");
    chat.put("text", "Does this work?");
    object.addEvent(chat);

    RPSlot lhand = object.getSlot("lhand");

    RPObject pocket = new RPObject();
    pocket.put("size", 1);
    pocket.addSlot("container");
    lhand.add(pocket);

    RPSlot container = pocket.getSlot("container");

    RPObject coin = new RPObject();
    coin.put("euro", 100);
    coin.put("value", 100);
    container.add(coin);

    zone = new MarauroaRPZone("test");
    /* Define the object as storable */
    object.store();
 
View Full Code Here

   */
  @Test
  public void addCharacter() throws SQLException, IOException {
    String username = "testUserCA";
    String character = "testCharacterCA";
    RPObject player = new RPObject();

    DBTransaction transaction = transactionPool.beginWork();
    try {
      accountDAO.addPlayer(transaction, username, Hash.hash("testPassword"), "email@email.com");
      assertTrue(accountDAO.hasPlayer(transaction, username));
View Full Code Here

TOP

Related Classes of marauroa.common.game.RPObject

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.