A lot of small fixes.

This commit is contained in:
marcins78@gmail.com
2012-04-24 19:28:05 +00:00
parent b85486c2cd
commit d03d8e1cd6
12 changed files with 105 additions and 80 deletions

View File

@@ -18,11 +18,11 @@ public class GameHistoryDAO {
_dbAccess = dbAccess;
}
public void addGameHistory(String winner, String loser, String winReason, String loseReason, String winRecordingId, String loseRecordingId, String formatName, String winnerDeckName, String loserDeckName, Date startDate, Date endDate) {
public void addGameHistory(String winner, String loser, String winReason, String loseReason, String winRecordingId, String loseRecordingId, String formatName, String tournament, String winnerDeckName, String loserDeckName, Date startDate, Date endDate) {
try {
Connection connection = _dbAccess.getDataSource().getConnection();
try {
PreparedStatement statement = connection.prepareStatement("insert into game_history (winner, loser, win_reason, lose_reason, win_recording_id, lose_recording_id, format_name, winner_deck_name, loser_deck_name, start_date, end_date) values (?,?,?,?,?,?,?,?,?,?,?)");
PreparedStatement statement = connection.prepareStatement("insert into game_history (winner, loser, win_reason, lose_reason, win_recording_id, lose_recording_id, format_name, tournament, winner_deck_name, loser_deck_name, start_date, end_date) values (?,?,?,?,?,?,?,?,?,?,?,?)");
try {
statement.setString(1, winner);
statement.setString(2, loser);
@@ -31,10 +31,11 @@ public class GameHistoryDAO {
statement.setString(5, winRecordingId);
statement.setString(6, loseRecordingId);
statement.setString(7, formatName);
statement.setString(8, winnerDeckName);
statement.setString(9, loserDeckName);
statement.setLong(10, startDate.getTime());
statement.setLong(11, endDate.getTime());
statement.setString(8, tournament);
statement.setString(9, winnerDeckName);
statement.setString(10, loserDeckName);
statement.setLong(11, startDate.getTime());
statement.setLong(12, endDate.getTime());
statement.execute();
} finally {
@@ -52,7 +53,7 @@ public class GameHistoryDAO {
try {
Connection connection = _dbAccess.getDataSource().getConnection();
try {
PreparedStatement statement = connection.prepareStatement("select winner, loser, win_reason, lose_reason, win_recording_id, lose_recording_id, format_name, winner_deck_name, loser_deck_name, start_date, end_date from game_history where winner=? or loser=? order by end_date desc limit ?, ?");
PreparedStatement statement = connection.prepareStatement("select winner, loser, win_reason, lose_reason, win_recording_id, lose_recording_id, format_name, tournament, winner_deck_name, loser_deck_name, start_date, end_date from game_history where winner=? or loser=? order by end_date desc limit ?, ?");
try {
statement.setString(1, player.getName());
statement.setString(2, player.getName());
@@ -69,12 +70,13 @@ public class GameHistoryDAO {
String winRecordingId = rs.getString(5);
String loseRecordingId = rs.getString(6);
String formatName = rs.getString(7);
String winnerDeckName = rs.getString(8);
String loserDeckName = rs.getString(9);
Date startDate = new Date(rs.getLong(10));
Date endDate = new Date(rs.getLong(11));
String tournament = rs.getString(8);
String winnerDeckName = rs.getString(9);
String loserDeckName = rs.getString(10);
Date startDate = new Date(rs.getLong(11));
Date endDate = new Date(rs.getLong(12));
GameHistoryEntry entry = new GameHistoryEntry(winner, winReason, winRecordingId, loser, loseReason, loseRecordingId, formatName, winnerDeckName, loserDeckName, startDate, endDate);
GameHistoryEntry entry = new GameHistoryEntry(winner, winReason, winRecordingId, loser, loseReason, loseRecordingId, formatName, tournament, winnerDeckName, loserDeckName, startDate, endDate);
result.add(entry);
}
return result;

View File

@@ -13,13 +13,14 @@ public class GameHistoryEntry {
private String _loserRecording;
private String _formatName;
private String _tournament;
private String _winnerDeckName;
private String _loserDeckName;
private Date _startTime;
private Date _endTime;
public GameHistoryEntry(String winner, String winReason, String winnerRecording, String loser, String loseReason, String loserRecording, String formatName, String winnerDeckName, String loserDeckName, Date startTime, Date endTime) {
public GameHistoryEntry(String winner, String winReason, String winnerRecording, String loser, String loseReason, String loserRecording, String formatName, String tournament, String winnerDeckName, String loserDeckName, Date startTime, Date endTime) {
_winner = winner;
_winReason = winReason;
_winnerRecording = winnerRecording;
@@ -27,6 +28,7 @@ public class GameHistoryEntry {
_loseReason = loseReason;
_loserRecording = loserRecording;
_formatName = formatName;
_tournament = tournament;
_winnerDeckName = winnerDeckName;
_loserDeckName = loserDeckName;
_startTime = startTime;
@@ -61,6 +63,10 @@ public class GameHistoryEntry {
return _formatName;
}
public String getTournament() {
return _tournament;
}
public String getWinnerDeckName() {
return _winnerDeckName;
}

View File

@@ -23,8 +23,8 @@ public class GameHistoryService {
_gameHistoryDAO = gameHistoryDAO;
}
public void addGameHistory(String winner, String loser, String winReason, String loseReason, String winRecordingId, String loseRecordingId, String formatName, String winnerDeckName, String loserDeckName, Date startDate, Date endDate) {
_gameHistoryDAO.addGameHistory(winner, loser, winReason, loseReason, winRecordingId, loseRecordingId, formatName, winnerDeckName, loserDeckName, startDate, endDate);
public void addGameHistory(String winner, String loser, String winReason, String loseReason, String winRecordingId, String loseRecordingId, String formatName, String tournament, String winnerDeckName, String loserDeckName, Date startDate, Date endDate) {
_gameHistoryDAO.addGameHistory(winner, loser, winReason, loseReason, winRecordingId, loseRecordingId, formatName, tournament, winnerDeckName, loserDeckName, startDate, endDate);
Integer winnerCount = _playerGameCount.get(winner);
Integer loserCount = _playerGameCount.get(loser);
if (winnerCount != null)

View File

@@ -48,7 +48,7 @@ public class GameRecorder {
return new InflaterInputStream(new FileInputStream(file));
}
public GameRecordingInProgress recordGame(LotroGameMediator lotroGame, final String formatName, final Map<String, String> deckNames) {
public GameRecordingInProgress recordGame(LotroGameMediator lotroGame, final String formatName, final String tournament, final Map<String, String> deckNames) {
final Date startData = new Date();
final Map<String, GatheringParticipantCommunicationChannel> recordingChannels = new HashMap<String, GatheringParticipantCommunicationChannel>();
for (String playerId : lotroGame.getPlayersPlaying()) {
@@ -61,7 +61,7 @@ public class GameRecorder {
@Override
public void finishRecording(String winner, String winReason, String loser, String loseReason) {
Map<String, String> playerRecordingId = saveRecordedChannels(recordingChannels);
_gameHistoryService.addGameHistory(winner, loser, winReason, loseReason, playerRecordingId.get(winner), playerRecordingId.get(loser), formatName, deckNames.get(winner), deckNames.get(loser), startData, new Date());
_gameHistoryService.addGameHistory(winner, loser, winReason, loseReason, playerRecordingId.get(winner), playerRecordingId.get(loser), formatName, tournament, deckNames.get(winner), deckNames.get(loser), startData, new Date());
}
};
}

View File

@@ -125,7 +125,7 @@ public class LotroServer extends AbstractServer {
return "Game" + gameId;
}
public synchronized String createNewGame(LotroFormat lotroFormat, LotroGameParticipant[] participants, boolean competetive) {
public synchronized String createNewGame(LotroFormat lotroFormat, String tournament, LotroGameParticipant[] participants, boolean competetive) {
if (participants.length < 2)
throw new IllegalArgumentException("There has to be at least two players");
final String gameId = String.valueOf(_nextGameId);
@@ -165,7 +165,7 @@ public class LotroServer extends AbstractServer {
lotroGameMediator.sendMessageToPlayers("Players in the game are: " + players.toString());
final GameRecorder.GameRecordingInProgress gameRecordingInProgress = _gameRecorder.recordGame(lotroGameMediator, lotroFormat.getName(), deckNames);
final GameRecorder.GameRecordingInProgress gameRecordingInProgress = _gameRecorder.recordGame(lotroGameMediator, lotroFormat.getName(), tournament, deckNames);
lotroGameMediator.addGameResultListener(
new GameResultListener() {
@Override

View File

@@ -299,7 +299,7 @@ public class HallServer extends AbstractServer {
LotroGameParticipant[] participants = players.toArray(new LotroGameParticipant[players.size()]);
final League league = awaitingTable.getLeague();
final LeagueSerieData leagueSerie = awaitingTable.getLeagueSerie();
String gameId = _lotroServer.createNewGame(awaitingTable.getLotroFormat(), participants, league != null);
String gameId = _lotroServer.createNewGame(awaitingTable.getLotroFormat(), getTournamentName(awaitingTable), participants, league != null);
LotroGameMediator lotroGameMediator = _lotroServer.getGameById(gameId);
if (league != null) {
lotroGameMediator.addGameResultListener(

View File

@@ -165,6 +165,9 @@ public class ServerResource extends AbstractResource {
historyEntry.setAttribute("loseReason", gameHistoryEntry.getLoseReason());
historyEntry.setAttribute("formatName", gameHistoryEntry.getFormatName());
String tournament = gameHistoryEntry.getTournament();
if (tournament != null)
historyEntry.setAttribute("tournament", tournament);
if (gameHistoryEntry.getWinner().equals(resourceOwner.getName()) && gameHistoryEntry.getWinnerRecording() != null) {
historyEntry.setAttribute("gameRecordingId", gameHistoryEntry.getWinnerRecording());
@@ -196,8 +199,8 @@ public class ServerResource extends AbstractResource {
} else {
sb.append("You are not logged in, log in below or <button id='clickToRegister'>register</button>.");
sb.append("<div class='status'>Tables count: ").append(_hallServer.getTablesCount()).append(", players in hall: ").append(_chatServer.getChatRoom("Game Hall").getUsersInRoom().size())
.append(", games played in last 24 hours: unknown").append(_gameHistoryService.getGamesPlayedCountInLastMs(1000 * 60 * 60 * 24))
.append(",<br/> active players in last week: unknown").append(_gameHistoryService.getActivePlayersInLastMs(1000 * 60 * 60 * 24 * 7))
.append(", games played in last 24 hours: ").append(_gameHistoryService.getGamesPlayedCountInLastMs(1000 * 60 * 60 * 24))
.append(",<br/> active players in last week: ").append(_gameHistoryService.getActivePlayersInLastMs(1000 * 60 * 60 * 24 * 7))
.append("</div>");
sb.append(getLoginHTML());
}

View File

@@ -145,10 +145,10 @@ var GempLotrDeckBuildingUI = Class.extend({
if (confirm("Do you wish to save this deck?"))
that.saveDeck(false);
}, {
"404": function() {
alert("Couldn't find the deck to rename on the server.");
}
});
"404": function() {
alert("Couldn't find the deck to rename on the server.");
}
});
}
});
@@ -244,11 +244,11 @@ var GempLotrDeckBuildingUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
var swipeOptions = {
threshold: 20,
@@ -296,14 +296,14 @@ var GempLotrDeckBuildingUI = Class.extend({
if (that.deckListDialog == null) {
that.deckListDialog = $("<div></div>")
.dialog({
title: "Your stored decks",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 400,
modal: true
});
title: "Your stored decks",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 400,
modal: true
});
}
that.deckListDialog.html("");
@@ -370,6 +370,9 @@ var GempLotrDeckBuildingUI = Class.extend({
var that = this;
var tar = $(event.target);
if (tar.length == 1 && tar[0].tagName == "A")
return true;
if (!this.successfulDrag && this.infoDialog.dialog("isOpen")) {
this.infoDialog.dialog("close");
event.stopPropagation();
@@ -418,14 +421,14 @@ var GempLotrDeckBuildingUI = Class.extend({
if (this.selectionDialog == null) {
this.selectionDialog = $("<div></div>")
.dialog({
title: "Choose one",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 200,
modal: true
});
title: "Choose one",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 200,
modal: true
});
this.selectionGroup = new NormalCardGroup(this.selectionDialog, function(card) {
return true;
@@ -510,10 +513,10 @@ var GempLotrDeckBuildingUI = Class.extend({
if (card.horizontal) {
// 500x360
this.infoDialog.dialog({width: Math.min(500 + horSpace, windowWidth), height: Math.min(360 + vertSpace, windowHeight)});
this.infoDialog.dialog({width: Math.min(500 + horSpace, windowWidth), height: Math.min(380 + vertSpace, windowHeight)});
} else {
// 360x500
this.infoDialog.dialog({width: Math.min(360 + horSpace, windowWidth), height: Math.min(500 + vertSpace, windowHeight)});
this.infoDialog.dialog({width: Math.min(360 + horSpace, windowWidth), height: Math.min(520 + vertSpace, windowHeight)});
}
this.infoDialog.dialog("open");
},
@@ -664,10 +667,10 @@ var GempLotrDeckBuildingUI = Class.extend({
that.checkDeckStatsDirty();
}, that.checkDirtyInterval);
}, {
"400": function() {
alert("Invalid deck for getting stats.");
}
});
"400": function() {
alert("Invalid deck for getting stats.");
}
});
} else {
$("#deckStats").html("Deck has no Ring, Ring-bearer or all 9 sites");
setTimeout(

View File

@@ -23,12 +23,13 @@ var GameHistoryUI = Class.extend({
var root = xml.documentElement;
if (root.tagName == 'gameHistory') {
var historyTable = $("<table class='gameHistory'></table>");
historyTable.append("<tr><th>Format</th><th>Deck</th><th>Winner</th><th>Loser</th><th>Win reason</th><th>Lose reason</th><th>Finished on</th><th>Replay link</th></tr>");
historyTable.append("<tr><th>Format</th><th>Tournament</th><th>Deck</th><th>Winner</th><th>Loser</th><th>Win reason</th><th>Lose reason</th><th>Finished on</th><th>Replay link</th></tr>");
var entries = root.getElementsByTagName("historyEntry");
for (var i = 0; i < entries.length; i++) {
var historyEntry = entries[i];
var format = historyEntry.getAttribute("formatName");
var tournament = historyEntry.getAttribute("tournament");
var deck = historyEntry.getAttribute("deckName");
var winner = historyEntry.getAttribute("winner");
var loser = historyEntry.getAttribute("loser");
@@ -42,6 +43,10 @@ var GameHistoryUI = Class.extend({
row.append($("<td></td>").html(format));
else
row.append($("<td></td>").html("&nbsp;"));
if (tournament != null)
row.append($("<td></td>").html(tournament));
else
row.append($("<td></td>").html("&nbsp;"));
if (deck != null)
row.append($("<td></td>").html(deck));
else

View File

@@ -234,7 +234,9 @@ var Card = Class.extend({
getWikiLink: function() {
var imageUrl = this.getUrlByBlueprintId(this.blueprintId, true);
return imageUrl.substr(0, imageUrl.length - 3) + "html";
var afterLastSlash = imageUrl.lastIndexOf("/") + 1;
var countAfterLastSlash = imageUrl.length - 3 - afterLastSlash;
return "http://lotrtcgdb.com/pages/" + imageUrl.substr(afterLastSlash, countAfterLastSlash) + "html";
},
formatSetNo: function(setNo) {

View File

@@ -9,12 +9,12 @@ var LeagueResultsUI = Class.extend({
this.questionDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "League operation"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "League operation"
});
this.loadResults();
},
@@ -84,19 +84,19 @@ var LeagueResultsUI = Class.extend({
tabDiv.append(tabNavigation);
// Overall tab
var tabContent = $("<div id='league" + i + "overall'></div>");
var tabContent = $("<div id='leagueoverall'></div>");
var standings = league.getElementsByTagName("leagueStanding");
if (standings.length > 0)
tabContent.append(this.createStandingsTable(standings));
tabDiv.append(tabContent);
tabNavigation.append("<li><a href='#league" + i + "overall'>Overall results</a></li>");
tabNavigation.append("<li><a href='#leagueoverall'>Overall results</a></li>");
var series = league.getElementsByTagName("serie");
for (var j = 0; j < series.length; j++) {
var tabContent = $("<div id='league" + i + "serie" + j + "'></div>");
var tabContent = $("<div id='leagueserie" + j + "'></div>");
var serie = series[j];
var serieName = serie.getAttribute("type");
@@ -120,7 +120,7 @@ var LeagueResultsUI = Class.extend({
tabContent.append(this.createStandingsTable(standings));
tabDiv.append(tabContent);
tabNavigation.append("<li><a href='#league" + i + "serie" + j + "'>Serie " + (j + 1) + "</a></li>");
tabNavigation.append("<li><a href='#leagueserie" + j + "'>Serie " + (j + 1) + "</a></li>");
}
tabDiv.tabs();
@@ -162,6 +162,7 @@ var LeagueResultsUI = Class.extend({
$("#leagueResults").append(detailsBut);
}
$("#leagueResults").append("<hr />");
$("#leagueResults").append("<div id='leagueExtraInfo'></div>");
}
},

View File

@@ -70,20 +70,20 @@ var GempLotrMerchantUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
this.questionDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "Merchant operation"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "Merchant operation"
});
var swipeOptions = {
threshold: 20,
@@ -155,6 +155,9 @@ var GempLotrMerchantUI = Class.extend({
var that = this;
var tar = $(event.target);
if (tar.length == 1 && tar[0].tagName == "A")
return true;
if (!this.successfulDrag && this.infoDialog.dialog("isOpen")) {
this.infoDialog.dialog("close");
event.stopPropagation();
@@ -193,10 +196,10 @@ var GempLotrMerchantUI = Class.extend({
if (card.horizontal) {
// 500x360
this.infoDialog.dialog({width: Math.min(500 + horSpace, windowWidth), height: Math.min(360 + vertSpace, windowHeight)});
this.infoDialog.dialog({width: Math.min(500 + horSpace, windowWidth), height: Math.min(380 + vertSpace, windowHeight)});
} else {
// 360x500
this.infoDialog.dialog({width: Math.min(360 + horSpace, windowWidth), height: Math.min(500 + vertSpace, windowHeight)});
this.infoDialog.dialog({width: Math.min(360 + horSpace, windowWidth), height: Math.min(520 + vertSpace, windowHeight)});
}
this.infoDialog.dialog("open");
},
@@ -322,10 +325,10 @@ var GempLotrMerchantUI = Class.extend({
if (card.horizontal) {
// 500x360
this.questionDialog.dialog({width: Math.min(500 + horSpace, windowWidth), height: Math.min(360 + vertSpace, windowHeight)});
this.questionDialog.dialog({width: Math.min(500 + horSpace, windowWidth), height: Math.min(380 + vertSpace, windowHeight)});
} else {
// 360x500
this.questionDialog.dialog({width: Math.min(360 + horSpace, windowWidth), height: Math.min(500 + vertSpace, windowHeight)});
this.questionDialog.dialog({width: Math.min(360 + horSpace, windowWidth), height: Math.min(520 + vertSpace, windowHeight)});
}
this.questionDialog.dialog("open");
},