Develope game branch #33

Merged
schrom01 merged 23 commits from develope_Game_branch into main 2022-05-12 13:44:47 +02:00
4 changed files with 21 additions and 11 deletions
Showing only changes of commit e5dc6a913a - Show all commits

View File

@ -6,10 +6,9 @@ public class Game implements Serializable {
private Participant participant1, participant2; private Participant participant1, participant2;
private int points1, points2; private int points1, points2;
private Place place; 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.participant1 = participant1;
this.participant2 = participant2; this.participant2 = participant2;
} }

View File

@ -93,15 +93,21 @@ public class Tournament implements Serializable {
private void calcGameSchedule() { private void calcGameSchedule() {
Collections.shuffle(participants); 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(firstGameRound); gameList.add(gameRound);
} else {
for (int j = 0; j < (participants.size() / Math.pow(2,i)); j++) {
gameRound.add(new Game(null,null));
}
}
}
} }
public void refreshGameParticipants(){ public void refreshGameParticipants(){
@ -117,7 +123,6 @@ public class Tournament implements Serializable {
} }
} }
} }
} }
public String getName() { public String getName() {

View File

@ -126,9 +126,15 @@ public class TournamentDecorator implements IsObservable{
} }
} }
public void refreshGameParticipants() {
getTournament().refreshGameParticipants();
informListener();
}
public void informListener() { public void informListener() {
for(IsObserver observer : listener) { for(IsObserver observer : listener) {
observer.update(); observer.update();
} }
} }
} }

View File

@ -32,7 +32,7 @@ public class GameController {
gameDecorator.setPoints1(Integer.parseInt(pointsTeamOne.getText())); gameDecorator.setPoints1(Integer.parseInt(pointsTeamOne.getText()));
gameDecorator.setPoints2(Integer.parseInt(pointsTeamTwo.getText())); gameDecorator.setPoints2(Integer.parseInt(pointsTeamTwo.getText()));
gameDecorator.setLocation(placesChoiceBox.getValue()); gameDecorator.setLocation(placesChoiceBox.getValue());
gameDecorator.getTournamentDecorator().getTournament().refreshGameParticipants(); gameDecorator.getTournamentDecorator().refreshGameParticipants();
loadContent(); loadContent();
} }