Search in sources :

Example 6 with MatchWinner

use of pl.themolka.arcade.match.MatchWinner in project Arcade2 by ShootGame.

the class ScoreGame method getDynamicWinners.

@Override
public List<MatchWinner> getDynamicWinners() {
    double highestScore = Score.MIN;
    List<MatchWinner> results = new ArrayList<>();
    for (MatchWinner winner : this.getMatch().getWinnerList()) {
        if (winner.areGoalsCompleted()) {
            results.add(winner);
        }
        Score score = this.getScore(winner);
        if (score == null) {
            continue;
        } else if (score.getScore() > highestScore) {
            results.clear();
            highestScore = score.getScore();
        }
        if (!results.contains(winner) && score.getScore() >= highestScore) {
            results.add(winner);
        }
    }
    if (highestScore != Score.MIN && !results.isEmpty()) {
        return results;
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) MatchWinner(pl.themolka.arcade.match.MatchWinner)

Aggregations

MatchWinner (pl.themolka.arcade.match.MatchWinner)6 Participator (pl.themolka.arcade.game.Participator)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Element (org.jdom2.Element)2 JDOMException (org.jdom2.JDOMException)2 MatchGame (pl.themolka.arcade.match.MatchGame)2 MatchModule (pl.themolka.arcade.match.MatchModule)2