Пример #1
0
  /**
   * Loads account data and returns.
   *
   * @param accountId
   * @param accountName
   * @return
   */
  private static Account loadAccount(int accountId) {
    Account account = new Account(accountId);

    PlayerDAO playerDAO = DAOManager.getDAO(PlayerDAO.class);
    PlayerAppearanceDAO appereanceDAO = DAOManager.getDAO(PlayerAppearanceDAO.class);

    List<Integer> playerOids = playerDAO.getPlayerOidsOnAccount(accountId);

    for (int playerOid : playerOids) {
      PlayerCommonData playerCommonData = playerDAO.loadPlayerCommonData(playerOid);
      PlayerAppearance appereance = appereanceDAO.load(playerOid);

      LegionMember legionMember =
          DAOManager.getDAO(LegionMemberDAO.class).loadLegionMember(playerOid);

      /** Load only equipment and its stones to display on character selection screen */
      List<Item> equipment = DAOManager.getDAO(InventoryDAO.class).loadEquipment(playerOid);

      PlayerAccountData acData =
          new PlayerAccountData(playerCommonData, appereance, equipment, legionMember);
      playerDAO.setCreationDeletionTime(acData);

      account.addPlayerAccountData(acData);

      /** load account warehouse only once */
      if (account.getAccountWarehouse() == null) {
        // TODO memory lake.....
        Player player = new Player(new PlayerController(), playerCommonData, appereance, account);
        Storage accWarehouse =
            DAOManager.getDAO(InventoryDAO.class)
                .loadStorage(player, StorageType.ACCOUNT_WAREHOUSE);
        ItemService.loadItemStones(accWarehouse.getStorageItems());
        account.setAccountWarehouse(accWarehouse);
      }
    }

    /** For new accounts - create empty account warehouse */
    if (account.getAccountWarehouse() == null)
      account.setAccountWarehouse(new Storage(StorageType.ACCOUNT_WAREHOUSE));

    return account;
  }
Пример #2
0
 /**
  * Load characters count on account from database
  *
  * @param accountId
  * @return
  */
 public static int getCharacterCountFor(int accountId) {
   PlayerDAO playerDAO = DAOManager.getDAO(PlayerDAO.class);
   return playerDAO.getCharacterCountOnAccount(accountId);
 }