-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRound.java
47 lines (45 loc) · 1.24 KB
/
Round.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.*;
public class Round{
int roundNum;
LinkedList<Match> matches;
Pairing pair;
public Round(int roundNum, LinkedList<Player> active){
pair = new Pairing();
this.roundNum = roundNum;
matches = pair.getMatches(roundNum, active);
}
public boolean finishMatch(int table, int win, int loss, int draw){
Iterator<Match> materate = matches.stream().filter(a -> a.getTable() == table).iterator();
Match curMatch = materate.next();
return curMatch.matchResult(win, loss, draw);
}
public boolean roundFinished(){
Iterator<Match> materate = matches.stream().iterator();
while(materate.hasNext()){
if(!materate.next().getDone()) return false;
}
materate = matches.stream().iterator();
while(materate.hasNext()){
materate.next().finishMatch();
}
return true;
}
public LinkedList<Match> getMatches(){
return matches;
}
public int getRoundNum(){
return roundNum;
}
//DEBUG
public void printMatches(){
Iterator<Match> mat = matches.stream().iterator();
while(mat.hasNext()){
Match m = mat.next();
if(m.getPlayer2() != null){
System.out.println("P1: " + m.getPlayer1().getName() + " P2: " + m.getPlayer2().getName());
} else {
System.out.println("P1: " + m.getPlayer1().getName());
}
}
}
}