Added infrastructure code for game summaries
This commit is contained in:
@@ -18,7 +18,7 @@ public abstract class Score {
|
||||
private int ignoreLastPlayers = 0;
|
||||
private boolean isClosed = false;
|
||||
protected Game instance;
|
||||
private List<Set<Player>> scores = new ArrayList<>();
|
||||
private final List<Set<Player>> scores = new ArrayList<>();
|
||||
|
||||
public Score() {}
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class Score {
|
||||
if(instance.getPlayers().isEmpty()) return;
|
||||
if(resultCount() >= instance.getPlayers().size() - ignoreLastPlayers) {
|
||||
if(ignoreLastPlayers > 0) {
|
||||
insertRemainingPlayers(instance.getPlayers().stream().filter(player -> !hasResult(player)).collect(Collectors.toSet()));
|
||||
insertRemainingPlayers(instance.getPlayers());
|
||||
}
|
||||
setDone();
|
||||
}
|
||||
@@ -55,9 +55,8 @@ public abstract class Score {
|
||||
this.checkGameEnd();
|
||||
}
|
||||
|
||||
private void insertRemainingPlayers(Set<Player> p) {
|
||||
if(p.stream().anyMatch(this::hasResult)) return;
|
||||
this.insertResultImplementation((p));
|
||||
private void insertRemainingPlayers(Set<Player> players) {
|
||||
this.insertResultImplementation(players.stream().filter(p -> !hasResult(p)).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
public boolean hasResult(Player p) {
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package eu.mhsl.minenet.minigames.score.tournament;
|
||||
|
||||
import eu.mhsl.minenet.minigames.score.Score;
|
||||
import net.minestom.server.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Tournament {
|
||||
private final List<Score> scores = new ArrayList<>();
|
||||
|
||||
public void addScore(Score score) {
|
||||
this.scores.add(score);
|
||||
}
|
||||
|
||||
public int getScoreCount() {
|
||||
return this.scores.size();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.scores.clear();
|
||||
}
|
||||
|
||||
public List<Map<Player, Integer>> getScores() {
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user