* Soulfire Grand Master - Fixed that a countered spell did wrongly return to hand if second ability was used.

This commit is contained in:
LevelX2 2015-04-18 11:53:51 +02:00
parent 2d3c98a7b4
commit 47b1753519
5 changed files with 102 additions and 37 deletions

View file

@ -89,27 +89,26 @@ class CurseOfInertiaTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfInertiaTriggeredAbility() {
super(Zone.BATTLEFIELD, new CurseOfInertiaTapOrUntapTargetEffect(), false);
}
public CurseOfInertiaTriggeredAbility(Effect effect, boolean optional, String text) {
super(Zone.BATTLEFIELD, effect, optional);
}
public CurseOfInertiaTriggeredAbility(final CurseOfInertiaTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType().equals(EventType.DECLARED_ATTACKERS);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType().equals(EventType.DECLARED_ATTACKERS)) {
Permanent enchantment = game.getPermanent(this.getSourceId());
if (enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (Effect effect: this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId()));
}
return true;
}
Permanent enchantment = game.getPermanent(this.getSourceId());
if (enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
TargetPermanent target = new TargetPermanent();
target.setTargetController(game.getCombat().getAttackerId());
addTarget(target);
return true;
}
return false;
}
@ -138,24 +137,20 @@ class CurseOfInertiaTapOrUntapTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Player player = game.getPlayer(source.getTargets().get(0).getTargetController());
if (player != null) {
Target target = new TargetPermanent();
if (target.canChoose(source.getSourceId(), player.getId(), game)
&& player.choose(outcome, target, source.getSourceId(), game)) {
Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
if (targetPermanent != null) {
if (targetPermanent.isTapped()) {
if (player.chooseUse(Outcome.Untap, "Untap that permanent?", game)) {
targetPermanent.untap(game);
}
} else {
if (player.chooseUse(Outcome.Tap, "Tap that permanent?", game)) {
targetPermanent.tap(game);
}
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetPermanent != null) {
if (targetPermanent.isTapped()) {
if (player.chooseUse(Outcome.Untap, "Untap that permanent?", game)) {
targetPermanent.untap(game);
}
} else {
if (player.chooseUse(Outcome.Tap, "Tap that permanent?", game)) {
targetPermanent.tap(game);
}
return true;
}
return true;
}
}
return false;

View file

@ -48,14 +48,12 @@ import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.TargetController;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.FilterObject;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
@ -230,7 +228,10 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
if (zEvent.getFromZone() == Zone.STACK &&
zEvent.getToZone() == Zone.GRAVEYARD &&
event.getTargetId().equals(spellId)) {
return true;
Spell spell = game.getStack().getSpell(spellId);
if (spell != null && !spell.isCountered()) {
return true;
}
}
}
return false;