use of org.jivesoftware.spark.ui.ShakeWindow in project Spark by igniterealtime.
the class GamePanel method onGameBoardPlaceMark.
/**
* being called from GameBoardPanel, places the Mark on the Logical Board
* and sends the Move if it was one
*
* @param m
* @param x
* @param y
*/
public void onGameBoardPlaceMark(Mark m, int x, int y) {
_gameboard.placeMark(x, y);
_playerdisplay.setCurrentPlayer(_gameboard.getCurrentPlayer());
if (m == getMyMark()) {
MovePacket move = new MovePacket();
move.setGameID(_gameID);
move.setPositionX(x);
move.setPositionY(y);
Message message = new Message(_opponent);
message.addExtension(move);
try {
_connection.sendStanza(message);
} catch (SmackException.NotConnectedException e) {
Log.warning("Unable to send move to " + message.getTo(), e);
}
}
if (_gameboard.isGameFinished()) {
_gameboardpanel.colorizeWinners(_gameboard.getWinningPositions());
if (_gameboard.getWinner() == getMyMark().getValue()) {
remove(_playerdisplay);
add(new GameEndsUI(TTTRes.getString("ttt.win"), Color.GREEN), BorderLayout.SOUTH);
}
if (_gameboard.getWinner() == getYourMark().getValue()) {
remove(_playerdisplay);
add(new GameEndsUI(TTTRes.getString("ttt.lose"), Color.RED), BorderLayout.SOUTH);
}
if (_gameboard.getWinner() == -1) {
remove(_playerdisplay);
add(new GameEndsUI(TTTRes.getString("ttt.tie"), Color.BLACK), BorderLayout.SOUTH);
}
ShakeWindow sw = new ShakeWindow(_frame);
sw.startShake();
repaint();
revalidate();
}
}
Aggregations