diff --git a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java index 584442aae1..1610e4ca13 100644 --- a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java +++ b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java @@ -220,6 +220,14 @@ public class CallbackClientImpl implements CallbackClient { logger.warn("message out of sequence - ignoring"); } } + else if (callback.getMethod().equals("gameInformPersonal")) { + GameClientMessage message = (GameClientMessage) callback.getData(); + GamePanel panel = frame.getGame(callback.getObjectId()); + if (panel != null) { + JOptionPane.showMessageDialog(panel, message.getMessage(), "Game message", + JOptionPane.INFORMATION_MESSAGE); + } + } else if (callback.getMethod().equals("sideboard")) { TableClientMessage message = (TableClientMessage) callback.getData(); DeckView deckView = message.getDeck(); diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 4255417aed..74a3a6b064 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -168,6 +168,9 @@ public class GameController implements GameCallback { case LOOK: lookAtCards(event.getPlayerId(), event.getMessage(), event.getCards()); break; + case PERSONAL_MESSAGE: + informPersonal(event.getPlayerId(), event.getMessage()); + break; } } catch (MageException ex) { logger.fatal("Player event listener error ", ex); @@ -519,6 +522,14 @@ public class GameController implements GameCallback { } } + private synchronized void informPersonal(UUID playerId, final String message) throws MageException { + perform(playerId, new Command() { + public void execute(UUID playerId) { + gameSessions.get(playerId).informPersonal(message); + } + }); + } + private void error(String message, Exception ex) { StringBuilder sb = new StringBuilder(); sb.append(message).append(ex.toString()); diff --git a/Mage.Server/src/main/java/mage/server/game/GameWatcher.java b/Mage.Server/src/main/java/mage/server/game/GameWatcher.java index 4fa3713b6c..ac45818112 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameWatcher.java +++ b/Mage.Server/src/main/java/mage/server/game/GameWatcher.java @@ -28,8 +28,6 @@ package mage.server.game; -import java.rmi.RemoteException; -import java.util.UUID; import mage.game.Game; import mage.interfaces.callback.ClientCallback; import mage.server.User; @@ -38,6 +36,9 @@ import mage.view.GameClientMessage; import mage.view.GameView; import org.apache.log4j.Logger; +import java.rmi.RemoteException; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -84,6 +85,15 @@ public class GameWatcher { } } + public void informPersonal(final String message) { + if (!killed) { + User user = UserManager.getInstance().getUser(userId); + if (user != null) { + user.fireCallback(new ClientCallback("gameInformPersonal", game.getId(), new GameClientMessage(getGameView(), message))); + } + } + } + public void gameOver(final String message) { if (!killed) { User user = UserManager.getInstance().getUser(userId); diff --git a/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java b/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java index 05b7841b76..3ec2abe784 100644 --- a/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/DamageTargetEffect.java @@ -109,6 +109,7 @@ public class DamageTargetEffect extends OneShotEffect { } Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { + game.informPlayer(player, "You were dealt 3 damage"); player.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable); return true; } diff --git a/Mage/src/mage/game/events/PlayerQueryEvent.java b/Mage/src/mage/game/events/PlayerQueryEvent.java index f9d388cb99..f8651c83f4 100644 --- a/Mage/src/mage/game/events/PlayerQueryEvent.java +++ b/Mage/src/mage/game/events/PlayerQueryEvent.java @@ -28,8 +28,6 @@ package mage.game.events; -import java.io.Serializable; -import java.util.*; import mage.abilities.Ability; import mage.abilities.ActivatedAbility; import mage.abilities.TriggeredAbility; @@ -37,6 +35,9 @@ import mage.cards.Card; import mage.cards.Cards; import mage.game.permanent.Permanent; +import java.io.Serializable; +import java.util.*; + /** * * @author BetaSteward_at_googlemail.com @@ -44,7 +45,7 @@ import mage.game.permanent.Permanent; public class PlayerQueryEvent extends EventObject implements ExternalEvent, Serializable { public enum QueryType { - ASK, CHOOSE, CHOOSE_ABILITY, CHOOSE_MODE, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD, CONSTRUCT, CHOOSE_PILE + ASK, CHOOSE, CHOOSE_ABILITY, CHOOSE_MODE, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD, CONSTRUCT, CHOOSE_PILE, PERSONAL_MESSAGE } private String message; @@ -127,6 +128,13 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri this.pile2 = pile2; } + private PlayerQueryEvent(UUID playerId, String message) { + super(playerId); + this.queryType = QueryType.PERSONAL_MESSAGE; + this.message = message; + this.playerId = playerId; + } + public static PlayerQueryEvent askEvent(UUID playerId, String message) { return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false); } @@ -195,6 +203,9 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri return new PlayerQueryEvent(playerId, message, QueryType.CONSTRUCT, time); } + public static PlayerQueryEvent informPersonal(UUID playerId, String message) { + return new PlayerQueryEvent(playerId, message); + } public String getMessage() { return message; diff --git a/Mage/src/mage/game/events/PlayerQueryEventSource.java b/Mage/src/mage/game/events/PlayerQueryEventSource.java index ff49d6c196..5a29a72ebf 100644 --- a/Mage/src/mage/game/events/PlayerQueryEventSource.java +++ b/Mage/src/mage/game/events/PlayerQueryEventSource.java @@ -28,14 +28,15 @@ package mage.game.events; -import java.io.Serializable; -import java.util.*; - -import mage.abilities.*; +import mage.abilities.ActivatedAbility; +import mage.abilities.TriggeredAbility; import mage.cards.Card; import mage.cards.Cards; import mage.game.permanent.Permanent; +import java.io.Serializable; +import java.util.*; + /** * * @author BetaSteward_at_googlemail.com @@ -117,4 +118,8 @@ public class PlayerQueryEventSource implements EventSource, Se dispatcher.fireEvent(PlayerQueryEvent.construct(playerId, message, time)); } + public void informPlayer(UUID playerId, String message) { + dispatcher.fireEvent(PlayerQueryEvent.informPersonal(playerId, message)); + } + } diff --git a/Mage/src/mage/game/events/TableEvent.java b/Mage/src/mage/game/events/TableEvent.java index 3840fa5249..9b57a85e3e 100644 --- a/Mage/src/mage/game/events/TableEvent.java +++ b/Mage/src/mage/game/events/TableEvent.java @@ -28,9 +28,6 @@ package mage.game.events; -import java.io.Serializable; -import java.util.EventObject; -import java.util.UUID; import mage.cards.Cards; import mage.cards.decks.Deck; import mage.game.Game; @@ -38,6 +35,10 @@ import mage.game.draft.Draft; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentPairing; +import java.io.Serializable; +import java.util.EventObject; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -82,6 +83,11 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab this.ex = ex; } + public TableEvent(EventType eventType, UUID playerId, String message, Game game) { + this(eventType, message, game); + this.playerId = playerId; + } + public TableEvent(EventType eventType, UUID playerId, Deck deck, int timeout) { super(playerId); this.playerId = playerId; diff --git a/Mage/src/mage/game/events/TableEventSource.java b/Mage/src/mage/game/events/TableEventSource.java index 44d8212a7d..6d89abb684 100644 --- a/Mage/src/mage/game/events/TableEventSource.java +++ b/Mage/src/mage/game/events/TableEventSource.java @@ -28,8 +28,6 @@ package mage.game.events; -import java.io.Serializable; -import java.util.UUID; import mage.cards.Cards; import mage.cards.decks.Deck; import mage.game.Game; @@ -38,6 +36,9 @@ import mage.game.events.TableEvent.EventType; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentPairing; +import java.io.Serializable; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -59,6 +60,10 @@ public class TableEventSource implements EventSource, Serializable { dispatcher.fireEvent(new TableEvent(eventType, message, game)); } + public void fireTableEvent(EventType eventType, UUID playerId, String message, Game game) { + dispatcher.fireEvent(new TableEvent(eventType, playerId, message, game)); + } + public void fireTableEvent(EventType eventType, String message, Exception ex, Game game) { dispatcher.fireEvent(new TableEvent(eventType, message, ex, game)); }