From 473e929a58fd5c76b4f1108c99927bc1cc808b79 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 11 Mar 2017 18:18:54 +0100 Subject: [PATCH 1/2] * Stitcher's Graft - Fixed that the triggered ability was wrongly given to the equipped creature instead of being a ability of the equipment. Fixed a bug that prevented that the equipped creature did not untap after attacking. --- .../src/mage/cards/s/StitchersGraft.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Mage.Sets/src/mage/cards/s/StitchersGraft.java b/Mage.Sets/src/mage/cards/s/StitchersGraft.java index 82a4e2add8..b3e8e90fe7 100644 --- a/Mage.Sets/src/mage/cards/s/StitchersGraft.java +++ b/Mage.Sets/src/mage/cards/s/StitchersGraft.java @@ -33,20 +33,20 @@ import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.UnattachedTriggeredAbility; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.DontUntapInControllersNextUntapStepSourceEffect; +import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect; import mage.abilities.effects.common.SacrificeTargetEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect; -import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EquipAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.AttachmentType; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; /** * @@ -55,19 +55,17 @@ import mage.game.events.GameEvent.EventType; public class StitchersGraft extends CardImpl { public StitchersGraft(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); this.subtype.add("Equipment"); // Equipped creature gets +3/+3. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(3, 3))); // Whenever equipped creature attacks, it doesn't untap during its controller's next untap step. - Effect effect = new GainAbilityAttachedEffect(new StitchersGraftTriggeredAbility(), AttachmentType.EQUIPMENT); - effect.setText("Equipped creature has \"Whenever equipped creature attacks, it doesn't untap during its controller's next untap step.\""); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); + this.addAbility(new StitchersGraftTriggeredAbility()); // Whenever Stitcher's Graft becomes unattached from a permanent, sacrifice that permanent. - effect = new SacrificeTargetEffect(); + Effect effect = new SacrificeTargetEffect(); effect.setText("sacrifice that permanent"); this.addAbility(new UnattachedTriggeredAbility(effect, false)); @@ -88,7 +86,7 @@ public class StitchersGraft extends CardImpl { class StitchersGraftTriggeredAbility extends TriggeredAbilityImpl { public StitchersGraftTriggeredAbility() { - super(Zone.BATTLEFIELD, new DontUntapInControllersNextUntapStepSourceEffect()); + super(Zone.BATTLEFIELD, new DontUntapInControllersNextUntapStepTargetEffect()); } public StitchersGraftTriggeredAbility(final StitchersGraftTriggeredAbility ability) { @@ -107,7 +105,12 @@ class StitchersGraftTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { + Permanent equipment = game.getPermanent(this.sourceId); + if (equipment != null && equipment.getAttachedTo() != null + && event.getSourceId().equals(equipment.getAttachedTo())) { + for (Effect effect : getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getSourceId(), game)); + } return true; } return false; @@ -115,6 +118,6 @@ class StitchersGraftTriggeredAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return "Whenever equipped creature attacks, it doesn't untap during its controller's next untap step"; + return "Whenever equipped creature attacks, it doesn't untap during its controller's next untap step."; } } From 95869811acba2894316620a24d2eac0220335375 Mon Sep 17 00:00:00 2001 From: ingmargoudt Date: Sat, 25 Mar 2017 09:38:08 +0100 Subject: [PATCH 2/2] fixed scope issue when logging in --- .../src/main/java/mage/server/Session.java | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index f01adb59ae..a96129aa3b 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -222,45 +222,47 @@ public class Session { ); } - Optional selectUser = UserManager.instance.createUser(userName, host, authorizedUser); - boolean reconnect = false; - if (!selectUser.isPresent()) { // user already exists - selectUser = UserManager.instance.getUserByName(userName); - if (selectUser.isPresent()) { - User user = selectUser.get(); - // If authentication is not activated, check the identity using IP address. - if (ConfigSettings.instance.isAuthenticationActivated() || user.getHost().equals(host)) { - user.updateLastActivity(null); // minimizes possible expiration - this.userId = user.getId(); - if (user.getSessionId().isEmpty()) { - logger.info("Reconnecting session for " + userName); - reconnect = true; - } else { - //disconnect previous session - logger.info("Disconnecting another user instance: " + userName); - SessionManager.instance.disconnect(user.getSessionId(), DisconnectReason.ConnectingOtherInstance); - } - } else { - return "User name " + userName + " already in use (or your IP address changed)"; - } - } - } + } + } + Optional selectUser = UserManager.instance.createUser(userName, host, authorizedUser); + boolean reconnect = false; + if (!selectUser.isPresent()) { // user already exists + selectUser = UserManager.instance.getUserByName(userName); + if (selectUser.isPresent()) { User user = selectUser.get(); - if (!UserManager.instance.connectToSession(sessionId, user.getId())) { - return "Error connecting " + userName; - } - this.userId = user.getId(); - if (reconnect) { // must be connected to receive the message - Optional room = GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId()); - if (!room.isPresent()) { - logger.error("main room not found"); - return null; + // If authentication is not activated, check the identity using IP address. + if (ConfigSettings.instance.isAuthenticationActivated() || user.getHost().equals(host)) { + user.updateLastActivity(null); // minimizes possible expiration + this.userId = user.getId(); + if (user.getSessionId().isEmpty()) { + logger.info("Reconnecting session for " + userName); + reconnect = true; + } else { + //disconnect previous session + logger.info("Disconnecting another user instance: " + userName); + SessionManager.instance.disconnect(user.getSessionId(), DisconnectReason.ConnectingOtherInstance); } - ChatManager.instance.joinChat(room.get().getChatId(), userId); - ChatManager.instance.sendReconnectMessage(userId); + } else { + return "User name " + userName + " already in use (or your IP address changed)"; } } } + User user = selectUser.get(); + if (!UserManager.instance.connectToSession(sessionId, user.getId())) { + return "Error connecting " + userName; + } + this.userId = user.getId(); + if (reconnect) { // must be connected to receive the message + Optional room = GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId()); + if (!room.isPresent()) { + logger.error("main room not found"); + return null; + } + ChatManager.instance.joinChat(room.get().getChatId(), userId); + ChatManager.instance.sendReconnectMessage(userId); + } + + return null; }