fixed replay + some other fixes

This commit is contained in:
BetaSteward 2011-03-18 18:27:01 -04:00
parent ff3e0108cd
commit 35f0767f1b
24 changed files with 218 additions and 187 deletions

View file

@ -69,7 +69,7 @@ public class ChatPanel extends javax.swing.JPanel {
}
public void disconnect() {
if (session.isConnected())
if (session != null && session.isConnected())
session.leaveChat(chatId);
}

View file

@ -201,7 +201,7 @@ public class GamePanel extends javax.swing.JPanel {
this.pnlReplay.setVisible(true);
this.setVisible(true);
this.chatPanel.clear();
if (!session.replayGame(gameId))
if (!session.startReplay(gameId))
hideGame();
}
@ -734,16 +734,16 @@ public class GamePanel extends javax.swing.JPanel {
private void btnStopReplayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopReplayActionPerformed
if (modalQuestion("Are you sure you want to stop replay?", "Stop replay") == JOptionPane.YES_OPTION) {
session.stopReplay();
session.stopReplay(gameId);
}
}//GEN-LAST:event_btnStopReplayActionPerformed
private void btnNextPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextPlayActionPerformed
session.nextPlay();
session.nextPlay(gameId);
}//GEN-LAST:event_btnNextPlayActionPerformed
private void btnPreviousPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPreviousPlayActionPerformed
session.previousPlay();
session.previousPlay(gameId);
}//GEN-LAST:event_btnPreviousPlayActionPerformed
private class HandContainer extends JPanel {

View file

@ -262,18 +262,6 @@ public class Session {
return false;
}
public boolean replayTable(UUID roomId, UUID tableId) {
try {
server.replayTable(sessionId, roomId, tableId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, DeckCardLists deckList) {
try {
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, deckList);
@ -622,9 +610,9 @@ public class Session {
return false;
}
public boolean stopReplay() {
public boolean startReplay(UUID gameId) {
try {
server.stopReplay(sessionId);
server.startReplay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
@ -634,9 +622,9 @@ public class Session {
return false;
}
public boolean nextPlay() {
public boolean stopReplay(UUID gameId) {
try {
server.nextPlay(sessionId);
server.stopReplay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
@ -646,9 +634,21 @@ public class Session {
return false;
}
public boolean previousPlay() {
public boolean nextPlay(UUID gameId) {
try {
server.previousPlay(sessionId);
server.nextPlay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean previousPlay(UUID gameId) {
try {
server.previousPlay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);

View file

@ -94,6 +94,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
{
int modelRow = Integer.valueOf( e.getActionCommand() );
UUID tableId = UUID.fromString((String)tableModel.getValueAt(modelRow, 0));
UUID gameId = (UUID)tableModel.getValueAt(modelRow, 6);
String state = (String)tableModel.getValueAt(modelRow, 4);
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 5);
@ -114,8 +115,8 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
if (!session.watchTable(roomId, tableId))
hideTables();
} else if (state.equals("Replay")) {
logger.info("Replaying table " + tableId);
if (!session.replayTable(roomId, tableId))
logger.info("Replaying game " + gameId);
if (!session.replayGame(gameId))
hideTables();
}
}
@ -346,7 +347,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
}
class TableTableModel extends AbstractTableModel {
private String[] columnNames = new String[]{"Game Id", "Game Type", "Deck Type", "Status", "Action"};
private String[] columnNames = new String[]{"Table Id", "Game Type", "Deck Type", "Status", "Action"};
private TableView[] tables = new TableView[0];
@ -389,6 +390,10 @@ class TableTableModel extends AbstractTableModel {
}
case 5:
return tables[arg0].isTournament();
case 6:
if (!tables[arg0].getGames().isEmpty())
return tables[arg0].getGames().get(0);
return null;
}
return "";
}

View file

@ -84,12 +84,12 @@ public class TournamentPanel extends javax.swing.JPanel implements Observer {
public void actionPerformed(ActionEvent e)
{
int modelRow = Integer.valueOf( e.getActionCommand() );
UUID tableId = UUID.fromString((String)tableMatches.getValueAt(modelRow, 3));
UUID gameId = UUID.fromString((String)tableMatches.getValueAt(modelRow, 3));
String state = (String)tableMatches.getValueAt(modelRow, 4);
if (state.equals("Finished")) {
logger.info("Replaying table " + tableId);
session.replayTable(null, tableId);
logger.info("Replaying game " + gameId);
session.replayGame(gameId);
}
}
};