Develope game branch #33
|
@ -6,10 +6,9 @@ public class Game implements Serializable {
|
|||
private Participant participant1, participant2;
|
||||
private int points1, points2;
|
||||
private Place place;
|
||||
private int index1, index2;
|
||||
|
||||
|
||||
public Game(Participant participant1, Participant participant2, int index1, int index2) {
|
||||
public Game(Participant participant1, Participant participant2) {
|
||||
this.participant1 = participant1;
|
||||
this.participant2 = participant2;
|
||||
}
|
||||
|
|
|
@ -93,15 +93,21 @@ public class Tournament implements Serializable {
|
|||
|
||||
private void calcGameSchedule() {
|
||||
Collections.shuffle(participants);
|
||||
List<Game> firstGameRound = new ArrayList<>();
|
||||
for (int i = 0; i < participants.size() - 1; i += 2) {
|
||||
firstGameRound.add(new Game(participants.get(i), participants.get(i+1), 0, i));
|
||||
|
||||
//TODO PRINT
|
||||
System.out.println("I: " + i + " " + participants.get(i).getName() +" vs " +participants.get(i+1).getName());
|
||||
|
||||
for (int i = 0; i < (Math.log(participants.size()) / Math.log(2)); i++) {
|
||||
List<Game> gameRound = new ArrayList<>();
|
||||
if (i == 0) {
|
||||
for (int j = 0; j < participants.size() - 1; j += 2) {
|
||||
gameRound.add(new Game(participants.get(j), participants.get(j+1)));
|
||||
}
|
||||
gameList.add(gameRound);
|
||||
} else {
|
||||
for (int j = 0; j < (participants.size() / Math.pow(2,i)); j++) {
|
||||
gameRound.add(new Game(null,null));
|
||||
}
|
||||
}
|
||||
}
|
||||
gameList.add(firstGameRound);
|
||||
|
||||
}
|
||||
|
||||
public void refreshGameParticipants(){
|
||||
|
@ -117,7 +123,6 @@ public class Tournament implements Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
|
@ -126,9 +126,15 @@ public class TournamentDecorator implements IsObservable{
|
|||
}
|
||||
}
|
||||
|
||||
public void refreshGameParticipants() {
|
||||
getTournament().refreshGameParticipants();
|
||||
informListener();
|
||||
}
|
||||
|
||||
public void informListener() {
|
||||
for(IsObserver observer : listener) {
|
||||
observer.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class GameController {
|
|||
gameDecorator.setPoints1(Integer.parseInt(pointsTeamOne.getText()));
|
||||
gameDecorator.setPoints2(Integer.parseInt(pointsTeamTwo.getText()));
|
||||
gameDecorator.setLocation(placesChoiceBox.getValue());
|
||||
gameDecorator.getTournamentDecorator().getTournament().refreshGameParticipants();
|
||||
gameDecorator.getTournamentDecorator().refreshGameParticipants();
|
||||
loadContent();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue