Exemplo n.º 1
0
  public void leaveGameLobby(CardGameType gameType, int lobbyId) {
    GameLobbyRequest glr = new GameLobbyRequest(player, lobbyId, gameType);
    isInLobby = false;
    setCurrentLobby(null, -1);
    ServerAccess.leaveLobby(glr);

    if (gameType == CardGameType.War) {
      obj = ServerAccess.getGameLobbyList(glr);
      if (obj != null) {
        warLobbies = (GameLobby[]) obj;
      }
    } else if (gameType == CardGameType.TexasHoldEm) {
      obj = ServerAccess.getGameLobbyList(glr);
      if (obj != null) {
        texasHoldemLobbies = (GameLobby[]) obj;
      }
    } else if (gameType == CardGameType.ERS) {
      obj = ServerAccess.getGameLobbyList(glr);
      if (obj != null) {
        ratscrewLobbies = (GameLobby[]) obj;
      }
    }

    return;
  }
Exemplo n.º 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;
  }
Exemplo n.º 3
0
  /**
   * ******************************************************* Game lobby mgmt model calls.
   * *******************************************************
   */
  public void joinGameLobby(CardGameType gameType, int lobbyId) {
    GameLobbyRequest glr = new GameLobbyRequest(player, lobbyId, gameType);

    if (gameType == CardGameType.War) {
      /* Check for space in lobby */
      if (warLobbies[lobbyId].getPlayers().size() < 2) {
        isInLobby = true;
        setCurrentLobby(gameType, lobbyId);
        ServerAccess.joinLobby(glr);

        obj = ServerAccess.getGameLobbyList(glr);
        if (obj != null) {
          warLobbies = (GameLobby[]) obj;
        }
      }
    } else if (gameType == CardGameType.TexasHoldEm) {
      if (texasHoldemLobbies[lobbyId].getPlayers().size() < 4) {
        isInLobby = true;
        setCurrentLobby(gameType, lobbyId);
        ServerAccess.joinLobby(glr);

        obj = ServerAccess.getGameLobbyList(glr);
        if (obj != null) {
          texasHoldemLobbies = (GameLobby[]) obj;
        }
      }
    } else if (gameType == CardGameType.ERS) {
      System.out.println("hello");
      if (ratscrewLobbies[lobbyId].getPlayers().size() < 2) {
        isInLobby = true;
        setCurrentLobby(gameType, lobbyId);
        ServerAccess.joinLobby(glr);

        obj = ServerAccess.getGameLobbyList(glr);
        if (obj != null) {
          ratscrewLobbies = (GameLobby[]) obj;
        }
      }
    }
    return;
  }