Skip to content

Commit

Permalink
Fix team stats for collective player stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Redned235 committed Jul 8, 2024
1 parent 0998945 commit b4bec98
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,38 @@ public void onStatChange(ArenaStatChangeEvent<Number> event) {
// after the team has collectively retrieved a stat, or a stat that is
// incremented by team (i.e. control points).
StatHolder statHolder = event.getStatHolder();
if (this.teamStats && statHolder instanceof TeamStatHolder teamHolder) {
if (this.winAfter != -1 && event.getNewValue().intValue() >= this.winAfter) {
this.advanceToNextPhase(this.competition.getTeamManager().getPlayersOnTeam(teamHolder.getTeam()));
if (this.teamStats) {
if (statHolder instanceof TeamStatHolder teamHolder) {
if (this.winAfter != -1 && event.getNewValue().intValue() >= this.winAfter) {
this.advanceToNextPhase(this.competition.getTeamManager().getPlayersOnTeam(teamHolder.getTeam()));
}
} else if (statHolder instanceof ArenaPlayer player) {
// Check for stats across all players on the team
ArenaTeam team = player.getTeam();
if (team == null) {
return;
}

Set<ArenaPlayer> players = this.competition.getTeamManager().getPlayersOnTeam(team);
int score = 0;
for (ArenaPlayer teamPlayer : players) {
if (teamPlayer == player) {
score += event.getNewValue().intValue();
continue;
}

score += teamPlayer.stat(this.stat).orElse(0).intValue();
}

if (score >= this.winAfter) {
this.advanceToNextPhase(players);
}
}

return;
}

if (!this.teamStats && statHolder instanceof ArenaPlayer player) {
if (statHolder instanceof ArenaPlayer player) {
if (this.winAfter != -1 && event.getNewValue().intValue() >= this.winAfter) {
// Still need to check if the player is on a team, since we grant
// the victory based on whether the team one. If the player is to
Expand Down

0 comments on commit b4bec98

Please sign in to comment.