diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 158b298f2b..b0b345bbde 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -414,7 +414,6 @@ public class PlayerPanelExt extends javax.swing.JPanel { zonesPanel.setSize(100, 20); zonesPanel.setLayout(null); - // image = ImageHelper.getImageFromResources("/info/command_zone.png"); r = new Rectangle(21, 21); resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); @@ -735,7 +734,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { } private void btnManaActionPerformed(ManaType manaType) { - session.sendPlayerManaType(gameId, manaType); + session.sendPlayerManaType(gameId, player.getPlayerId(), manaType); } private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed @@ -764,10 +763,6 @@ public class PlayerPanelExt extends javax.swing.JPanel { private ImagePanel life; private ImagePanel poison; private ImagePanel hand; - -// private HoverButton btnWhiteMana; -// private HoverButton btnBlueMana; - private HoverButton grave; private ImagePanel library; private CardView topCard; diff --git a/Mage.Common/src/mage/interfaces/MageServer.java b/Mage.Common/src/mage/interfaces/MageServer.java index 065e9fc09b..5cfacaf306 100644 --- a/Mage.Common/src/mage/interfaces/MageServer.java +++ b/Mage.Common/src/mage/interfaces/MageServer.java @@ -114,7 +114,7 @@ public interface MageServer { void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException; void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException; void sendPlayerInteger(UUID gameId, String sessionId, Integer data) throws MageException; - void sendPlayerManaType(UUID gameId, String sessionId, ManaType data) throws MageException; + void sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException; void concedeGame(UUID gameId, String sessionId) throws MageException; void quitMatch(UUID gameId, String sessionId) throws MageException; void undo(UUID gameId, String sessionId) throws MageException; diff --git a/Mage.Common/src/mage/remote/SessionImpl.java b/Mage.Common/src/mage/remote/SessionImpl.java index ac527a35e9..00c7dec2f1 100644 --- a/Mage.Common/src/mage/remote/SessionImpl.java +++ b/Mage.Common/src/mage/remote/SessionImpl.java @@ -625,10 +625,10 @@ public class SessionImpl implements Session { } @Override - public boolean sendPlayerManaType(UUID gameId, ManaType data) { + public boolean sendPlayerManaType(UUID gameId, UUID playerId, ManaType data) { try { if (isConnected()) { - server.sendPlayerManaType(gameId, sessionId, data); + server.sendPlayerManaType(gameId, playerId, sessionId, data); return true; } } catch (MageException ex) { diff --git a/Mage.Common/src/mage/remote/interfaces/GamePlay.java b/Mage.Common/src/mage/remote/interfaces/GamePlay.java index a5e8cde56b..14af9f96cb 100644 --- a/Mage.Common/src/mage/remote/interfaces/GamePlay.java +++ b/Mage.Common/src/mage/remote/interfaces/GamePlay.java @@ -51,7 +51,7 @@ public interface GamePlay { boolean sendPlayerString(UUID gameId, String data); - boolean sendPlayerManaType(UUID gameId, ManaType data); + boolean sendPlayerManaType(UUID gameId, UUID playerId, ManaType data); boolean concedeGame(UUID gameId); diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index db1f280074..af0bfda490 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -520,7 +520,10 @@ public class HumanPlayer extends PlayerImpl { } } else if (response.getManaType() != null) { // this mana type can be paid once from pool - this.getManaPool().unlockManaType(response.getManaType()); + if (response.getResponseManaTypePlayerId().equals(this.getId())) { + this.getManaPool().unlockManaType(response.getManaType()); + } + // TODO: Handle if mana pool } return true; } @@ -965,9 +968,10 @@ public class HumanPlayer extends PlayerImpl { } @Override - public void setResponseManaType(ManaType manaType) { + public void setResponseManaType(UUID playerId, ManaType manaType) { synchronized(response) { response.setManaType(manaType); + response.setResponseManaTypePlayerId(playerId); response.notify(); log.debug("Got response mana type from player: " + getId()); } diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/PlayerResponse.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/PlayerResponse.java index 0256871570..d8769b7284 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/PlayerResponse.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/PlayerResponse.java @@ -43,6 +43,7 @@ public class PlayerResponse implements Serializable { private Boolean responseBoolean; private Integer responseInteger; private ManaType responseManaType; + private UUID responseManaTypePlayerId; public void clear() { responseString = null; @@ -50,6 +51,7 @@ public class PlayerResponse implements Serializable { responseBoolean = null; responseInteger = null; responseManaType = null; + responseManaTypePlayerId = null; } public String getString() { @@ -92,4 +94,12 @@ public class PlayerResponse implements Serializable { this.responseManaType = responseManaType; } + public UUID getResponseManaTypePlayerId() { + return responseManaTypePlayerId; + } + + public void setResponseManaTypePlayerId(UUID responseManaTypePlayerId) { + this.responseManaTypePlayerId = responseManaTypePlayerId; + } + } diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java index b5162c43e7..ccf1fd076d 100644 --- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java @@ -570,13 +570,13 @@ public class MageServerImpl implements MageServer { } @Override - public void sendPlayerManaType(final UUID gameId, final String sessionId, final ManaType data) throws MageException { + public void sendPlayerManaType(final UUID gameId, final UUID playerId, final String sessionId, final ManaType data) throws MageException { execute("sendPlayerManaType", sessionId, new Action() { @Override public void execute() { User user = SessionManager.getInstance().getUser(sessionId); if (user != null) { - user.sendPlayerManaType(gameId, data); + user.sendPlayerManaType(gameId, playerId, data); } else { logger.warn("Your session expired: gameId=" + gameId + ", sessionId=" + sessionId); } diff --git a/Mage.Server/src/main/java/mage/server/User.java b/Mage.Server/src/main/java/mage/server/User.java index fa1d6c9d0b..a3d1a552f0 100644 --- a/Mage.Server/src/main/java/mage/server/User.java +++ b/Mage.Server/src/main/java/mage/server/User.java @@ -223,9 +223,9 @@ public class User { GameManager.getInstance().sendPlayerString(gameId, userId, data); } - public void sendPlayerManaType(final UUID gameId, final ManaType data) { + public void sendPlayerManaType(final UUID gameId, final UUID playerId, final ManaType data) { lastActivity = new Date(); - GameManager.getInstance().sendPlayerManaType(gameId, userId, data); + GameManager.getInstance().sendPlayerManaType(gameId, playerId, userId, data); } public void sendPlayerBoolean(final UUID gameId, final Boolean data) { 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 429a37d255..3d27682edc 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -475,11 +475,11 @@ public class GameController implements GameCallback { }); } - public void sendPlayerManaType(UUID userId, final ManaType data) { + public void sendPlayerManaType(UUID userId, UUID playerId, final ManaType data) { sendMessage(userId, new Command() { @Override public void execute(UUID playerId) { - getGameSession(playerId).sendPlayerManaType(data); + getGameSession(playerId).sendPlayerManaType(data, playerId); } }); } diff --git a/Mage.Server/src/main/java/mage/server/game/GameManager.java b/Mage.Server/src/main/java/mage/server/game/GameManager.java index 0c8d6289a2..bd7a14bf65 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameManager.java +++ b/Mage.Server/src/main/java/mage/server/game/GameManager.java @@ -85,9 +85,9 @@ public class GameManager { } } - public void sendPlayerManaType(UUID gameId, UUID userId, ManaType data) { + public void sendPlayerManaType(UUID gameId, UUID playerId, UUID userId, ManaType data) { if (gameControllers.containsKey(gameId)) { - gameControllers.get(gameId).sendPlayerManaType(userId, data); + gameControllers.get(gameId).sendPlayerManaType(userId, playerId, data); } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameSession.java b/Mage.Server/src/main/java/mage/server/game/GameSession.java index 46db5ca27a..dc9e82d693 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameSession.java +++ b/Mage.Server/src/main/java/mage/server/game/GameSession.java @@ -221,9 +221,9 @@ public class GameSession extends GameWatcher { game.getPlayer(playerId).setResponseString(data); } - public void sendPlayerManaType(ManaType manaType) { + public void sendPlayerManaType(ManaType manaType, UUID playerId) { cancelTimeout(); - game.getPlayer(playerId).setResponseManaType(manaType); + game.getPlayer(playerId).setResponseManaType(playerId, manaType); } public void sendPlayerBoolean(Boolean data) { diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 005d6fcbb2..649e0a541f 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -278,7 +278,7 @@ public interface Player extends MageItem, Copyable { void setResponseUUID(UUID responseUUID); void setResponseBoolean(Boolean responseBoolean); void setResponseInteger(Integer data); - void setResponseManaType(ManaType responseManaType); + void setResponseManaType(UUID playerId, ManaType responseManaType); boolean priority(Game game); boolean choose(Outcome outcome, Target target, UUID sourceId, Game game); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index d7a6513279..6f93c04782 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -1473,7 +1473,7 @@ public abstract class PlayerImpl> implements Player, Ser public void setResponseString(String responseString) {} @Override - public void setResponseManaType(ManaType responseManaType) {} + public void setResponseManaType(UUID playerId, ManaType responseManaType) {} @Override public void setResponseUUID(UUID responseUUID) {}