Skip to content
Permalink
Browse files
* Fixed Mid's Dilation bugs (fixes #2077).
  • Loading branch information
LevelX2 committed Jul 14, 2016
1 parent 4d0cfb3 commit 4bdc4936f0504a73625f2bb0d4f45174d1613418
@@ -32,15 +32,11 @@
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
@@ -64,8 +60,7 @@ public MindsDilation(UUID ownerId) {

// Whenever an opponent casts his or her first spell each turn, that player exiles the top card of his or her library. If it's a nonland card,
// you may cast it without paying its mana cost.
Ability ability = new MindsDilationTriggeredAbility(new MindsDilationEffect(), false);
this.addAbility(ability, new SpellsCastWatcher());
this.addAbility(new MindsDilationTriggeredAbility(new MindsDilationEffect(), false), new SpellsCastWatcher());
}

public MindsDilation(final MindsDilation card) {
@@ -113,15 +108,15 @@ public boolean checkTrigger(GameEvent event, Game game) {
@Override
public String getRule() {
return "Whenever an opponent casts his or her first spell each turn, that player exiles the top card of his or her library."
+ " If it's a nonland card, you may cast it without paying its mana cost";
+ " If it's a nonland card, you may cast it without paying its mana cost.";
}
}

class MindsDilationEffect extends OneShotEffect {

MindsDilationEffect() {
super(Outcome.Benefit);
this.staticText = "that player exiles the top card of his or her library. If it's a nonland card, you may cast it without paying its mana cost.";
this.staticText = "that player exiles the top card of his or her library. If it's a nonland card, you may cast it without paying its mana cost";
}

MindsDilationEffect(final MindsDilationEffect effect) {
@@ -140,54 +135,17 @@ public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && sourceObject != null && opponent != null) {
if (opponent.getLibrary().size() > 0) {
Card card = opponent.getLibrary().removeFromTop(game);
if (card != null) {
opponent.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
ContinuousEffect effect = new MindsDilationCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
Card card = opponent.getLibrary().getFromTop(game);
if (card != null && opponent.moveCards(card, Zone.EXILED, source, game)) {
if (!card.getCardType().contains(CardType.LAND)) {
if (controller.chooseUse(outcome, "Cast " + card.getLogName() + " without paying its mana cost from exile?", source, game)) {
controller.cast(card.getSpellAbility(), game, true);
}
}
}
}
return true;
}
return false;
}
}

class MindsDilationCastFromExileEffect extends AsThoughEffectImpl {

MindsDilationCastFromExileEffect() {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
staticText = "If it's a nonland card, you may cast it without paying its mana cost";
}

MindsDilationCastFromExileEffect(final MindsDilationCastFromExileEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public MindsDilationCastFromExileEffect copy() {
return new MindsDilationCastFromExileEffect(this);
}

@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
UUID targetId = getTargetPointer().getFirst(game, source);
Player controller = game.getPlayer(source.getControllerId());
if (targetId != null && controller != null) {
Card card = game.getCard(targetId);
if (card != null && !card.getCardType().contains(CardType.LAND) && game.getState().getZone(targetId) == Zone.EXILED) {
if (controller.chooseUse(outcome, "Cast " + card.getLogName() + "?", source, game)) {
controller.cast(card.getSpellAbility(), game, true);
}
return true;
}
}
return false;
}
}
@@ -50,8 +50,8 @@
protected Token token;
protected String type;
protected boolean losePreviousTypes;
protected DynamicValue power;
protected DynamicValue toughness;
protected DynamicValue power = null;
protected DynamicValue toughness = null;

public BecomesCreatureSourceEffect(Token token, String type, Duration duration) {
this(token, type, duration, false, false);
@@ -77,8 +77,12 @@ public BecomesCreatureSourceEffect(final BecomesCreatureSourceEffect effect) {
this.token = effect.token.copy();
this.type = effect.type;
this.losePreviousTypes = effect.losePreviousTypes;
this.power = effect.power.copy();
this.toughness = effect.toughness.copy();
if (effect.power != null) {
this.power = effect.power.copy();
}
if (effect.toughness != null) {
this.toughness = effect.toughness.copy();
}
}

@Override
@@ -32,6 +32,7 @@ public SpellsCastWatcher() {

public SpellsCastWatcher(final SpellsCastWatcher watcher) {
super(watcher);
this.spellsCast.putAll(watcher.spellsCast);
}

@Override

0 comments on commit 4bdc493

Please sign in to comment.