|
| 1 | +package material.stats; |
| 2 | + |
| 3 | +import com.google.gson.JsonObject; |
| 4 | +import material.user.BungieUser; |
| 5 | + |
| 6 | +public class ActivityParticipant { |
| 7 | + |
| 8 | + private JsonObject jo; |
| 9 | + private BungieUser bungieUser; |
| 10 | + private String membershipId, characterId; |
| 11 | + private int score, assists, deaths, kills, opponentsDefeated, activityDuration, completionReason; |
| 12 | + private double kdr, kda, completed, effeciency, startSeconds, timePlayed; |
| 13 | + JsonObject values; |
| 14 | + |
| 15 | + public ActivityParticipant(JsonObject entry) { |
| 16 | + jo = entry.getAsJsonObject("values"); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * Get the membership ID of this user |
| 21 | + */ |
| 22 | + public String getMembershipId() { |
| 23 | + if (membershipId != null) return membershipId; |
| 24 | + jo.getAsJsonObject("player").getAsJsonObject("destinyUserInfo").get("membershipId").getAsString(); |
| 25 | + return membershipId; |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Gets the bungie user of this |
| 30 | += */ |
| 31 | + public BungieUser getBungieUser() { |
| 32 | + if (bungieUser != null) return bungieUser; |
| 33 | + bungieUser = new BungieUser(getMembershipId()); |
| 34 | + return bungieUser; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Get the character ID of the player |
| 39 | += */ |
| 40 | + public String getCharacterId() { |
| 41 | + if (characterId != null) return characterId; |
| 42 | + characterId = jo.get("characterId").getAsString(); |
| 43 | + return characterId; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Gets the score of the user in this activity |
| 48 | + */ |
| 49 | + public int getScore() { |
| 50 | + if (score != 0) return score; |
| 51 | + score = jo.getAsJsonObject("score").getAsJsonObject("basic").get("value").getAsInt(); |
| 52 | + return score; |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Get the assists of the user |
| 57 | +- */ |
| 58 | + public int getAssists() { |
| 59 | + if (assists != 0) return assists; |
| 60 | + assists = jo.getAsJsonObject("assists").getAsJsonObject("basic").get("value").getAsInt(); |
| 61 | + return assists; |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Get if this user completed the activity |
| 66 | +- */ |
| 67 | + public double getCompleted() { |
| 68 | + if(completed != 0) return completed; |
| 69 | + completed = jo.getAsJsonObject("completed").getAsJsonObject("basic").get("value").getAsDouble(); |
| 70 | + return completed; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Get the number of deaths for this user |
| 75 | + */ |
| 76 | + public int getDeaths() { |
| 77 | + if(deaths != 0) return deaths; |
| 78 | + deaths = jo.getAsJsonObject("deaths").getAsJsonObject("basic").get("value").getAsInt(); |
| 79 | + return deaths; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Get the number of kills for this user |
| 84 | + */ |
| 85 | + public int getKills() { |
| 86 | + if(kills != 0) return kills; |
| 87 | + kills = jo.getAsJsonObject("kills").getAsJsonObject("basic").get("value").getAsInt(); |
| 88 | + return kills; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Gets the number of opponents this user defeated |
| 93 | +- */ |
| 94 | + public int getOpponentsDefeated() { |
| 95 | + if(opponentsDefeated != 0) return opponentsDefeated; |
| 96 | + opponentsDefeated = jo.getAsJsonObject("opponentsDefeated").getAsJsonObject("basic").get("value").getAsInt(); |
| 97 | + return opponentsDefeated; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Get the effeciency of this user |
| 102 | + */ |
| 103 | + public double getEffeciency() { |
| 104 | + if(effeciency != 0) return effeciency; |
| 105 | + effeciency = jo.getAsJsonObject("efficiency").getAsJsonObject("basic").get("value").getAsDouble(); |
| 106 | + return effeciency; |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Gets the Kill-Death Ratio of this user |
| 111 | + */ |
| 112 | + public double getKdr() { |
| 113 | + if(kdr != 0) return kdr; |
| 114 | + kdr = jo.getAsJsonObject("killsDeathsRatio").getAsJsonObject("basic").get("value").getAsDouble(); |
| 115 | + return kdr; |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * Gets the Kill-Deaths-Assists of this user |
| 120 | + */ |
| 121 | + public double getKda() { |
| 122 | + if(kda != 0) return kda; |
| 123 | + kda = jo.getAsJsonObject("killsDeathsAssists").getAsJsonObject("basic").get("value").getAsDouble(); |
| 124 | + return kda; |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Gets the duration, in seconds, of this activity |
| 129 | + */ |
| 130 | + public int getActivityDuration() { |
| 131 | + if(activityDuration != 0) return activityDuration; |
| 132 | + activityDuration = jo.getAsJsonObject("activityDurationSeconds").getAsJsonObject("basic").get("value").getAsInt(); |
| 133 | + return activityDuration; |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * Gets the reason why this activity was completed |
| 138 | + */ |
| 139 | + public int getCompletionReason() { |
| 140 | + if(completionReason != 0) return completionReason; |
| 141 | + completionReason = jo.getAsJsonObject("completionReason").getAsJsonObject("basic").get("value").getAsInt(); |
| 142 | + return completionReason; |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * Gets the time the user joined the activity? |
| 147 | + */ |
| 148 | + public double getStartSeconds() { |
| 149 | + if(startSeconds != 0) return startSeconds; |
| 150 | + startSeconds = jo.getAsJsonObject("startSeconds").getAsJsonObject("basic").get("value").getAsDouble(); |
| 151 | + return startSeconds; |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Gets how long this user played in this activity |
| 156 | + */ |
| 157 | + public double getTimePlayed() { |
| 158 | + if(timePlayed != 0) return timePlayed; |
| 159 | + timePlayed = jo.getAsJsonObject("timePlayedSeconds").getAsJsonObject("basic").get("value").getAsDouble(); |
| 160 | + return timePlayed; |
| 161 | + } |
| 162 | +} |
0 commit comments