Пример #1
0
 @SuppressWarnings("unchecked")
 public void removeFriend(String username) {
   Object isSuccess = ServerAccess.removeFriend(new NewFriendRequest(player, username));
   if (isSuccess != null && (boolean) isSuccess) {
     obj = ServerAccess.getFriends(player);
     if (obj != null) {
       friendList = (ArrayList<Friend>) obj;
     }
   }
 }
Пример #2
0
  @SuppressWarnings("unchecked")
  public boolean attemptLogin(String username, String password) {
    NewPlayerRequest loginRequest = new NewPlayerRequest(username, password, null);
    obj = ServerAccess.loginRequest(loginRequest);
    if (obj != null) {
      player = (Player) obj;

      isLoggedIn = true;

      obj = ServerAccess.getFriends(player);
      if (obj != null) {
        friendList = (ArrayList<Friend>) obj;
      }

      obj = ServerAccess.getMenuChat();
      if (obj != null) {
        menuChat = (ArrayList<ChatEntry>) obj;
      }

      /* Server calls to initialize stats */
      updateAchievements();
      obj = ServerAccess.getGameLobbyList(new GameLobbyRequest(null, 0, CardGameType.War));
      if (obj != null) {
        warLobbies = (GameLobby[]) obj;
      }

      obj = ServerAccess.getGameLobbyList(new GameLobbyRequest(null, 0, CardGameType.ERS));
      if (obj != null) {
        ratscrewLobbies = (GameLobby[]) obj;
      }

      obj = ServerAccess.getGameLobbyList(new GameLobbyRequest(null, 0, CardGameType.TexasHoldEm));
      if (obj != null) {
        texasHoldemLobbies = (GameLobby[]) obj;
      }

      obj = ServerAccess.getBlackJackTables();
      if (obj != null) {
        blackJackTables = (BlackJack[]) obj;
      }

      /*
       * Initialize thread that will periodically ask server for updates
       * to update model
       */
      UpdateChecker updateChecker = new UpdateChecker(this);
      Thread t = new Thread(updateChecker);
      t.start();

      return true;
    }
    return false;
  }