Fixed - join tournament late
This commit is contained in:
@@ -555,10 +555,11 @@ public class HallServer extends AbstractServer {
|
|||||||
if (tournament.getInfo().Parameters().requiresDeck) {
|
if (tournament.getInfo().Parameters().requiresDeck) {
|
||||||
lotroDeck = validateUserAndDeck(_formatLibrary.getFormat(tournament.getFormatCode()), player, deckName, tournament.getCollectionType());
|
lotroDeck = validateUserAndDeck(_formatLibrary.getFormat(tournament.getFormatCode()), player, deckName, tournament.getCollectionType());
|
||||||
}
|
}
|
||||||
|
if (_tournamentService.joinTournamentLate(tournamentId, player.getName(), lotroDeck)) {
|
||||||
_tournamentService.recordTournamentPlayer(tournamentId, player.getName(), lotroDeck);
|
result = "Joined tournament <b>" + tournament.getTournamentName() + "</b> successfully.";
|
||||||
tournament.issuePlayerMaterial(player.getName());
|
} else {
|
||||||
result = "Joined tournament <b>" + tournament.getTournamentName() + "</b> successfully.";
|
result = "Joining tournament <b>" + tournament.getTournamentName() + "</b> failed.";
|
||||||
|
}
|
||||||
hallChanged();
|
hallChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -536,4 +536,26 @@ public abstract class BaseTournament implements Tournament {
|
|||||||
public String getTableDescription() {
|
public String getTableDescription() {
|
||||||
return null;
|
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();
|
TournamentInfo getInfo();
|
||||||
|
|
||||||
boolean isJoinable();
|
boolean isJoinable();
|
||||||
|
boolean join(String playerName, LotroDeck lotroDeck);
|
||||||
long getSecondsRemaining() throws IllegalStateException;
|
long getSecondsRemaining() throws IllegalStateException;
|
||||||
String getTableDescription();
|
String getTableDescription();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,6 +332,15 @@ public class TournamentService {
|
|||||||
_tournamentPlayerDao.addPlayer(tournamentId, playerName, deck);
|
_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) {
|
public void recordPlayerTournamentAbandon(String tournamentId, String playerName) {
|
||||||
_tournamentPlayerDao.dropPlayer(tournamentId, playerName);
|
_tournamentPlayerDao.dropPlayer(tournamentId, playerName);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user