* Gilt-Leaf Archdruid - Fixed that control handling was wrong (fixes #4596).

This commit is contained in:
LevelX2 2018-03-10 20:11:39 +01:00
parent dac8f2dfe8
commit 0077484c3e

View file

@ -30,12 +30,13 @@ package mage.cards.g;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.TapTargetCost; import mage.abilities.costs.common.TapTargetCost;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
@ -48,6 +49,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -62,7 +64,7 @@ public class GiltLeafArchdruid extends CardImpl {
} }
public GiltLeafArchdruid(UUID ownerId, CardSetInfo setInfo) { public GiltLeafArchdruid(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
this.subtype.add(SubType.ELF); this.subtype.add(SubType.ELF);
this.subtype.add(SubType.DRUID); this.subtype.add(SubType.DRUID);
@ -73,7 +75,7 @@ public class GiltLeafArchdruid extends CardImpl {
this.addAbility(new SpellCastControllerTriggeredAbility(new DrawCardSourceControllerEffect(1), filterSpell, true)); this.addAbility(new SpellCastControllerTriggeredAbility(new DrawCardSourceControllerEffect(1), filterSpell, true));
// Tap seven untapped Druids you control: Gain control of all lands target player controls. // Tap seven untapped Druids you control: Gain control of all lands target player controls.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlAllLandsEffect(Duration.EndOfGame), new TapTargetCost(new TargetControlledCreaturePermanent(7, 7, new FilterControlledCreaturePermanent(SubType.DRUID, "Druids you control"), true))); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GiltLeafArchdruidEffect(), new TapTargetCost(new TargetControlledCreaturePermanent(7, 7, new FilterControlledCreaturePermanent(SubType.DRUID, "Druids you control"), true)));
ability.addTarget(new TargetPlayer()); ability.addTarget(new TargetPlayer());
this.addAbility(ability); this.addAbility(ability);
} }
@ -88,38 +90,36 @@ public class GiltLeafArchdruid extends CardImpl {
} }
} }
class GainControlAllLandsEffect extends ContinuousEffectImpl { class GiltLeafArchdruidEffect extends OneShotEffect {
public GainControlAllLandsEffect(Duration duration) { public GiltLeafArchdruidEffect() {
super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); super(Outcome.GainControl);
this.staticText = "gain control of all lands target player controls";
} }
public GainControlAllLandsEffect(final GainControlAllLandsEffect effect) { public GiltLeafArchdruidEffect(final GiltLeafArchdruidEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public GainControlAllLandsEffect copy() { public GiltLeafArchdruidEffect copy() {
return new GainControlAllLandsEffect(this); return new GiltLeafArchdruidEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null && targetPlayer.isInGame()) { if (controller != null && targetPlayer != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LANDS, targetPointer.getFirst(game, source), game)) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LANDS, targetPlayer.getId(), game)) {
if (permanent != null) { if (permanent != null) {
permanent.changeControllerId(source.getControllerId(), game); ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
} }
} }
} else {
discard();
}
return true; return true;
} }
return false;
@Override
public String getText(Mode mode) {
return "Gain control of all lands target player controls";
} }
} }