Merge pull request #629 from SalavecJ/draft_timer_fix
Fixed - broken draft timers
This commit is contained in:
@@ -28,6 +28,8 @@ public class TableDraftTournament extends BaseTournament implements Tournament {
|
|||||||
private TableDraft table = null;
|
private TableDraft table = null;
|
||||||
private final ChatServer chatServer;
|
private final ChatServer chatServer;
|
||||||
private ZonedDateTime nextRoundStart = null;
|
private ZonedDateTime nextRoundStart = null;
|
||||||
|
public ZonedDateTime deckbuildingDeadline = null;
|
||||||
|
public ZonedDateTime registrationDeadline = null;
|
||||||
|
|
||||||
public TableDraftTournament(TournamentService tournamentService, CollectionsManager collectionsManager, ProductLibrary productLibrary,
|
public TableDraftTournament(TournamentService tournamentService, CollectionsManager collectionsManager, ProductLibrary productLibrary,
|
||||||
LotroFormatLibrary formatLibrary, SoloDraftDefinitions soloDraftDefinitions, TableDraftDefinitions tableDraftDefinitions,
|
LotroFormatLibrary formatLibrary, SoloDraftDefinitions soloDraftDefinitions, TableDraftDefinitions tableDraftDefinitions,
|
||||||
@@ -89,13 +91,13 @@ public class TableDraftTournament extends BaseTournament implements Tournament {
|
|||||||
if (getTournamentStage() == Stage.DRAFT) {
|
if (getTournamentStage() == Stage.DRAFT) {
|
||||||
createTable();
|
createTable();
|
||||||
} else if (getTournamentStage() == Stage.DECK_BUILDING) {
|
} else if (getTournamentStage() == Stage.DECK_BUILDING) {
|
||||||
if (tableDraftInfo.deckbuildingDeadline == null || tableDraftInfo.registrationDeadline == null) {
|
if (deckbuildingDeadline == null) {
|
||||||
tableDraftInfo.deckbuildingDeadline = DateUtils.Now().plus(tableDraftInfo.deckbuildingDuration);
|
deckbuildingDeadline = DateUtils.Now().plus(tableDraftInfo.deckbuildingDuration);
|
||||||
tableDraftInfo.registrationDeadline = tableDraftInfo.deckbuildingDeadline.plus(tableDraftInfo.registrationDuration);
|
registrationDeadline = deckbuildingDeadline.plus(tableDraftInfo.registrationDuration);
|
||||||
}
|
}
|
||||||
} else if (getTournamentStage() == Stage.DECK_REGISTRATION) {
|
} else if (getTournamentStage() == Stage.DECK_REGISTRATION) {
|
||||||
if (tableDraftInfo.registrationDeadline == null) {
|
if (registrationDeadline == null) {
|
||||||
tableDraftInfo.registrationDeadline = DateUtils.Now().plus(tableDraftInfo.registrationDuration);
|
registrationDeadline = DateUtils.Now().plus(tableDraftInfo.registrationDuration);
|
||||||
}
|
}
|
||||||
} else if (_tournamentInfo.Stage == Stage.PLAYING_GAMES) {
|
} else if (_tournamentInfo.Stage == Stage.PLAYING_GAMES) {
|
||||||
var matchesToCreate = new HashMap<String, String>();
|
var matchesToCreate = new HashMap<String, String>();
|
||||||
@@ -162,30 +164,37 @@ public class TableDraftTournament extends BaseTournament implements Tournament {
|
|||||||
_tournamentInfo.Stage = Stage.DECK_BUILDING;
|
_tournamentInfo.Stage = Stage.DECK_BUILDING;
|
||||||
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
||||||
|
|
||||||
tableDraftInfo.deckbuildingDeadline = DateUtils.Now().plus(tableDraftInfo.deckbuildingDuration);
|
deckbuildingDeadline = DateUtils.Now().plus(tableDraftInfo.deckbuildingDuration);
|
||||||
tableDraftInfo.registrationDeadline = tableDraftInfo.deckbuildingDeadline.plus(tableDraftInfo.registrationDuration);
|
registrationDeadline = deckbuildingDeadline.plus(tableDraftInfo.registrationDuration);
|
||||||
|
|
||||||
String duration = DateUtils.HumanDuration(tableDraftInfo.deckbuildingDuration);
|
String duration = DateUtils.HumanDuration(tableDraftInfo.deckbuildingDuration);
|
||||||
result.add(new BroadcastAction("Draft has finished for tournament <b>" + getTournamentName() + "</b>. " +
|
result.add(new BroadcastAction("Draft has finished for tournament <b>" + getTournamentName() + "</b>. " +
|
||||||
"Players now have " + duration + " to build a deck with the cards they got. "
|
"Players now have " + duration + " to build a deck with the cards they got. "
|
||||||
+ "<br/><br/>Remember to return to the game hall and register your deck before " + DateUtils.FormatTime(tableDraftInfo.registrationDeadline) + ".", activePlayers));
|
+ "<br/><br/>Remember to return to the game hall and register your deck before " + DateUtils.FormatTime(registrationDeadline) + ".", activePlayers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (getTournamentStage() == Stage.DECK_BUILDING) {
|
else if (getTournamentStage() == Stage.DECK_BUILDING) {
|
||||||
if (DateUtils.Now().isAfter(tableDraftInfo.deckbuildingDeadline)) {
|
if (deckbuildingDeadline == null) {
|
||||||
|
deckbuildingDeadline = DateUtils.Now().plus(tableDraftInfo.deckbuildingDuration);
|
||||||
|
registrationDeadline = deckbuildingDeadline.plus(tableDraftInfo.registrationDuration);
|
||||||
|
}
|
||||||
|
if (DateUtils.Now().isAfter(deckbuildingDeadline)) {
|
||||||
_tournamentInfo.Stage = Stage.DECK_REGISTRATION;
|
_tournamentInfo.Stage = Stage.DECK_REGISTRATION;
|
||||||
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
||||||
|
|
||||||
String duration = DateUtils.HumanDuration(tableDraftInfo.registrationDuration);
|
String duration = DateUtils.HumanDuration(tableDraftInfo.registrationDuration);
|
||||||
result.add(new BroadcastAction("Deck building in tournament <b>" + getTournamentName() + "</b> has finished. Players now have "
|
result.add(new BroadcastAction("Deck building in tournament <b>" + getTournamentName() + "</b> has finished. Players now have "
|
||||||
+ duration + " to finish registering their decks. Any player who has not turned in their deck by the deadline at "
|
+ duration + " to finish registering their decks. Any player who has not turned in their deck by the deadline at "
|
||||||
+ DateUtils.FormatTime(tableDraftInfo.registrationDeadline) + " will be auto-disqualified."
|
+ DateUtils.FormatTime(registrationDeadline) + " will be auto-disqualified."
|
||||||
+ "<br/><br/>Once the deadline has passed, the tournament will begin.", activePlayers));
|
+ "<br/><br/>Once the deadline has passed, the tournament will begin.", activePlayers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTournamentStage() == Stage.DECK_REGISTRATION) {
|
if (getTournamentStage() == Stage.DECK_REGISTRATION) {
|
||||||
if (DateUtils.Now().isAfter(tableDraftInfo.registrationDeadline)) {
|
if (registrationDeadline == null) {
|
||||||
|
registrationDeadline = DateUtils.Now().plus(tableDraftInfo.registrationDuration);
|
||||||
|
}
|
||||||
|
if (DateUtils.Now().isAfter(registrationDeadline)) {
|
||||||
disqualifyUnregisteredPlayers();
|
disqualifyUnregisteredPlayers();
|
||||||
|
|
||||||
_tournamentInfo.Stage = tableDraftInfo.postRegistrationStage();
|
_tournamentInfo.Stage = tableDraftInfo.postRegistrationStage();
|
||||||
@@ -268,10 +277,10 @@ public class TableDraftTournament extends BaseTournament implements Tournament {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSecondsRemaining() throws IllegalStateException {
|
public long getSecondsRemaining() throws IllegalStateException {
|
||||||
if (getTournamentStage() == Stage.DECK_BUILDING) {
|
if (getTournamentStage() == Stage.DECK_BUILDING && deckbuildingDeadline != null && DateUtils.Now().isBefore(deckbuildingDeadline)) {
|
||||||
return Duration.between(DateUtils.Now(), tableDraftInfo.deckbuildingDeadline).getSeconds();
|
return Duration.between(DateUtils.Now(), deckbuildingDeadline).getSeconds();
|
||||||
} else if (getTournamentStage() == Stage.DECK_REGISTRATION) {
|
} else if (getTournamentStage() == Stage.DECK_REGISTRATION && registrationDeadline != null && DateUtils.Now().isBefore(registrationDeadline)) {
|
||||||
return Duration.between(DateUtils.Now(), tableDraftInfo.registrationDeadline).getSeconds();
|
return Duration.between(DateUtils.Now(), registrationDeadline).getSeconds();
|
||||||
} else if (getTournamentStage() == Stage.PLAYING_GAMES && nextRoundStart != null && DateUtils.Now().isBefore(nextRoundStart)) {
|
} else if (getTournamentStage() == Stage.PLAYING_GAMES && nextRoundStart != null && DateUtils.Now().isBefore(nextRoundStart)) {
|
||||||
return Duration.between(DateUtils.Now(), nextRoundStart).getSeconds();
|
return Duration.between(DateUtils.Now(), nextRoundStart).getSeconds();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ import java.time.ZonedDateTime;
|
|||||||
public class TableDraftTournamentInfo extends TournamentInfo {
|
public class TableDraftTournamentInfo extends TournamentInfo {
|
||||||
|
|
||||||
public final TableDraftDefinition tableDraftDefinition;
|
public final TableDraftDefinition tableDraftDefinition;
|
||||||
public ZonedDateTime deckbuildingDeadline;
|
|
||||||
public final Duration deckbuildingDuration;
|
public final Duration deckbuildingDuration;
|
||||||
public ZonedDateTime registrationDeadline;
|
|
||||||
public final Duration registrationDuration;
|
public final Duration registrationDuration;
|
||||||
protected TableDraftTournamentParams tableDraftParams;
|
protected TableDraftTournamentParams tableDraftParams;
|
||||||
|
|
||||||
@@ -30,9 +28,6 @@ public class TableDraftTournamentInfo extends TournamentInfo {
|
|||||||
|
|
||||||
deckbuildingDuration = Duration.ofMinutes(tableDraftParams.deckbuildingDuration);
|
deckbuildingDuration = Duration.ofMinutes(tableDraftParams.deckbuildingDuration);
|
||||||
registrationDuration = Duration.ofMinutes(tableDraftParams.turnInDuration);
|
registrationDuration = Duration.ofMinutes(tableDraftParams.turnInDuration);
|
||||||
//
|
|
||||||
deckbuildingDeadline = StartTime.plus(deckbuildingDuration);
|
|
||||||
// registrationDeadline = deckbuildingDeadline.plus(registrationDuration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used by tournament queues to duplicate a template info with fresh parameters
|
//Used by tournament queues to duplicate a template info with fresh parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user