Adding format name and deck name to game history.
This commit is contained in:
@@ -18,11 +18,11 @@ public class GameHistoryDAO {
|
||||
_dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public void addGameHistory(String winner, String loser, String winReason, String loseReason, String winRecordingId, String loseRecordingId, Date startDate, Date endDate) {
|
||||
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) {
|
||||
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, 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, winner_deck_name, loser_deck_name, start_date, end_date) values (?,?,?,?,?,?,?,?)");
|
||||
try {
|
||||
statement.setString(1, winner);
|
||||
statement.setString(2, loser);
|
||||
@@ -30,8 +30,11 @@ public class GameHistoryDAO {
|
||||
statement.setString(4, loseReason);
|
||||
statement.setString(5, winRecordingId);
|
||||
statement.setString(6, loseRecordingId);
|
||||
statement.setLong(7, startDate.getTime());
|
||||
statement.setLong(8, endDate.getTime());
|
||||
statement.setString(7, formatName);
|
||||
statement.setString(8, winnerDeckName);
|
||||
statement.setString(9, loserDeckName);
|
||||
statement.setLong(10, startDate.getTime());
|
||||
statement.setLong(11, endDate.getTime());
|
||||
|
||||
statement.execute();
|
||||
} finally {
|
||||
@@ -49,7 +52,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, 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, 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());
|
||||
@@ -65,10 +68,13 @@ public class GameHistoryDAO {
|
||||
String loseReason = rs.getString(4);
|
||||
String winRecordingId = rs.getString(5);
|
||||
String loseRecordingId = rs.getString(6);
|
||||
Date startDate = new Date(rs.getLong(7));
|
||||
Date endDate = new Date(rs.getLong(8));
|
||||
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));
|
||||
|
||||
GameHistoryEntry entry = new GameHistoryEntry(winner, winReason, winRecordingId, loser, loseReason, loseRecordingId, startDate, endDate);
|
||||
GameHistoryEntry entry = new GameHistoryEntry(winner, winReason, winRecordingId, loser, loseReason, loseRecordingId, formatName, winnerDeckName, loserDeckName, startDate, endDate);
|
||||
result.add(entry);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -12,16 +12,23 @@ public class GameHistoryEntry {
|
||||
private String _winnerRecording;
|
||||
private String _loserRecording;
|
||||
|
||||
private String _formatName;
|
||||
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, Date startTime, 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) {
|
||||
_winner = winner;
|
||||
_winReason = winReason;
|
||||
_winnerRecording = winnerRecording;
|
||||
_loser = loser;
|
||||
_loseReason = loseReason;
|
||||
_loserRecording = loserRecording;
|
||||
_formatName = formatName;
|
||||
_winnerDeckName = winnerDeckName;
|
||||
_loserDeckName = loserDeckName;
|
||||
_startTime = startTime;
|
||||
_endTime = endTime;
|
||||
}
|
||||
@@ -50,6 +57,18 @@ public class GameHistoryEntry {
|
||||
return _winReason;
|
||||
}
|
||||
|
||||
public String getFormatName() {
|
||||
return _formatName;
|
||||
}
|
||||
|
||||
public String getWinnerDeckName() {
|
||||
return _winnerDeckName;
|
||||
}
|
||||
|
||||
public String getLoserDeckName() {
|
||||
return _loserDeckName;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GameRecorder {
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
|
||||
public GameRecordingInProgress recordGame(LotroGameMediator lotroGame) {
|
||||
public GameRecordingInProgress recordGame(LotroGameMediator lotroGame, final String formatName, 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);
|
||||
_gameHistoryDao.addGameHistory(winner, loser, winReason, loseReason, playerRecordingId.get(winner), playerRecordingId.get(loser), startData, new Date());
|
||||
_gameHistoryDao.addGameHistory(winner, loser, winReason, loseReason, playerRecordingId.get(winner), playerRecordingId.get(loser), formatName, deckNames.get(winner), deckNames.get(loser), startData, new Date());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
|
||||
public class LotroGameParticipant {
|
||||
private String _playerId;
|
||||
private String _deckName;
|
||||
private LotroDeck _deck;
|
||||
|
||||
public LotroGameParticipant(String playerId, LotroDeck deck) {
|
||||
public LotroGameParticipant(String playerId, String deckName, LotroDeck deck) {
|
||||
_playerId = playerId;
|
||||
_deckName = deckName;
|
||||
_deck = deck;
|
||||
}
|
||||
|
||||
@@ -18,4 +20,8 @@ public class LotroGameParticipant {
|
||||
public LotroDeck getDeck() {
|
||||
return _deck;
|
||||
}
|
||||
|
||||
public String getDeckName() {
|
||||
return _deckName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,11 @@ public class LotroServer extends AbstractServer {
|
||||
}
|
||||
});
|
||||
if (!_test) {
|
||||
final GameRecorder.GameRecordingInProgress gameRecordingInProgress = _gameRecorder.recordGame(lotroGameMediator);
|
||||
Map<String, String> deckNames = new HashMap<String, String>();
|
||||
for (LotroGameParticipant participant : participants)
|
||||
deckNames.put(participant.getPlayerId(), participant.getDeckName());
|
||||
|
||||
final GameRecorder.GameRecordingInProgress gameRecordingInProgress = _gameRecorder.recordGame(lotroGameMediator, formatName, deckNames);
|
||||
lotroGameMediator.addGameResultListener(
|
||||
new GameResultListener() {
|
||||
@Override
|
||||
|
||||
@@ -89,7 +89,7 @@ public class HallServer extends AbstractServer {
|
||||
AwaitingTable table = new AwaitingTable(type, _supportedFormatNames.get(type), supportedFormat);
|
||||
_awaitingTables.put(tableId, table);
|
||||
|
||||
joinTableInternal(tableId, playerId, table, lotroDeck);
|
||||
joinTableInternal(tableId, playerId, table, deckName, lotroDeck);
|
||||
}
|
||||
|
||||
private LotroDeck validateUserAndDeck(String type, LotroFormat format, String playerId, String deckName) throws HallException {
|
||||
@@ -124,13 +124,13 @@ public class HallServer extends AbstractServer {
|
||||
|
||||
LotroDeck lotroDeck = validateUserAndDeck(awaitingTable.getFormatType(), awaitingTable.getLotroFormat(), playerId, deckName);
|
||||
|
||||
joinTableInternal(tableId, playerId, awaitingTable, lotroDeck);
|
||||
joinTableInternal(tableId, playerId, awaitingTable, deckName, lotroDeck);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void joinTableInternal(String tableId, String playerId, AwaitingTable awaitingTable, LotroDeck lotroDeck) {
|
||||
boolean tableFull = awaitingTable.addPlayer(new LotroGameParticipant(playerId, lotroDeck));
|
||||
private void joinTableInternal(String tableId, String playerId, AwaitingTable awaitingTable, String deckName, LotroDeck lotroDeck) {
|
||||
boolean tableFull = awaitingTable.addPlayer(new LotroGameParticipant(playerId, deckName, lotroDeck));
|
||||
if (tableFull)
|
||||
createGame(tableId, awaitingTable);
|
||||
}
|
||||
|
||||
@@ -202,10 +202,15 @@ public class ServerResource {
|
||||
historyEntry.setAttribute("winReason", gameHistoryEntry.getWinReason());
|
||||
historyEntry.setAttribute("loseReason", gameHistoryEntry.getLoseReason());
|
||||
|
||||
if (gameHistoryEntry.getWinner().equals(participantId) && gameHistoryEntry.getWinnerRecording() != null)
|
||||
historyEntry.setAttribute("formatName", gameHistoryEntry.getFormatName());
|
||||
|
||||
if (gameHistoryEntry.getWinner().equals(participantId) && gameHistoryEntry.getWinnerRecording() != null) {
|
||||
historyEntry.setAttribute("gameRecordingId", gameHistoryEntry.getWinnerRecording());
|
||||
else if (gameHistoryEntry.getLoser().equals(participantId) && gameHistoryEntry.getLoserRecording() != null)
|
||||
historyEntry.setAttribute("deckName", gameHistoryEntry.getWinnerDeckName());
|
||||
} else if (gameHistoryEntry.getLoser().equals(participantId) && gameHistoryEntry.getLoserRecording() != null) {
|
||||
historyEntry.setAttribute("gameRecordingId", gameHistoryEntry.getLoserRecording());
|
||||
historyEntry.setAttribute("deckName", gameHistoryEntry.getLoserDeckName());
|
||||
}
|
||||
|
||||
historyEntry.setAttribute("startTime", String.valueOf(gameHistoryEntry.getStartTime().getTime()));
|
||||
historyEntry.setAttribute("endTime", String.valueOf(gameHistoryEntry.getEndTime().getTime()));
|
||||
|
||||
@@ -120,8 +120,7 @@
|
||||
$(document).ready(
|
||||
function() {
|
||||
$("#latestNews").append("<b>Sets 01-10 are available to play.</b> "
|
||||
+ "If you find any problems with specific card or rules in general, please report it to me directly or "
|
||||
+ "on the TLHH forums.");
|
||||
+ "If you find any problems with specific card or rules in general, please report it <a href='http://lotrtcgdb.com/forums/index.php/topic,7592.0.html'>at the TLHH forums</a>.");
|
||||
|
||||
var chat = new ChatBoxUI("Game Hall", $("#chat"), "/gemp-lotr/server", true);
|
||||
chat.setBounds(2, 2, 780 - 4, 200 - 4);
|
||||
|
||||
@@ -23,11 +23,13 @@ var GameHistoryUI = Class.extend({
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == 'gameHistory') {
|
||||
var historyTable = $("<table class='gameHistory'></table>");
|
||||
historyTable.append("<tr><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>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 deck = historyEntry.getAttribute("deckName");
|
||||
var winner = historyEntry.getAttribute("winner");
|
||||
var loser = historyEntry.getAttribute("loser");
|
||||
var winReason = historyEntry.getAttribute("winReason");
|
||||
@@ -36,6 +38,15 @@ var GameHistoryUI = Class.extend({
|
||||
var gameRecordingId = historyEntry.getAttribute("gameRecordingId");
|
||||
|
||||
var row = $("<tr></tr>");
|
||||
if (format != null)
|
||||
row.append($("<td></td>").html(format));
|
||||
else
|
||||
row.append($("<td></td>").html(" "));
|
||||
if (deck != null)
|
||||
row.append($("<td></td>").html(deck));
|
||||
else
|
||||
row.append($("<td></td>").html(" "));
|
||||
row.append($("<td></td>").html(winner));
|
||||
row.append($("<td></td>").html(winner));
|
||||
row.append($("<td></td>").html(loser));
|
||||
row.append($("<td></td>").html(winReason));
|
||||
|
||||
Reference in New Issue
Block a user