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

View file

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

View file

@ -22,8 +22,11 @@ import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
import mage.abilities.SpellAbility;
import static mage.constants.Outcome.Benefit;
import mage.game.command.Emblem;
import mage.game.permanent.Permanent;
/**
* @author TheElk801
@ -63,8 +66,8 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
TamiyoCollectorOfTalesRuleEffect() {
super(Duration.WhileOnBattlefield, Benefit);
staticText = "Spells and abilities your opponents control can't " +
"cause you to discard cards or sacrifice permanents";
staticText = "Spells and abilities your opponents control can't "
+ "cause you to discard cards or sacrifice permanents";
}
private TamiyoCollectorOfTalesRuleEffect(final TamiyoCollectorOfTalesRuleEffect effect) {
@ -84,8 +87,16 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
@Override
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());
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 (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) {
return true;
@ -96,8 +107,18 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
return true;
}
}
if (object instanceof Card) {
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
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;
}
}
@ -106,6 +127,12 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
return true;
}
}
if (object instanceof Card) {
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
return true;
}
}
}
}
return false;
}
@ -115,8 +142,8 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
TamiyoCollectorOfTalesEffect() {
super(Outcome.Benefit);
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.";
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.";
}
private TamiyoCollectorOfTalesEffect(final TamiyoCollectorOfTalesEffect effect) {
@ -146,8 +173,8 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
player.revealCards(source, cards, game);
for (Card card : cards.getCards(game)) {
if (card.isSplitCard()) {
if(((SplitCard) card).getLeftHalfCard().getName().equals(choice.getChoice()) ||
((SplitCard) card).getRightHalfCard().getName().equals(choice.getChoice())){
if (((SplitCard) card).getLeftHalfCard().getName().equals(choice.getChoice())
|| ((SplitCard) card).getRightHalfCard().getName().equals(choice.getChoice())) {
cards2.add(card);
}
}
@ -160,4 +187,5 @@ class TamiyoCollectorOfTalesEffect extends OneShotEffect {
player.moveCards(cards2, Zone.HAND, source, game);
return true;
}
}