Beispiel #1
0
  /**
   * return the best scores of all levels in one level group.
   *
   * @param playerProfile
   * @return
   */
  public Map<Integer, Score> getPlayerBestScores(
      PlayerProfile playerProfile, LevelGroup levelGroup) {
    String selectScore =
        "select level_id, score, compare_score, reached_date,is_uploaded,server_score_id from score where player_id ="
            + playerProfile.getId()
            + " and level_group_id="
            + levelGroup.id;
    Map<Integer, Score> bestScores = new HashMap<Integer, Score>();

    DatabaseCursor cursor = FlyDBManager.getInstance().selectData(selectScore);
    if (cursor != null && cursor.getCount() > 0) {

      while (cursor.next()) {
        int levelId = cursor.getInt(0);
        Score score = new Score();
        score.setTotalScore(cursor.getInt(1));
        score.setCompareScore(cursor.getString(2));
        // todo score.setReachedDate(cursor.getString(3));
        score.setIsUploaded(cursor.getInt(4) > 0);
        score.setServerScoreId(cursor.getInt(5));

        Gdx.app.log("ScoreManager", "LevelId: " + levelId);
        bestScores.put(levelId, score);
      }
      cursor.close();
    }

    return bestScores;
  }
Beispiel #2
0
  public Score getLevelBestScore(PlayerProfile playerProfile, LevelProfile level) {
    int levelgroupID = playerProfile.getCurrentLevelGroup().id;
    String selectScore =
        "select score, compare_score, reached_date, is_uploaded, server_score_id from score where player_id ="
            + playerProfile.getId()
            + " and level_id="
            + level.id
            + " and level_group_id="
            + levelgroupID;
    Score score = null;

    DatabaseCursor cursor = FlyDBManager.getInstance().selectData(selectScore);
    if (cursor != null && cursor.getCount() > 0) {
      cursor.next();
      score = new Score();
      score.setTotalScore(cursor.getInt(0));
      score.setCompareScore(cursor.getString(1));
      // todo score.setReachedDate(cursor.getString(2));
      score.setIsUploaded(cursor.getInt(3) > 0);
      score.setServerScoreId(cursor.getInt(4));
      cursor.close();
    }
    return score;
  }