Package marauroa.server.game.db

Examples of marauroa.server.game.db.CharacterDAO


  @Test
  public void testPerform() throws Throwable {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      AccountDAO accountDAO = DAORegister.get().get(AccountDAO.class);
      CharacterDAO characterDAO = DAORegister.get().get(CharacterDAO.class);
      BanAction ban = new BanAction();
      Player player = PlayerTestHelper.createPlayer("bob");
      RPAction action = new RPAction();
      action.put("target", player.getName());
      action.put("hours", -1);
      action.put("reason", "Because we were testing banning");
     
      // I don't know if this is still needed.
      if (!accountDAO.hasPlayer(transaction, player.getName())) {
        accountDAO.addPlayer(transaction, player.getName(), new byte[0], "schnubbel");
      }
     
      // we do a character check now. Made the the character name and the account name the same
      if (!characterDAO.hasCharacter(transaction, player.getName(), player.getName())) {
        characterDAO.addCharacter(transaction,  player.getName(), player.getName(), player);
      }

      System.out.println(DAORegister.get().get(CharacterDAO.class).getAccountName(transaction, player.getName()));
      accountDAO.setAccountStatus(transaction, player.getName(), "active");
      assertEquals("active", accountDAO.getAccountStatus(transaction, player.getName()));
View Full Code Here


  @Test
  public void testCommandCenterPerform() throws Throwable {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      AccountDAO accountDAO = DAORegister.get().get(AccountDAO.class);
      CharacterDAO characterDAO = DAORegister.get().get(CharacterDAO.class);
     
      Player player = PlayerTestHelper.createPlayer("bobby");
      Player admin = PlayerTestHelper.createPlayer("admin");
      RPAction action = new RPAction();
      action.put("type", "ban");
      action.put("target", player.getName());
      action.put("hours",  -1);
      action.put("reason", "whynot");
      if (!accountDAO.hasPlayer(transaction, player.getName())) {
        accountDAO.addPlayer(transaction, player.getName(), new byte[0], "schnubbel");
      }

      accountDAO.setAccountStatus(transaction, player.getName(), "active");
      if (!accountDAO.hasPlayer(transaction, admin.getName())) {
        accountDAO.addPlayer(transaction, admin.getName(), new byte[0], "schnubbel");
      }
      // we do a character check now. Made the the character name and the account name the same
        if (!characterDAO.hasCharacter(transaction, player.getName(), player.getName())) {
        characterDAO.addCharacter(transaction,  player.getName(), player.getName(), player);
        }
       
      accountDAO.setAccountStatus(transaction, admin.getName(), "active");
 
      assertEquals("active", accountDAO.getAccountStatus(transaction, player.getName()));
View Full Code Here

  @Test
  public void testTemporaryBan() throws Throwable {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      AccountDAO accountDAO = DAORegister.get().get(AccountDAO.class);
      CharacterDAO characterDAO = DAORegister.get().get(CharacterDAO.class);
     
      Player player = PlayerTestHelper.createPlayer("bobby");
      Player admin = PlayerTestHelper.createPlayer("admin");
      RPAction action = new RPAction();
      action.put("type", "ban");
      action.put("target", player.getName());
      action.put("hours"1);
      action.put("reason", "We want to test the temporary bans");
      if (!accountDAO.hasPlayer(transaction, player.getName())) {
        accountDAO.addPlayer(transaction, player.getName(), new byte[0], "schnubbel");
      }

      accountDAO.setAccountStatus(transaction, player.getName(), "active");
      if (!accountDAO.hasPlayer(transaction, admin.getName())) {
        accountDAO.addPlayer(transaction, admin.getName(), new byte[0], "schnubbel");
      }
      // we do a character check now. Made the the character name and the account name the same
        if (!characterDAO.hasCharacter(transaction, player.getName(), player.getName())) {
        characterDAO.addCharacter(transaction,  player.getName(), player.getName(), player);
        }
       
      accountDAO.setAccountStatus(transaction, admin.getName(), "active");
 
      assertEquals("active", accountDAO.getAccountStatus(transaction, player.getName()));
View Full Code Here

    this.namesToCheck = namesToCheck;
  }

  @Override
  public void execute(DBTransaction transaction) throws SQLException {
    CharacterDAO dao = DAORegister.get().get(CharacterDAO.class);

    validNames = new HashSet<String>();

    for(String name : namesToCheck) {
      // check for existing accounts (may be merged with the following call into only one DB query)
      if (dao.getAccountName(transaction, name) != null) {
        // get the real character name independent from the client character case
        String canonicalName = dao.getCanonicalName(transaction, name);

        if (canonicalName != null) {
          validNames.add(canonicalName);
        }
      }
View Full Code Here

    this.messagetype = messagetype;
  }

  @Override
  public void execute(DBTransaction transaction) throws SQLException {
    CharacterDAO characterdao = DAORegister.get().get(CharacterDAO.class);
    accountName = characterdao.getAccountName(transaction, target);
    if (accountName != null) {
      PostmanDAO postmandao = DAORegister.get().get(PostmanDAO.class);
      postmandao.storeMessage(transaction, source, target, message, messagetype);
    }
  }
View Full Code Here

    this.charname = charname;
  }

  @Override
  public void execute(DBTransaction transaction) throws SQLException {
    CharacterDAO dao = DAORegister.get().get(CharacterDAO.class);
    date = dao.getCreationDate(transaction, charname);
  }
View Full Code Here

      return new CharacterResult(result, character, template);
    }

    final TransactionPool transactionPool = SingletonRepository.getTransactionPool();
    final DBTransaction trans = transactionPool.beginWork();
    final CharacterDAO characterDAO = DAORegister.get().get(CharacterDAO.class);

    try {
      if (characterDAO.hasCharacter(trans, character)) {
        logger.warn("Character already exist: " + character);
        transactionPool.commit(trans);
        return new CharacterResult(Result.FAILED_PLAYER_EXISTS,
            character, template);
      }

      final Player object = Player.createZeroLevelPlayer(character, template);
           // monitor new account names
          final String text = "Support: A new character has just been created called " + character + ".";
  
        SingletonRepository.getRuleProcessor().sendMessageToSupporters(text);
     
      /*
       * Finally we add it to database.
       */
        characterDAO.addCharacter(trans, username, character, object);
      transactionPool.commit(trans);

      return new CharacterResult(Result.OK_CREATED, character, object);
    } catch (final Exception e) {
      transactionPool.rollback(trans);
View Full Code Here

      this.message = message;
    }

    @Override
    public void execute(DBTransaction transaction) throws SQLException {
      CharacterDAO characterdao = DAORegister.get().get(CharacterDAO.class);
      accountName = characterdao.getAccountName(transaction, target);
      // should not really happen with taxman, but check anyway
      if (accountName != null) {
        PostmanDAO postmandao = DAORegister.get().get(PostmanDAO.class);
        List<ChatMessage> oldMessages = postmandao.getChatMessages(transaction, target);
        for (ChatMessage msg : oldMessages) {
View Full Code Here

      admin.sendPrivateText("This player is currently online. Please use the normal commands.");
      return;
    }

    // start a transaction
    CharacterDAO characterDAO = DAORegister.get().get(CharacterDAO.class);
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {

      // check that the player exists
      if (!characterDAO.hasCharacter(characterName)) {
        admin.sendPrivateText("No player with that name.");
        TransactionPool.get().commit(transaction);
        return;
      }
      String username = DAORegister.get().get(CharacterDAO.class).getAccountName(transaction, characterName);
      RPObject object = characterDAO.loadCharacter(transaction, username, characterName);

      process(admin, object, args);

      // safe it back
      characterDAO.storeCharacter(transaction, username, characterName, object);
      TransactionPool.get().commit(transaction);

      // remove from world
      IRPZone zone = StendhalRPWorld.get().getRPZone(object.getID());
      if (zone != null) {
View Full Code Here

TOP

Related Classes of marauroa.server.game.db.CharacterDAO

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.