From 62440463304d75e611cf48ddfa2c94c984c53fe3 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 14 Aug 2017 16:48:48 +0200 Subject: [PATCH] * Some minor changes. --- .../java/mage/server/game/GameController.java | 2 +- .../mage/cards/a/AbandonedSarcophagus.java | 6 +++--- .../src/mage/cards/a/AzoriusAEthermage.java | 2 +- Mage.Sets/src/mage/cards/m/MenacingOgre.java | 9 ++++----- .../mage/cards/p/PlaneswalkersMischief.java | 2 +- Mage.Sets/src/mage/cards/r/Reparations.java | 7 +++---- .../PlayerDiedStackTargetHandlingTest.java | 4 ++-- ...ttacksAndIsNotBlockedTriggeredAbility.java | 19 ++++++++----------- .../abilities/keyword/AftermathAbility.java | 2 +- 9 files changed, 24 insertions(+), 29 deletions(-) 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 1787d6739e..366404cff6 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -613,7 +613,7 @@ public class GameController implements GameCallback { if (viewLimitedDeckPlayer != null) { if (viewLimitedDeckPlayer.isHuman()) { for (MatchPlayer p : TableManager.instance.getTable(tableId).getMatch().getPlayers()) { - if (p.getPlayer().getId() == userIdRequester) { + if (p.getPlayer().getId().equals(userIdRequester)) { Optional u = UserManager.instance.getUser(origId); if (u != null && u.isPresent() && p.getDeck() != null) { u.get().ccViewLimitedDeck(p.getDeck(), tableId, requestsOpen, true); diff --git a/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java b/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java index 6621fa8baa..02b7df4f4e 100644 --- a/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java +++ b/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java @@ -181,7 +181,7 @@ class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl { Card card = game.getCard(event.getTargetId()); if (card != null && watcher != null - && card.getOwnerId() == controller.getId()) { + && card.getOwnerId().equals(controller.getId())) { for (Ability ability : card.getAbilities()) { if (ability instanceof CyclingAbility) { cardHasCycling = true; @@ -224,8 +224,8 @@ class AbandonedSarcophagusWatcher extends Watcher { Card card = game.getCard(event.getSourceId()); Player controller = game.getPlayer(event.getPlayerId()); if (card != null - && controller != null - && card.getOwnerId() == controller.getId()) { + && controller != null + && card.getOwnerId().equals(controller.getId())) { Cards c = getCardsCycledThisTurn(event.getPlayerId()); c.add(card); cycledCardsThisTurn.put(event.getPlayerId(), c); diff --git a/Mage.Sets/src/mage/cards/a/AzoriusAEthermage.java b/Mage.Sets/src/mage/cards/a/AzoriusAEthermage.java index 26737e39b8..61be2614cf 100644 --- a/Mage.Sets/src/mage/cards/a/AzoriusAEthermage.java +++ b/Mage.Sets/src/mage/cards/a/AzoriusAEthermage.java @@ -115,7 +115,7 @@ class AzoriusAEthermageAbility extends TriggeredAbilityImpl { } if (permanentThatMoved != null && filter.match(permanentThatMoved, sourceId, controllerId, game) - && zEvent.getPlayerId() == controllerId) { //The controller's hand is where the permanent moved to. + && zEvent.getPlayerId().equals(controllerId)) { //The controller's hand is where the permanent moved to. return true; } } diff --git a/Mage.Sets/src/mage/cards/m/MenacingOgre.java b/Mage.Sets/src/mage/cards/m/MenacingOgre.java index 8b87182ea8..4997b1be68 100644 --- a/Mage.Sets/src/mage/cards/m/MenacingOgre.java +++ b/Mage.Sets/src/mage/cards/m/MenacingOgre.java @@ -27,6 +27,9 @@ */ package mage.cards.m; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -42,10 +45,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - /** * * @author jeffwadsworth @@ -123,7 +122,7 @@ class MenacingOgreEffect extends OneShotEffect { game.informPlayers(player.getLogName() + " chose number " + numberChosen.get(player)); if (numberChosen.get(player) >= highestNumber) { player.loseLife(highestNumber, game, false); - if (player.getId() == source.getControllerId() + if (player.getId().equals(source.getControllerId()) && menacingOgre != null) { menacingOgre.addCounters(CounterType.P1P1.createInstance(2), source, game); } diff --git a/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java b/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java index c148859118..58c4e52088 100644 --- a/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java +++ b/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java @@ -183,7 +183,7 @@ class SpellWasNotCastCondition implements Condition { List spells = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spells != null) { for (Spell spell : spells) { - if (spell.getSourceId() == cardId) { + if (spell.getSourceId().equals(cardId)) { return false; } } diff --git a/Mage.Sets/src/mage/cards/r/Reparations.java b/Mage.Sets/src/mage/cards/r/Reparations.java index d819dc92f2..6f3a66ee13 100644 --- a/Mage.Sets/src/mage/cards/r/Reparations.java +++ b/Mage.Sets/src/mage/cards/r/Reparations.java @@ -49,11 +49,10 @@ public class Reparations extends CardImpl { public Reparations(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{U}"); - // Whenever an opponent casts a spell that targets you or a creature you control, you may draw a card. this.addAbility(new ReparationsTriggeredAbility()); - + } public Reparations(final Reparations card) { @@ -96,12 +95,12 @@ class ReparationsTriggeredAbility extends TriggeredAbilityImpl { Player targetPlayer = game.getPlayer(stackObject.getStackAbility().getFirstTarget()); Permanent targetPermanent = game.getPermanent(stackObject.getStackAbility().getFirstTarget()); if (targetPlayer != null - && targetPlayer.getId() == controllerId) { + && targetPlayer.getId().equals(controllerId)) { return true; } if (targetPermanent != null && targetPermanent.isCreature() - && targetPermanent.getControllerId() == controllerId) { + && targetPermanent.getControllerId().equals(controllerId)) { return true; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/multiplayer/PlayerDiedStackTargetHandlingTest.java b/Mage.Tests/src/test/java/org/mage/test/multiplayer/PlayerDiedStackTargetHandlingTest.java index 8f240a2378..00c796abcb 100644 --- a/Mage.Tests/src/test/java/org/mage/test/multiplayer/PlayerDiedStackTargetHandlingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/multiplayer/PlayerDiedStackTargetHandlingTest.java @@ -58,7 +58,7 @@ public class PlayerDiedStackTargetHandlingTest extends CardTestMultiPlayerBase { execute(); assertGraveyardCount(playerA, "Lightning Helix", 2); - Assert.assertTrue("Active player has to be player C", currentGame.getActivePlayerId() == playerC.getId()); + Assert.assertTrue("Active player has to be player C", currentGame.getActivePlayerId().equals(playerC.getId())); assertLife(playerA, 6); @@ -93,7 +93,7 @@ public class PlayerDiedStackTargetHandlingTest extends CardTestMultiPlayerBase { assertPermanentCount(playerA, "Silvercoat Lion", 2); assertGraveyardCount(playerA, "Tendrils of Agony", 1); - Assert.assertTrue("Active player has to be player C", currentGame.getActivePlayerId() == playerC.getId()); + Assert.assertTrue("Active player has to be player C", currentGame.getActivePlayerId().equals(playerC.getId())); assertLife(playerA, 7); diff --git a/Mage/src/main/java/mage/abilities/common/AttacksAndIsNotBlockedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksAndIsNotBlockedTriggeredAbility.java index ba69791fe4..0998dd2a4c 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksAndIsNotBlockedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksAndIsNotBlockedTriggeredAbility.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.common; import mage.abilities.TriggeredAbilityImpl; @@ -33,14 +32,14 @@ import mage.abilities.effects.Effect; import mage.constants.Zone; import mage.game.Game; import mage.game.combat.CombatGroup; -import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; public class AttacksAndIsNotBlockedTriggeredAbility extends TriggeredAbilityImpl { - private boolean setTargetPointer; + private final boolean setTargetPointer; public AttacksAndIsNotBlockedTriggeredAbility(Effect effect) { this(effect, false, false); @@ -72,14 +71,12 @@ public class AttacksAndIsNotBlockedTriggeredAbility extends TriggeredAbilityImpl @Override public boolean checkTrigger(GameEvent event, Game game) { - Permanent sourcePermanent = game.getPermanent(getSourceId()); - if(sourcePermanent.isAttacking()) { - for(CombatGroup combatGroup: game.getCombat().getGroups()) { - if(combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(getSourceId())) { - if(setTargetPointer) { - for(Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(game.getCombat().getDefendingPlayerId(getSourceId(), game))); - } + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); + if (sourcePermanent != null && sourcePermanent.isAttacking()) { + for (CombatGroup combatGroup : game.getCombat().getGroups()) { + if (combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(getSourceId())) { + if (setTargetPointer) { + this.getEffects().setTargetPointer(new FixedTarget(game.getCombat().getDefendingPlayerId(getSourceId(), game))); } return true; } diff --git a/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java b/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java index cd246dd20a..64d8f1c012 100644 --- a/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java @@ -180,7 +180,7 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl { sourceId = sourceCard.getId(); } - if (event.getTargetId() == sourceId) { + if (event.getTargetId().equals(sourceId)) { // Moving this spell from stack to yard Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null && spell.getFromZone() == Zone.GRAVEYARD) {