Merge pull request #659 from SalavecJ/tournament_fixes
Tournament fixes
This commit is contained in:
@@ -145,7 +145,7 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
|
|||||||
Document doc = documentBuilder.newDocument();
|
Document doc = documentBuilder.newDocument();
|
||||||
Element tournaments = doc.createElement("tournaments");
|
Element tournaments = doc.createElement("tournaments");
|
||||||
|
|
||||||
for (Tournament tournament : _tournamentService.getOldTournaments(ZonedDateTime.now().minus(RecentTournamentDuration))) {
|
for (Tournament tournament : _tournamentService.getOldTournaments(ZonedDateTime.now().minus(RecentTournamentDuration)).reversed()) {
|
||||||
Element tournamentElem = doc.createElement("tournament");
|
Element tournamentElem = doc.createElement("tournament");
|
||||||
|
|
||||||
tournamentElem.setAttribute("id", tournament.getTournamentId());
|
tournamentElem.setAttribute("id", tournament.getTournamentId());
|
||||||
@@ -155,6 +155,10 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
|
|||||||
tournamentElem.setAttribute("round", String.valueOf(tournament.getCurrentRound()));
|
tournamentElem.setAttribute("round", String.valueOf(tournament.getCurrentRound()));
|
||||||
tournamentElem.setAttribute("stage", tournament.getTournamentStage().getHumanReadable());
|
tournamentElem.setAttribute("stage", tournament.getTournamentStage().getHumanReadable());
|
||||||
|
|
||||||
|
if (tournament.getTournamentStage().equals(Tournament.Stage.FINISHED) && tournament.getCurrentRound() == 0) {
|
||||||
|
// do NOT include past tournaments with 0 games played (for example draft of one player against bots)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tournaments.appendChild(tournamentElem);
|
tournaments.appendChild(tournamentElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,6 +409,7 @@ var ChatBoxUI = Class.extend({
|
|||||||
if(this.tournamentCallback) {
|
if(this.tournamentCallback) {
|
||||||
this.tournamentCallback(from, text);
|
this.tournamentCallback(from, text);
|
||||||
}
|
}
|
||||||
|
from = "TournamentSystem";
|
||||||
}
|
}
|
||||||
var prefix = "<div class='msg-identifier'>";
|
var prefix = "<div class='msg-identifier'>";
|
||||||
if (this.showTimestamps) {
|
if (this.showTimestamps) {
|
||||||
|
|||||||
@@ -35,13 +35,11 @@ var TournamentResultsUI = Class.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
loadedTournament:function (xml) {
|
loadedTournament:function (xml, targetDiv) {
|
||||||
var that = this;
|
var that = this;
|
||||||
log(xml);
|
log(xml);
|
||||||
var root = xml.documentElement;
|
var root = xml.documentElement;
|
||||||
if (root.tagName == 'tournament') {
|
if (root.tagName == 'tournament') {
|
||||||
$("#tournamentExtraInfo").html("");
|
|
||||||
|
|
||||||
var tournament = root;
|
var tournament = root;
|
||||||
|
|
||||||
var tournamentId = tournament.getAttribute("id");
|
var tournamentId = tournament.getAttribute("id");
|
||||||
@@ -51,16 +49,16 @@ var TournamentResultsUI = Class.extend({
|
|||||||
var tournamentRound = tournament.getAttribute("round");
|
var tournamentRound = tournament.getAttribute("round");
|
||||||
var tournamentStage = tournament.getAttribute("stage");
|
var tournamentStage = tournament.getAttribute("stage");
|
||||||
|
|
||||||
$("#tournamentExtraInfo").append("<div class='tournamentName'>" + tournamentName + "</div>");
|
targetDiv.append("<div class='tournamentFormat'><b>Format:</b> " + tournamentFormat + "</div>");
|
||||||
|
targetDiv.append("<div class='tournamentCollection'><b>Collection:</b> " + tournamentCollection + "</div>");
|
||||||
$("#tournamentExtraInfo").append("<div class='tournamentFormat'><b>Format:</b> " + tournamentFormat + "</div>");
|
|
||||||
$("#tournamentExtraInfo").append("<div class='tournamentCollection'><b>Collection:</b> " + tournamentCollection + "</div>");
|
|
||||||
if (tournamentStage == "Playing games")
|
if (tournamentStage == "Playing games")
|
||||||
$("#tournamentExtraInfo").append("<div class='tournamentRound'><b>Round:</b> " + tournamentRound + "</div>");
|
targetDiv.append("<div class='tournamentRound'><b>Round:</b> " + tournamentRound + "</div>");
|
||||||
|
|
||||||
var standings = tournament.getElementsByTagName("tournamentStanding");
|
var standings = tournament.getElementsByTagName("tournamentStanding");
|
||||||
if (standings.length > 0)
|
if (standings.length > 0)
|
||||||
$("#tournamentExtraInfo").append(this.createStandingsTable(standings, tournamentId, tournamentStage));
|
targetDiv.append(this.createStandingsTable(standings, tournamentId, tournamentStage));
|
||||||
|
|
||||||
|
targetDiv.show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -90,22 +88,25 @@ var TournamentResultsUI = Class.extend({
|
|||||||
$("#tournamentResults").append("<div class='tournamentRound'><b>Rounds:</b> " + tournamentRound + "</div>");
|
$("#tournamentResults").append("<div class='tournamentRound'><b>Rounds:</b> " + tournamentRound + "</div>");
|
||||||
|
|
||||||
var detailsBut = $("<button>See details</button>").button();
|
var detailsBut = $("<button>See details</button>").button();
|
||||||
|
$("#tournamentResults").append(detailsBut);
|
||||||
|
|
||||||
|
var extraInfoDiv = $("<div class='tournamentExtraInfo' style='display:none;'></div>");
|
||||||
|
$("#tournamentResults").append(extraInfoDiv);
|
||||||
|
|
||||||
detailsBut.click(
|
detailsBut.click(
|
||||||
(function (id) {
|
(function (id, extraInfoTarget) {
|
||||||
return function () {
|
return function () {
|
||||||
|
var btn = $(this);
|
||||||
that.communication.getTournament(id,
|
that.communication.getTournament(id,
|
||||||
function (xml) {
|
function (xml) {
|
||||||
that.loadedTournament(xml);
|
that.loadedTournament(xml, extraInfoTarget);
|
||||||
|
btn.hide();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
})(tournamentId));
|
})(tournamentId, extraInfoDiv));
|
||||||
$("#tournamentResults").append(detailsBut);
|
|
||||||
}
|
}
|
||||||
if (tournaments.length == 0)
|
if (tournaments.length == 0)
|
||||||
$("#tournamentResults").append("<i>There is no running tournaments at the moment</i>");
|
$("#tournamentResults").append("<i>There is no running tournaments at the moment</i>");
|
||||||
|
|
||||||
$("#tournamentResults").append("<hr />");
|
|
||||||
$("#tournamentResults").append("<div id='tournamentExtraInfo'></div>");
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
|
||||||
tournament.issuePlayerMaterial(player.getName());
|
|
||||||
result = "Joined tournament <b>" + tournament.getTournamentName() + "</b> successfully.";
|
result = "Joined tournament <b>" + tournament.getTournamentName() + "</b> successfully.";
|
||||||
|
} else {
|
||||||
|
result = "Joining tournament <b>" + tournament.getTournamentName() + "</b> failed.";
|
||||||
|
}
|
||||||
hallChanged();
|
hallChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,13 +583,13 @@ public class HallServer extends AbstractServer {
|
|||||||
var submitted = tournament.playerSubmittedDeck(player.getName(), lotroDeck);
|
var submitted = tournament.playerSubmittedDeck(player.getName(), lotroDeck);
|
||||||
|
|
||||||
if(submitted) {
|
if(submitted) {
|
||||||
result = "Registered deck '" + deckName + "' with tournament <b>" + tournament.getTournamentName() + "</b> successfully."
|
result = "Registered deck '" + deckName + "' with tournament '" + tournament.getTournamentName() + "' successfully. "
|
||||||
+ "<br/><br/>If you make an update to your deck, you will need to register it here again for any changes to take effect.";
|
+ "If you make an update to your deck, you will need to register it here again for any changes to take effect.";
|
||||||
_log.trace("Player '" + player.getName() + "' registered deck '" + deckName + "' for tournament '" + tournament.getTournamentName() + "' successfully.");
|
_log.trace("Player '" + player.getName() + "' registered deck '" + deckName + "' for tournament '" + tournament.getTournamentName() + "' successfully.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = "Could not register deck with tournament <b>" + tournament.getTournamentName() + "</b>."
|
result = "Could not register deck with tournament '" + tournament.getTournamentName() + "'. "
|
||||||
+ "<br/><br/>Please contact an administrator if you think this was in error.";
|
+ "Please contact an administrator if you think this was in error.";
|
||||||
|
|
||||||
_log.trace("Player '" + player.getName() + "' failed to register deck '" + deckName + "' for tournament '" + tournament.getTournamentName() + "'.");
|
_log.trace("Player '" + player.getName() + "' failed to register deck '" + deckName + "' for tournament '" + tournament.getTournamentName() + "'.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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