initial commit - only table pane chat is working atm

This commit is contained in:
betasteward 2015-05-23 10:18:36 -04:00
parent f9bad74ca7
commit e45345d87a
84 changed files with 5370 additions and 3992 deletions

View file

@ -1,126 +1,126 @@
package org.mage.test.load;
import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback;
import mage.remote.Session;
import mage.utils.CompressUtil;
import mage.view.GameClientMessage;
import mage.view.GameView;
import mage.view.SimpleCardView;
import mage.view.TableClientMessage;
import org.apache.log4j.Logger;
import java.util.UUID;
/**
* @author noxx
*/
public class LoadCallbackClient implements CallbackClient {
private static final transient Logger log = Logger.getLogger(LoadCallbackClient.class);
private Session session;
private UUID gameId;
private UUID playerId;
private boolean gameOver;
private volatile int controlCount;
private GameView gameView;
@Override
public void processCallback(ClientCallback callback) {
//TODO
controlCount = 0;
log.info(callback.getMethod());
callback.setData(CompressUtil.decompress(callback.getData()));
switch (callback.getMethod()) {
case "startGame":
{
TableClientMessage message = (TableClientMessage) callback.getData();
gameId = message.getGameId();
playerId = message.getPlayerId();
session.joinGame(message.getGameId());
startControlThread();
break;
}
case "gameInform":
{
GameClientMessage message = (GameClientMessage) callback.getData();
log.info("Inform: " + message.getMessage());
gameView = message.getGameView();
break;
}
case "gameInit":
break;
case "gameTarget":
{
GameClientMessage message = (GameClientMessage) callback.getData();
log.info("Target: " + message.getMessage());
switch (message.getMessage()) {
case "Select a starting player":
session.sendPlayerUUID(gameId, playerId);
break;
case "Select a card to discard":
log.info("hand size: " + gameView.getHand().size());
SimpleCardView card = gameView.getHand().values().iterator().next();
session.sendPlayerUUID(gameId, card.getId());
break;
}
break;
}
case "gameAsk":
{
GameClientMessage message = (GameClientMessage) callback.getData();
log.info("Ask: " + message.getMessage());
if (message.getMessage().equals("Do you want to take a mulligan?")) {
session.sendPlayerBoolean(gameId, false);
} break;
}
case "gameSelect":
{
GameClientMessage message = (GameClientMessage) callback.getData();
log.info("Select: " + message.getMessage());
if (LoadPhaseManager.getInstance().isSkip(message.getGameView(), message.getMessage(), playerId)) {
log.info("Skipped: " + message.getMessage());
session.sendPlayerBoolean(gameId, false);
} break;
}
case "gameOver":
log.info("Game over");
gameOver = true;
break;
}
}
public void setSession(Session session) {
this.session = session;
}
public boolean isGameOver() {
return gameOver;
}
private void startControlThread() {
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
controlCount++;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (controlCount > 5) {
log.warn("Game seems freezed. Sending boolean message to server.");
session.sendPlayerBoolean(gameId, false);
controlCount = 0;
}
}
}
}).start();
}
}
//package org.mage.test.load;
//
//import mage.interfaces.callback.CallbackClient;
//import mage.interfaces.callback.ClientCallback;
//import mage.remote.Session;
//import mage.utils.CompressUtil;
//import mage.view.GameClientMessage;
//import mage.view.GameView;
//import mage.view.SimpleCardView;
//import mage.view.TableClientMessage;
//import org.apache.log4j.Logger;
//
//import java.util.UUID;
//
///**
// * @author noxx
// */
//public class LoadCallbackClient implements CallbackClient {
//
// private static final transient Logger log = Logger.getLogger(LoadCallbackClient.class);
//
// private Session session;
// private UUID gameId;
// private UUID playerId;
// private boolean gameOver;
//
// private volatile int controlCount;
//
// private GameView gameView;
//
// @Override
// public void processCallback(ClientCallback callback) {
// //TODO
// controlCount = 0;
// log.info(callback.getMethod());
// callback.setData(CompressUtil.decompress(callback.getData()));
// switch (callback.getMethod()) {
// case "startGame":
// {
// TableClientMessage message = (TableClientMessage) callback.getData();
// gameId = message.getGameId();
// playerId = message.getPlayerId();
// session.joinGame(message.getGameId());
// startControlThread();
// break;
// }
// case "gameInform":
// {
// GameClientMessage message = (GameClientMessage) callback.getData();
// log.info("Inform: " + message.getMessage());
// gameView = message.getGameView();
// break;
// }
// case "gameInit":
// break;
// case "gameTarget":
// {
// GameClientMessage message = (GameClientMessage) callback.getData();
// log.info("Target: " + message.getMessage());
// switch (message.getMessage()) {
// case "Select a starting player":
// session.sendPlayerUUID(gameId, playerId);
// break;
// case "Select a card to discard":
// log.info("hand size: " + gameView.getHand().size());
// SimpleCardView card = gameView.getHand().values().iterator().next();
// session.sendPlayerUUID(gameId, card.getId());
// break;
// }
// break;
// }
// case "gameAsk":
// {
// GameClientMessage message = (GameClientMessage) callback.getData();
// log.info("Ask: " + message.getMessage());
// if (message.getMessage().equals("Do you want to take a mulligan?")) {
// session.sendPlayerBoolean(gameId, false);
// } break;
// }
// case "gameSelect":
// {
// GameClientMessage message = (GameClientMessage) callback.getData();
// log.info("Select: " + message.getMessage());
// if (LoadPhaseManager.getInstance().isSkip(message.getGameView(), message.getMessage(), playerId)) {
// log.info("Skipped: " + message.getMessage());
// session.sendPlayerBoolean(gameId, false);
// } break;
// }
// case "gameOver":
// log.info("Game over");
// gameOver = true;
// break;
// }
//
// }
//
// public void setSession(Session session) {
// this.session = session;
// }
//
// public boolean isGameOver() {
// return gameOver;
// }
//
// private void startControlThread() {
// new Thread(new Runnable() {
// @Override
// public void run() {
// while (true) {
// controlCount++;
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// if (controlCount > 5) {
// log.warn("Game seems freezed. Sending boolean message to server.");
// session.sendPlayerBoolean(gameId, false);
// controlCount = 0;
// }
// }
//
// }
// }).start();
// }
//}

View file

@ -1,300 +1,300 @@
package org.mage.test.load;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardLists;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.ColoredManaSymbol;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.game.match.MatchOptions;
import mage.player.ai.ComputerPlayer;
import mage.remote.Connection;
import mage.remote.Session;
import mage.remote.SessionImpl;
import mage.cards.Sets;
import mage.view.GameTypeView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.cards.decks.DeckCardInfo;
/**
* Intended to test Mage server under different load patterns.
*
* These tests do use server started separately, so Mage server should be started before running them.
* In case you want to debug these tests, use -Ddebug.mage that would disable client-server request timeout.
*
* Then it's also better to use -Xms256M -Xmx512M JVM options for these stests.
*
* @author noxx
*/
public class LoadTest {
/**
* Logger for tests
*/
private static final Logger log = Logger.getLogger(LoadTest.class);
/**
* First player's username
*/
private static final String TEST_USER_NAME = "player";
/**
* Second player's username
*/
private static final String TEST_USER_NAME_2 = "opponent";
/**
* Server connection setting.
*/
private static final String TEST_SERVER = "localhost";
/**
* Server connection setting.
*/
private static final int TEST_PORT = 17171;
/**
* Server connection setting.
*/
private static final String TEST_PROXY_TYPE = "None";
/**
* Determines how many times test will be executed in a row.
*/
private static final int EXECUTION_COUNT = 100;
/**
* Determines how many times test will be executed in a row.
*/
private static final int EXECUTION_COUNT_PLAY_GAME = 100;
/**
* Tests connecting with two players, creating game and starting it.
*
* Executes the test EXECUTION_COUNT times.
*
* @throws Exception
*/
@Test
@Ignore
public void testStartGame() throws Exception {
DeckCardLists deckList = createDeck();
for (int i = 0; i < EXECUTION_COUNT; i++) {
Connection connection = createConnection(TEST_USER_NAME + i);
SimpleMageClient mageClient = new SimpleMageClient();
Session session = new SessionImpl(mageClient);
session.connect(connection);
UUID roomId = session.getMainRoomId();
GameTypeView gameTypeView = session.getGameTypes().get(0);
log.info("Game type view: " + gameTypeView.getName());
MatchOptions options = createGameOptions(gameTypeView, session);
TableView table = session.createTable(roomId, options);
if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
log.error("Error while joining table");
Assert.assertTrue("Error while joining table", false);
return;
}
/*** Connect with a second player ***/
Connection connection2 = createConnection(TEST_USER_NAME_2 + i);
SimpleMageClient mageClient2 = new SimpleMageClient();
Session session2 = new SessionImpl(mageClient2);
session2.connect(connection2);
UUID roomId2 = session2.getMainRoomId();
// connect to the table with the same deck
if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
log.error("Error while joining table");
Assert.assertTrue("Error while joining table", false);
return;
}
/*** Start game ***/
session.startMatch(roomId, table.getTableId());
Thread.sleep(100);
}
}
/**
* Tests 10 simple games played one after another.
*/
@Test
@Ignore
public void testSimpleGame() throws Exception {
final DeckCardLists deckList = createDeck();
for (int i = 0; i < EXECUTION_COUNT_PLAY_GAME; i++) {
final int j = i;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
testSimpleGame0(deckList, j);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
t.start();
t.join();
}
}
/**
* Tests simple game till the end (game over).
* Players do nothing but skip phases and discard cards at the end.
*
* This results in a game that lasts until there is no cards in library.
*/
private boolean testSimpleGame0(DeckCardLists deckList, int i) throws InterruptedException {
Connection connection = createConnection(TEST_USER_NAME + i);
SimpleMageClient mageClient = new SimpleMageClient();
Session session = new SessionImpl(mageClient);
session.connect(connection);
mageClient.setSession(session);
UUID roomId = session.getMainRoomId();
GameTypeView gameTypeView = session.getGameTypes().get(0);
log.info("Game type view: " + gameTypeView.getName());
MatchOptions options = createGameOptions(gameTypeView, session);
TableView table = session.createTable(roomId, options);
if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
log.error("Error while joining table");
Assert.assertTrue("Error while joining table", false);
return true;
}
/*** Connect with a second player ***/
Connection connection2 = createConnection(TEST_USER_NAME_2 + i);
SimpleMageClient mageClient2 = new SimpleMageClient();
Session session2 = new SessionImpl(mageClient2);
session2.connect(connection2);
mageClient2.setSession(session2);
UUID roomId2 = session2.getMainRoomId();
// connect to the table with the same deck
if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
log.error("Error while joining table");
Assert.assertTrue("Error while joining table", false);
return true;
}
/*** Start game ***/
session.startMatch(roomId, table.getTableId());
while (!mageClient.isGameOver()) {
Thread.sleep(1000);
}
return false;
}
/**
* Tests playing the whole game.
* Player use cheat to add lands, creatures and other cards.
* Then play only lands, one of them plays 1 damage targeting player.
*
* This results in 40 turns of the game.
*/
@Test
@Ignore
public void testPlayGame() throws Exception {
//TODO: to be implemented
}
/**
* Creates connection to the server.
* Server should run independently.
*
* @param username
* @return
*/
private Connection createConnection(String username) {
Connection connection = new Connection();
connection.setUsername(username);
connection.setHost(TEST_SERVER);
connection.setPort(TEST_PORT);
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(TEST_PROXY_TYPE);
connection.setProxyType(proxyType);
return connection;
}
/**
* Returns random deck.
* Converts deck returned by {@link #generateRandomDeck} method to {@link DeckCardLists} format.
*
* @return
*/
private DeckCardLists createDeck() {
DeckCardLists deckList = new DeckCardLists();
Deck deck = generateRandomDeck();
for (Card card : deck.getCards()) {
CardInfo cardInfo = CardRepository.instance.findCard(card.getExpansionSetCode(), card.getCardNumber());
if (cardInfo != null) {
deckList.getCards().add(new DeckCardInfo(cardInfo.getName(), cardInfo.getCardNumber(), cardInfo.getSetCode()));
}
}
return deckList;
}
/**
* Creates game options with two human players.
*
* @param gameTypeView
* @param session
* @return
*/
private MatchOptions createGameOptions(GameTypeView gameTypeView, Session session) {
MatchOptions options = new MatchOptions("Test game", gameTypeView.getName());
options.getPlayerTypes().add("Human");
options.getPlayerTypes().add("Human");
options.setDeckType(session.getDeckTypes()[0]);
options.setLimited(false);
options.setAttackOption(MultiplayerAttackOption.MULTIPLE);
options.setRange(RangeOfInfluence.ALL);
options.setWinsNeeded(1);
return options;
}
/**
* Generates random deck in {@link Deck} format.
* Uses {B}{R} as deck colors.
*
* @return
*/
private Deck generateRandomDeck() {
String selectedColors = "BR";
List<ColoredManaSymbol> allowedColors = new ArrayList<ColoredManaSymbol>();
log.info("Building deck with colors: " + selectedColors);
for (int i = 0; i < selectedColors.length(); i++) {
char c = selectedColors.charAt(i);
allowedColors.add(ColoredManaSymbol.lookup(c));
}
List<Card> cardPool = Sets.generateRandomCardPool(45, allowedColors);
return ComputerPlayer.buildDeck(cardPool, allowedColors);
}
}
//package org.mage.test.load;
//
//import mage.cards.Card;
//import mage.cards.decks.Deck;
//import mage.cards.decks.DeckCardLists;
//import mage.cards.repository.CardInfo;
//import mage.cards.repository.CardRepository;
//import mage.constants.ColoredManaSymbol;
//import mage.constants.MultiplayerAttackOption;
//import mage.constants.RangeOfInfluence;
//import mage.game.match.MatchOptions;
//import mage.player.ai.ComputerPlayer;
//import mage.remote.Connection;
////import mage.remote.Session;
////import mage.remote.SessionImpl;
//import mage.cards.Sets;
//import mage.view.GameTypeView;
//import mage.view.TableView;
//import org.apache.log4j.Logger;
//import org.junit.Assert;
//import org.junit.Ignore;
//import org.junit.Test;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.UUID;
//import mage.cards.decks.DeckCardInfo;
//
///**
// * Intended to test Mage server under different load patterns.
// *
// * These tests do use server started separately, so Mage server should be started before running them.
// * In case you want to debug these tests, use -Ddebug.mage that would disable client-server request timeout.
// *
// * Then it's also better to use -Xms256M -Xmx512M JVM options for these stests.
// *
// * @author noxx
// */
//public class LoadTest {
//
// /**
// * Logger for tests
// */
// private static final Logger log = Logger.getLogger(LoadTest.class);
//
// /**
// * First player's username
// */
// private static final String TEST_USER_NAME = "player";
//
// /**
// * Second player's username
// */
// private static final String TEST_USER_NAME_2 = "opponent";
//
// /**
// * Server connection setting.
// */
// private static final String TEST_SERVER = "localhost";
//
// /**
// * Server connection setting.
// */
// private static final int TEST_PORT = 17171;
//
// /**
// * Server connection setting.
// */
// private static final String TEST_PROXY_TYPE = "None";
//
// /**
// * Determines how many times test will be executed in a row.
// */
// private static final int EXECUTION_COUNT = 100;
//
// /**
// * Determines how many times test will be executed in a row.
// */
// private static final int EXECUTION_COUNT_PLAY_GAME = 100;
//
// /**
// * Tests connecting with two players, creating game and starting it.
// *
// * Executes the test EXECUTION_COUNT times.
// *
// * @throws Exception
// */
// @Test
// @Ignore
// public void testStartGame() throws Exception {
// DeckCardLists deckList = createDeck();
//
// for (int i = 0; i < EXECUTION_COUNT; i++) {
// Connection connection = createConnection(TEST_USER_NAME + i);
//
// SimpleMageClient mageClient = new SimpleMageClient();
// Session session = new SessionImpl(mageClient);
//
// session.connect(connection);
// UUID roomId = session.getMainRoomId();
//
// GameTypeView gameTypeView = session.getGameTypes().get(0);
// log.info("Game type view: " + gameTypeView.getName());
// MatchOptions options = createGameOptions(gameTypeView, session);
//
// TableView table = session.createTable(roomId, options);
//
// if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
// log.error("Error while joining table");
// Assert.assertTrue("Error while joining table", false);
// return;
// }
//
// /*** Connect with a second player ***/
// Connection connection2 = createConnection(TEST_USER_NAME_2 + i);
// SimpleMageClient mageClient2 = new SimpleMageClient();
// Session session2 = new SessionImpl(mageClient2);
// session2.connect(connection2);
// UUID roomId2 = session2.getMainRoomId();
//
// // connect to the table with the same deck
// if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
// log.error("Error while joining table");
// Assert.assertTrue("Error while joining table", false);
// return;
// }
//
// /*** Start game ***/
// session.startMatch(roomId, table.getTableId());
//
// Thread.sleep(100);
// }
// }
//
// /**
// * Tests 10 simple games played one after another.
// */
// @Test
// @Ignore
// public void testSimpleGame() throws Exception {
// final DeckCardLists deckList = createDeck();
//
// for (int i = 0; i < EXECUTION_COUNT_PLAY_GAME; i++) {
// final int j = i;
// Thread t = new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// testSimpleGame0(deckList, j);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// });
// t.start();
// t.join();
// }
// }
//
// /**
// * Tests simple game till the end (game over).
// * Players do nothing but skip phases and discard cards at the end.
// *
// * This results in a game that lasts until there is no cards in library.
// */
// private boolean testSimpleGame0(DeckCardLists deckList, int i) throws InterruptedException {
// Connection connection = createConnection(TEST_USER_NAME + i);
//
// SimpleMageClient mageClient = new SimpleMageClient();
// Session session = new SessionImpl(mageClient);
//
// session.connect(connection);
//
// mageClient.setSession(session);
// UUID roomId = session.getMainRoomId();
//
// GameTypeView gameTypeView = session.getGameTypes().get(0);
// log.info("Game type view: " + gameTypeView.getName());
// MatchOptions options = createGameOptions(gameTypeView, session);
//
// TableView table = session.createTable(roomId, options);
//
// if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
// log.error("Error while joining table");
// Assert.assertTrue("Error while joining table", false);
// return true;
// }
//
// /*** Connect with a second player ***/
// Connection connection2 = createConnection(TEST_USER_NAME_2 + i);
// SimpleMageClient mageClient2 = new SimpleMageClient();
// Session session2 = new SessionImpl(mageClient2);
// session2.connect(connection2);
//
// mageClient2.setSession(session2);
// UUID roomId2 = session2.getMainRoomId();
//
// // connect to the table with the same deck
// if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
// log.error("Error while joining table");
// Assert.assertTrue("Error while joining table", false);
// return true;
// }
//
// /*** Start game ***/
// session.startMatch(roomId, table.getTableId());
//
// while (!mageClient.isGameOver()) {
// Thread.sleep(1000);
// }
// return false;
// }
//
// /**
// * Tests playing the whole game.
// * Player use cheat to add lands, creatures and other cards.
// * Then play only lands, one of them plays 1 damage targeting player.
// *
// * This results in 40 turns of the game.
// */
// @Test
// @Ignore
// public void testPlayGame() throws Exception {
// //TODO: to be implemented
// }
//
// /**
// * Creates connection to the server.
// * Server should run independently.
// *
// * @param username
// * @return
// */
// private Connection createConnection(String username) {
// Connection connection = new Connection();
// connection.setUsername(username);
// connection.setHost(TEST_SERVER);
// connection.setPort(TEST_PORT);
// Connection.ProxyType proxyType = Connection.ProxyType.valueByText(TEST_PROXY_TYPE);
// connection.setProxyType(proxyType);
// return connection;
// }
//
// /**
// * Returns random deck.
// * Converts deck returned by {@link #generateRandomDeck} method to {@link DeckCardLists} format.
// *
// * @return
// */
// private DeckCardLists createDeck() {
// DeckCardLists deckList = new DeckCardLists();
// Deck deck = generateRandomDeck();
// for (Card card : deck.getCards()) {
// CardInfo cardInfo = CardRepository.instance.findCard(card.getExpansionSetCode(), card.getCardNumber());
// if (cardInfo != null) {
// deckList.getCards().add(new DeckCardInfo(cardInfo.getName(), cardInfo.getCardNumber(), cardInfo.getSetCode()));
// }
// }
// return deckList;
// }
//
// /**
// * Creates game options with two human players.
// *
// * @param gameTypeView
// * @param session
// * @return
// */
// private MatchOptions createGameOptions(GameTypeView gameTypeView, Session session) {
// MatchOptions options = new MatchOptions("Test game", gameTypeView.getName());
//
// options.getPlayerTypes().add("Human");
// options.getPlayerTypes().add("Human");
//
// options.setDeckType(session.getDeckTypes()[0]);
// options.setLimited(false);
// options.setAttackOption(MultiplayerAttackOption.MULTIPLE);
// options.setRange(RangeOfInfluence.ALL);
// options.setWinsNeeded(1);
// return options;
// }
//
// /**
// * Generates random deck in {@link Deck} format.
// * Uses {B}{R} as deck colors.
// *
// * @return
// */
// private Deck generateRandomDeck() {
// String selectedColors = "BR";
// List<ColoredManaSymbol> allowedColors = new ArrayList<ColoredManaSymbol>();
// log.info("Building deck with colors: " + selectedColors);
// for (int i = 0; i < selectedColors.length(); i++) {
// char c = selectedColors.charAt(i);
// allowedColors.add(ColoredManaSymbol.lookup(c));
// }
// List<Card> cardPool = Sets.generateRandomCardPool(45, allowedColors);
// return ComputerPlayer.buildDeck(cardPool, allowedColors);
// }
//}

View file

@ -1,67 +1,68 @@
package org.mage.test.load;
import java.util.UUID;
import mage.interfaces.MageClient;
import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback;
import mage.remote.Session;
import mage.utils.MageVersion;
import org.apache.log4j.Logger;
/**
* For tests only
*
* @author noxx
*/
public class SimpleMageClient implements MageClient {
private final UUID clientId;
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static final transient Logger log = Logger.getLogger(SimpleMageClient.class);
private final CallbackClient callbackClient;
public SimpleMageClient() {
clientId = UUID.randomUUID();
callbackClient = new LoadCallbackClient();
}
@Override
public MageVersion getVersion() {
return version;
}
@Override
public void connected(String message) {
// do nothing
}
@Override
public void disconnected(boolean errorCall) {
// do nothing
}
@Override
public void showMessage(String message) {
log.info(message);
}
@Override
public void showError(String message) {
log.error(message);
}
@Override
public void processCallback(ClientCallback callback) {
callbackClient.processCallback(callback);
}
public void setSession(Session session) {
((LoadCallbackClient)callbackClient).setSession(session);
}
public boolean isGameOver() {
return ((LoadCallbackClient)callbackClient).isGameOver();
}
}
//package org.mage.test.load;
//
//import java.util.UUID;
////import mage.interfaces.MageClient;
////import mage.interfaces.callback.CallbackClient;
////import mage.interfaces.callback.ClientCallback;
////import mage.remote.Session;
//import mage.utils.MageVersion;
//import org.apache.log4j.Logger;
//import org.mage.network.interfaces.MageClient;
//
///**
// * For tests only
// *
// * @author noxx
// */
//public class SimpleMageClient implements MageClient {
//
// private final UUID clientId;
// private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
//
// private static final transient Logger log = Logger.getLogger(SimpleMageClient.class);
//
//// private final CallbackClient callbackClient;
//
// public SimpleMageClient() {
// clientId = UUID.randomUUID();
// callbackClient = new LoadCallbackClient();
// }
//
// @Override
// public MageVersion getVersion() {
// return version;
// }
//
// @Override
// public void connected(String message) {
// // do nothing
// }
//
// @Override
// public void disconnected(boolean errorCall) {
// // do nothing
// }
//
// @Override
// public void showMessage(String message) {
// log.info(message);
// }
//
// @Override
// public void showError(String message) {
// log.error(message);
// }
//
// @Override
// public void processCallback(ClientCallback callback) {
// callbackClient.processCallback(callback);
// }
//
// public void setSession(Session session) {
// ((LoadCallbackClient)callbackClient).setSession(session);
// }
//
// public boolean isGameOver() {
// return ((LoadCallbackClient)callbackClient).isGameOver();
// }
//}