Fixed cards with "Spells and abilities your opponents control can't cause you to sacrifice permanents".

This commit is contained in:
jeffwadsworth 2019-11-22 15:41:19 -06:00
parent db9bdfdd5c
commit 5c15400f02
3 changed files with 118 additions and 38 deletions

View file

@ -1,10 +1,10 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
@ -14,10 +14,13 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard; import mage.game.permanent.PermanentCard;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.game.stack.StackAbility; import mage.game.stack.StackAbility;
import mage.players.Player;
/** /**
* @author noxx * @author noxx
@ -72,8 +75,11 @@ class SigardaHostOfHeronsEffect extends ContinuousRuleModifyingEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(source.getControllerId())) { Player controller = game.getPlayer(source.getControllerId());
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
Permanent permanent = game.getPermanent(event.getTargetId());
if (controller != null
&& permanent.getControllerId() == source.getControllerId()) {
if (object instanceof PermanentCard) { if (object instanceof PermanentCard) {
if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) {
return true; return true;
@ -84,8 +90,18 @@ class SigardaHostOfHeronsEffect extends ContinuousRuleModifyingEffectImpl {
return true; return true;
} }
} }
if (object instanceof Card) { if (object instanceof Emblem) {
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) { if (game.getOpponents(source.getControllerId()).contains(((Emblem) object).getControllerId())) {
return true;
}
}
if (object instanceof Ability) {
if (game.getOpponents(source.getControllerId()).contains(((Ability) object).getControllerId())) {
return true;
}
}
if (object instanceof SpellAbility) {
if (game.getOpponents(source.getControllerId()).contains(((SpellAbility) object).getControllerId())) {
return true; return true;
} }
} }
@ -94,6 +110,11 @@ class SigardaHostOfHeronsEffect extends ContinuousRuleModifyingEffectImpl {
return true; return true;
} }
} }
if (object instanceof Card) {
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
return true;
}
}
} }
return false; return false;
} }

View file

@ -1,20 +1,24 @@
package mage.cards.t; package mage.cards.t;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard; import mage.game.permanent.PermanentCard;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.game.stack.StackAbility;
import mage.players.Player;
/** /**
* @author noxx * @author noxx
@ -71,9 +75,11 @@ class TajuruPreserverEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId()); Player controller = game.getPlayer(source.getControllerId());
if (permanent != null && permanent.isControlledBy(source.getControllerId())) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
Permanent permanent = game.getPermanent(event.getTargetId());
if (controller != null
&& permanent.getControllerId() == source.getControllerId()) {
if (object instanceof PermanentCard) { if (object instanceof PermanentCard) {
if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) {
return true; return true;
@ -84,6 +90,31 @@ class TajuruPreserverEffect extends ReplacementEffectImpl {
return true; return true;
} }
} }
if (object instanceof Emblem) {
if (game.getOpponents(source.getControllerId()).contains(((Emblem) object).getControllerId())) {
return true;
}
}
if (object instanceof Ability) {
if (game.getOpponents(source.getControllerId()).contains(((Ability) object).getControllerId())) {
return true;
}
}
if (object instanceof SpellAbility) {
if (game.getOpponents(source.getControllerId()).contains(((SpellAbility) object).getControllerId())) {
return true;
}
}
if (object instanceof StackAbility) {
if (game.getOpponents(source.getControllerId()).contains(((StackAbility) object).getControllerId())) {
return true;
}
}
if (object instanceof Card) {
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
return true;
}
}
} }
return false; return false;
} }

View file

@ -22,8 +22,11 @@ import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID; import java.util.UUID;
import mage.abilities.SpellAbility;
import static mage.constants.Outcome.Benefit; import static mage.constants.Outcome.Benefit;
import mage.game.command.Emblem;
import mage.game.permanent.Permanent;
/** /**
* @author TheElk801 * @author TheElk801
@ -63,8 +66,8 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
TamiyoCollectorOfTalesRuleEffect() { TamiyoCollectorOfTalesRuleEffect() {
super(Duration.WhileOnBattlefield, Benefit); super(Duration.WhileOnBattlefield, Benefit);
staticText = "Spells and abilities your opponents control can't " + staticText = "Spells and abilities your opponents control can't "
"cause you to discard cards or sacrifice permanents"; + "cause you to discard cards or sacrifice permanents";
} }
private TamiyoCollectorOfTalesRuleEffect(final TamiyoCollectorOfTalesRuleEffect effect) { private TamiyoCollectorOfTalesRuleEffect(final TamiyoCollectorOfTalesRuleEffect effect) {
@ -84,8 +87,16 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(source.getControllerId())) { Player controller = game.getPlayer(source.getControllerId());
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
Permanent permanent = game.getPermanent(event.getTargetId());
Card cardInHand = game.getCard(event.getTargetId());
if (controller != null) {
if (permanent != null
&& permanent.getControllerId() == source.getControllerId()
|| cardInHand != null
&& cardInHand.getOwnerId() == source.getControllerId()) {
if (object instanceof PermanentCard) { if (object instanceof PermanentCard) {
if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) {
return true; return true;
@ -96,8 +107,18 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
return true; return true;
} }
} }
if (object instanceof Card) { if (object instanceof Emblem) {
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) { if (game.getOpponents(source.getControllerId()).contains(((Emblem) object).getControllerId())) {
return true;
}
}
if (object instanceof Ability) {
if (game.getOpponents(source.getControllerId()).contains(((Ability) object).getControllerId())) {
return true;
}
}
if (object instanceof SpellAbility) {
if (game.getOpponents(source.getControllerId()).contains(((SpellAbility) object).getControllerId())) {
return true; return true;
} }
} }
@ -106,6 +127,12 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
return true; return true;
} }
} }
if (object instanceof Card) {
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
return true;
}
}
}
} }
return false; return false;
} }
@ -115,8 +142,8 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
TamiyoCollectorOfTalesEffect() { TamiyoCollectorOfTalesEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
staticText = "Choose a nonland card name, then reveal the top four cards of your library. " + staticText = "Choose a nonland card name, then reveal the top four cards of your library. "
"Put all cards with the chosen name from among them into your hand and the rest into your graveyard."; + "Put all cards with the chosen name from among them into your hand and the rest into your graveyard.";
} }
private TamiyoCollectorOfTalesEffect(final TamiyoCollectorOfTalesEffect effect) { private TamiyoCollectorOfTalesEffect(final TamiyoCollectorOfTalesEffect effect) {
@ -146,8 +173,8 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
player.revealCards(source, cards, game); player.revealCards(source, cards, game);
for (Card card : cards.getCards(game)) { for (Card card : cards.getCards(game)) {
if (card.isSplitCard()) { if (card.isSplitCard()) {
if(((SplitCard) card).getLeftHalfCard().getName().equals(choice.getChoice()) || if (((SplitCard) card).getLeftHalfCard().getName().equals(choice.getChoice())
((SplitCard) card).getRightHalfCard().getName().equals(choice.getChoice())){ || ((SplitCard) card).getRightHalfCard().getName().equals(choice.getChoice())) {
cards2.add(card); cards2.add(card);
} }
} }
@ -160,4 +187,5 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
player.moveCards(cards2, Zone.HAND, source, game); player.moveCards(cards2, Zone.HAND, source, game);
return true; return true;
} }
} }