* Chaos Warp - Some minor changes to implementation.

This commit is contained in:
LevelX2 2014-08-18 11:13:36 +02:00
parent 7865137eea
commit ea62f1dd3b

View file

@ -28,6 +28,7 @@
package mage.sets.vintagemasters; package mage.sets.vintagemasters;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
@ -94,10 +95,11 @@ class ChaosWarpShuffleIntoLibraryEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
Player owner = game.getPlayer(permanent.getOwnerId()); if (permanent != null) {
if (permanent != null && owner != null) { Player owner = game.getPlayer(permanent.getOwnerId());
if (owner.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, true)) { if (owner != null) {
owner.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, true);
owner.shuffleLibrary(game); owner.shuffleLibrary(game);
return true; return true;
} }
@ -125,24 +127,26 @@ public ChaosWarpRevealEffect() {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
if (permanent == null) {
return false;
}
Player owner = game.getPlayer(permanent.getOwnerId()); Player owner = game.getPlayer(permanent.getOwnerId());
if (owner == null) { MageObject sourceObject = game.getObject(source.getSourceId());
if (owner == null || sourceObject == null) {
return false; return false;
} }
if (owner.getLibrary().size() > 0) { if (owner.getLibrary().size() > 0) {
Card card = owner.getLibrary().getFromTop(game); Card card = owner.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
owner.revealCards(card.getName(), cards, game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
owner.revealCards(sourceObject.getLogName(), cards, game);
if (new FilterPermanentCard().match(card, game)) { if (new FilterPermanentCard().match(card, game)) {
card = owner.getLibrary().removeFromTop(game); owner.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), owner.getId());
} }
} }
} }
return false; return true;
} }
} }