Fixed - join tournament late
This commit is contained in:
@@ -555,10 +555,11 @@ public class HallServer extends AbstractServer {
|
||||
if (tournament.getInfo().Parameters().requiresDeck) {
|
||||
lotroDeck = validateUserAndDeck(_formatLibrary.getFormat(tournament.getFormatCode()), player, deckName, tournament.getCollectionType());
|
||||
}
|
||||
|
||||
_tournamentService.recordTournamentPlayer(tournamentId, player.getName(), lotroDeck);
|
||||
tournament.issuePlayerMaterial(player.getName());
|
||||
result = "Joined tournament <b>" + tournament.getTournamentName() + "</b> successfully.";
|
||||
if (_tournamentService.joinTournamentLate(tournamentId, player.getName(), lotroDeck)) {
|
||||
result = "Joined tournament <b>" + tournament.getTournamentName() + "</b> successfully.";
|
||||
} else {
|
||||
result = "Joining tournament <b>" + tournament.getTournamentName() + "</b> failed.";
|
||||
}
|
||||
hallChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -536,4 +536,26 @@ public abstract class BaseTournament implements Tournament {
|
||||
public String getTableDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean join(String playerName, LotroDeck lotroDeck) {
|
||||
// Assumes the deck is validated for the tournament or null if the tournament is limited
|
||||
writeLock.lock();
|
||||
try {
|
||||
if (!isJoinable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_players.contains(playerName)) {
|
||||
return false;
|
||||
}
|
||||
_tournamentService.recordTournamentPlayer(_tournamentId, playerName, lotroDeck);
|
||||
issuePlayerMaterial(playerName);
|
||||
_players.add(playerName);
|
||||
regeneratePlayerList();
|
||||
return true;
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,7 @@ public interface Tournament {
|
||||
TournamentInfo getInfo();
|
||||
|
||||
boolean isJoinable();
|
||||
boolean join(String playerName, LotroDeck lotroDeck);
|
||||
long getSecondsRemaining() throws IllegalStateException;
|
||||
String getTableDescription();
|
||||
}
|
||||
|
||||
@@ -332,6 +332,15 @@ public class TournamentService {
|
||||
_tournamentPlayerDao.addPlayer(tournamentId, playerName, deck);
|
||||
}
|
||||
|
||||
public boolean joinTournamentLate(String tournamentId, String playerName, LotroDeck deck) {
|
||||
// Assumes the deck is validated for the tournament or null if the tournament is limited
|
||||
Tournament tournament = getTournamentById(tournamentId);
|
||||
if (tournament == null) {
|
||||
return false;
|
||||
}
|
||||
return tournament.join(playerName, deck);
|
||||
}
|
||||
|
||||
public void recordPlayerTournamentAbandon(String tournamentId, String playerName) {
|
||||
_tournamentPlayerDao.dropPlayer(tournamentId, playerName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user