mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
added startMatch and joinGame
This commit is contained in:
parent
19ad01ced8
commit
58e85df735
17 changed files with 220 additions and 46 deletions
|
|
@ -96,6 +96,7 @@ import java.util.prefs.Preferences;
|
|||
import static mage.client.dialog.PreferencesDialog.KEY_CONNECT_FLAG;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.interfaces.ServerState;
|
||||
import mage.view.ChatMessage;
|
||||
|
|
@ -1477,6 +1478,21 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
showTableWaitingDialog(roomId, tableId, chatId, owner, tournament);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gameStarted(UUID gameId, UUID playerId) {
|
||||
// try {
|
||||
GameManager.getInstance().setCurrentPlayerUUID(playerId);
|
||||
showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
|
||||
if (Plugins.getInstance().isCounterPluginLoaded()) {
|
||||
Plugins.getInstance().addGamesPlayed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
||||
|
|
|
|||
|
|
@ -382,10 +382,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.pnlReplay.setVisible(false);
|
||||
|
||||
this.gameChatPanel.clear();
|
||||
this.gameChatPanel.connect(client.getGameChatId(gameId));
|
||||
if (!client.joinGame(gameId)) {
|
||||
UUID chatId = client.joinGame(gameId);
|
||||
if (chatId == null) {
|
||||
removeGame();
|
||||
} else {
|
||||
} else {
|
||||
this.gameChatPanel.connect(chatId);
|
||||
// play start sound
|
||||
AudioManager.playYourGameStarted();
|
||||
}
|
||||
|
|
@ -415,10 +416,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
this.pnlReplay.setVisible(false);
|
||||
this.gameChatPanel.clear();
|
||||
this.gameChatPanel.connect(client.getGameChatId(gameId));
|
||||
if (!client.watchGame(gameId)) {
|
||||
UUID chatId = client.watchGame(gameId);
|
||||
if (chatId == null) {
|
||||
removeGame();
|
||||
}
|
||||
else {
|
||||
this.gameChatPanel.connect(chatId);
|
||||
}
|
||||
for (PlayAreaPanel panel : getPlayers().values()) {
|
||||
panel.setPlayingMode(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,10 +91,10 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
switch (callback.getMethod()) {
|
||||
case "startGame":
|
||||
{
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
|
||||
gameStarted(message.getGameId(), message.getPlayerId());
|
||||
break;
|
||||
// TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
// GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
|
||||
// gameStarted(message.getGameId(), message.getPlayerId());
|
||||
// break;
|
||||
}
|
||||
case "startTournament":
|
||||
{
|
||||
|
|
@ -433,18 +433,18 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// }
|
||||
// }
|
||||
|
||||
protected void gameStarted(final UUID gameId, final UUID playerId) {
|
||||
try {
|
||||
frame.showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
||||
if (Plugins.getInstance().isCounterPluginLoaded()) {
|
||||
Plugins.getInstance().addGamesPlayed();
|
||||
}
|
||||
}
|
||||
// protected void gameStarted(final UUID gameId, final UUID playerId) {
|
||||
// try {
|
||||
// frame.showGame(gameId, playerId);
|
||||
// logger.info("Game " + gameId + " started for player " + playerId);
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
//
|
||||
// if (Plugins.getInstance().isCounterPluginLoaded()) {
|
||||
// Plugins.getInstance().addGamesPlayed();
|
||||
// }
|
||||
// }
|
||||
|
||||
protected void draftStarted(UUID draftId, UUID playerId) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -128,6 +128,11 @@ public class MultiConnectTest {
|
|||
public void joinedTable(UUID roomId, UUID tableId, UUID chatId, boolean owner, boolean tournament) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gameStarted(UUID gameId, UUID playerId) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue