- Fixed Elsewhere Flask and Terraformer. Rule 611.2c.

This commit is contained in:
Jeff 2017-03-13 11:57:39 -05:00
parent a5628dcf5b
commit 4b3389b8cc
2 changed files with 39 additions and 9 deletions

View file

@ -27,7 +27,9 @@
*/ */
package mage.cards.e; package mage.cards.e;
import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -63,7 +65,7 @@ import mage.players.Player;
public class ElsewhereFlask extends CardImpl { public class ElsewhereFlask extends CardImpl {
public ElsewhereFlask(UUID ownerId, CardSetInfo setInfo) { public ElsewhereFlask(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// When Elsewhere Flask enters the battlefield, draw a card. // When Elsewhere Flask enters the battlefield, draw a card.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)));
@ -130,11 +132,22 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl {
return new ElsewhereFlaskContinuousEffect(this); return new ElsewhereFlaskContinuousEffect(this);
} }
@Override
public void init(Ability source, Game game) {
super.init(source, game);
if (this.affectedObjectsSet) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}
@Override @Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_ElsewhereFlask"); String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_ElsewhereFlask");
if (choice != null) { if (choice != null) {
for (Permanent land : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent land = it.next().getPermanent(game);
if (land != null) { if (land != null) {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
@ -164,6 +177,8 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl {
} }
break; break;
} }
} else {
it.remove();
} }
} }
return true; return true;

View file

@ -27,8 +27,10 @@
*/ */
package mage.cards.t; package mage.cards.t;
import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
@ -62,7 +64,7 @@ import mage.players.Player;
public class Terraformer extends CardImpl { public class Terraformer extends CardImpl {
public Terraformer(UUID ownerId, CardSetInfo setInfo) { public Terraformer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
this.subtype.add("Human"); this.subtype.add("Human");
this.subtype.add("Wizard"); this.subtype.add("Wizard");
this.power = new MageInt(2); this.power = new MageInt(2);
@ -83,21 +85,21 @@ public class Terraformer extends CardImpl {
} }
class TerraformerEffect extends OneShotEffect { class TerraformerEffect extends OneShotEffect {
TerraformerEffect() { TerraformerEffect() {
super(Outcome.Neutral); super(Outcome.Neutral);
this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn"; this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn";
} }
TerraformerEffect(final TerraformerEffect effect) { TerraformerEffect(final TerraformerEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public TerraformerEffect copy() { public TerraformerEffect copy() {
return new TerraformerEffect(this); return new TerraformerEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
@ -130,11 +132,22 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl {
return new TerraformerContinuousEffect(this); return new TerraformerContinuousEffect(this);
} }
@Override
public void init(Ability source, Game game) {
super.init(source, game);
if (this.affectedObjectsSet) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}
@Override @Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_Terraformer"); String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_Terraformer");
if (choice != null) { if (choice != null) {
for (Permanent land : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent land = it.next().getPermanent(game);
if (land != null) { if (land != null) {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
@ -164,13 +177,15 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl {
} }
break; break;
} }
} else {
it.remove();
} }
} }
return true; return true;
} }
return false; return false;
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return false; return false;