Fixed Vision Charm second ability.  Rule 611.2c.
*/
package mage.cards.v;
+import java.util.Iterator;
import java.util.UUID;
+import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
@@ -66,7 +68,6 @@ public class VisionCharm extends CardImpl {
public VisionCharm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}");
-
// Choose one - Target player puts the top four cards of his or her library into his or her graveyard;
this.getSpellAbility().addEffect(new PutLibraryIntoGraveTargetEffect(4));
this.getSpellAbility().addTarget(new TargetPlayer());
@@ -94,6 +95,7 @@ public class VisionCharm extends CardImpl {
}
class VisionCharmEffect extends ContinuousEffectImpl {
+
private String targetLandType;
private String targetBasicLandType;
@@ -113,33 +115,40 @@ class VisionCharmEffect extends ContinuousEffectImpl {
@Override
public void init(Ability source, Game game) {
+ super.init(source, game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceLandType();
controller.choose(outcome, choice, game);
targetLandType = choice.getChoice();
-
choice = new ChoiceBasicLandType();
controller.choose(outcome, choice, game);
targetBasicLandType = choice.getChoice();
- }
- else {
+ } else {
this.discard();
}
+ FilterPermanent filter = new FilterLandPermanent();
+ filter.add(new SubtypePredicate(targetLandType));
+ if (this.affectedObjectsSet) {
+ for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
+ affectedObjectList.add(new MageObjectReference(permanent, game));
+ }
+ }
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
- FilterPermanent filter = new FilterLandPermanent();
- filter.add(new SubtypePredicate(targetLandType));
- for (Permanent land : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
- //Remove all existing subtypes and replace them with the selected Basic Land Type
- land.getSubtype(game).removeAll(land.getSubtype(game));
+ for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
+ Permanent land = it.next().getPermanent(game);
+ if (land != null) {
+ switch (layer) {
+ case TypeChangingEffects_4:
+ land.getSubtype(game).clear();
land.getSubtype(game).add(targetBasicLandType);
-
- /* Remove the existing abilities and replace them with the ability
- of the chosen basic land */
- land.removeAllAbilities(source.getId(), game);
+ break;
+ case AbilityAddingRemovingEffects_6:
+ if (sublayer == SubLayer.NA) {
+ land.getAbilities().clear();
switch (targetBasicLandType) {
case "Swamp":
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
@@ -158,6 +167,11 @@ class VisionCharmEffect extends ContinuousEffectImpl {
break;
}
}
+ }
+ } else {
+ it.remove();
+ }
+ }
return true;
}
