- 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;
import java.util.Iterator;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
@ -63,7 +65,7 @@ import mage.players.Player;
public class ElsewhereFlask extends CardImpl {
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.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)));
@ -130,11 +132,22 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl {
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
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_ElsewhereFlask");
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) {
switch (layer) {
case TypeChangingEffects_4:
@ -164,6 +177,8 @@ class ElsewhereFlaskContinuousEffect extends ContinuousEffectImpl {
}
break;
}
} else {
it.remove();
}
}
return true;

View file

@ -27,8 +27,10 @@
*/
package mage.cards.t;
import java.util.Iterator;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.GenericManaCost;
@ -62,7 +64,7 @@ import mage.players.Player;
public class Terraformer extends CardImpl {
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("Wizard");
this.power = new MageInt(2);
@ -83,21 +85,21 @@ public class Terraformer extends CardImpl {
}
class TerraformerEffect extends OneShotEffect {
TerraformerEffect() {
super(Outcome.Neutral);
this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn";
}
TerraformerEffect(final TerraformerEffect effect) {
super(effect);
}
@Override
public TerraformerEffect copy() {
return new TerraformerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
@ -130,11 +132,22 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl {
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
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_Terraformer");
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) {
switch (layer) {
case TypeChangingEffects_4:
@ -164,13 +177,15 @@ class TerraformerContinuousEffect extends ContinuousEffectImpl {
}
break;
}
} else {
it.remove();
}
}
return true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;