Notify of changes to tournament.
This commit is contained in:
@@ -689,11 +689,11 @@ public class HallServer extends AbstractServer {
|
||||
|
||||
for (Map.Entry<String, Tournament> tournamentEntry : new HashMap<String, Tournament>(_runningTournaments).entrySet()) {
|
||||
Tournament runningTournament = tournamentEntry.getValue();
|
||||
runningTournament.advanceTournament(new HallTournamentCallback(runningTournament), _collectionsManager);
|
||||
if (runningTournament.getTournamentStage() == Tournament.Stage.FINISHED) {
|
||||
boolean changed = runningTournament.advanceTournament(new HallTournamentCallback(runningTournament), _collectionsManager);
|
||||
if (runningTournament.getTournamentStage() == Tournament.Stage.FINISHED)
|
||||
_runningTournaments.remove(tournamentEntry.getKey());
|
||||
if (changed)
|
||||
hallChanged();
|
||||
}
|
||||
}
|
||||
|
||||
if (_tickCounter == 60) {
|
||||
|
||||
@@ -226,9 +226,10 @@ public class DefaultTournament implements Tournament {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void advanceTournament(TournamentCallback tournamentCallback, CollectionsManager collectionsManager) {
|
||||
public boolean advanceTournament(TournamentCallback tournamentCallback, CollectionsManager collectionsManager) {
|
||||
_lock.writeLock().lock();
|
||||
try {
|
||||
boolean result = false;
|
||||
if (_nextTask == null) {
|
||||
if (_tournamentStage == Stage.DRAFT) {
|
||||
_draft.advanceDraft(tournamentCallback);
|
||||
@@ -238,6 +239,7 @@ public class DefaultTournament implements Tournament {
|
||||
_tournamentService.updateTournamentStage(_tournamentId, _tournamentStage);
|
||||
_deckBuildStartTime = System.currentTimeMillis();
|
||||
_draft = null;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if (_tournamentStage == Stage.DECK_BUILDING) {
|
||||
@@ -245,6 +247,7 @@ public class DefaultTournament implements Tournament {
|
||||
|| _playerDecks.size() == _players.size()) {
|
||||
_tournamentStage = Stage.PLAYING_GAMES;
|
||||
_tournamentService.updateTournamentStage(_tournamentId, _tournamentStage);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if (_tournamentStage == Stage.PLAYING_GAMES) {
|
||||
@@ -255,6 +258,7 @@ public class DefaultTournament implements Tournament {
|
||||
tournamentCallback.broadcastMessage("Tournament " + _tournamentName + " will start round "+(_tournamentRound+1)+" in 2 minutes");
|
||||
_nextTask = new PairPlayers();
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,7 +266,9 @@ public class DefaultTournament implements Tournament {
|
||||
TournamentTask task = _nextTask;
|
||||
_nextTask = null;
|
||||
task.executeTask(tournamentCallback, collectionsManager);
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
_lock.writeLock().unlock();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface Tournament {
|
||||
public int getCurrentRound();
|
||||
public int getPlayersInCompetitionCount();
|
||||
|
||||
public void advanceTournament(TournamentCallback tournamentCallback, CollectionsManager collectionsManager);
|
||||
public boolean advanceTournament(TournamentCallback tournamentCallback, CollectionsManager collectionsManager);
|
||||
|
||||
public void reportGameFinished(String winner, String loser);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user