Merge pull request #3896 from theelk801/master

a few small things
This commit is contained in:
theelk801 2017-08-28 21:46:31 -04:00 committed by GitHub
commit 4fd8cff41e
2 changed files with 22 additions and 21 deletions

View file

@ -33,7 +33,7 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
@ -48,8 +48,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.util.CardUtil;
import org.apache.log4j.Logger;
/** /**
* *
@ -58,13 +58,13 @@ import mage.target.TargetPermanent;
public class DetentionSphere extends CardImpl { public class DetentionSphere extends CardImpl {
static final protected FilterPermanent filter = new FilterNonlandPermanent("nonland permanent not named Detention Sphere"); static final protected FilterPermanent filter = new FilterNonlandPermanent("nonland permanent not named Detention Sphere");
static { static {
filter.add(Predicates.not(new NamePredicate("Detention Sphere"))); filter.add(Predicates.not(new NamePredicate("Detention Sphere")));
} }
public DetentionSphere(UUID ownerId, CardSetInfo setInfo) { public DetentionSphere(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{U}");
// When Detention Sphere enters the battlefield, you may exile // When Detention Sphere enters the battlefield, you may exile
// target nonland permanent not named Detention Sphere and all // target nonland permanent not named Detention Sphere and all
@ -73,7 +73,6 @@ public class DetentionSphere extends CardImpl {
ability.addTarget(new TargetPermanent(filter)); ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability); this.addAbility(ability);
// When Detention Sphere leaves the battlefield, return the exiled // When Detention Sphere leaves the battlefield, return the exiled
// cards to the battlefield under their owner's control. // cards to the battlefield under their owner's control.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new DetentionSphereLeavesEffect(), false)); this.addAbility(new LeavesBattlefieldTriggeredAbility(new DetentionSphereLeavesEffect(), false));
@ -91,7 +90,6 @@ public class DetentionSphere extends CardImpl {
class DetentionSphereEntersEffect extends OneShotEffect { class DetentionSphereEntersEffect extends OneShotEffect {
public DetentionSphereEntersEffect() { public DetentionSphereEntersEffect() {
super(Outcome.Exile); super(Outcome.Exile);
staticText = "you may exile target nonland permanent not named Detention Sphere and all other permanents with the same name as that permanent"; staticText = "you may exile target nonland permanent not named Detention Sphere and all other permanents with the same name as that permanent";
@ -103,7 +101,7 @@ class DetentionSphereEntersEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
UUID exileId = source.getSourceId(); UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
@ -143,15 +141,18 @@ class DetentionSphereLeavesEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
UUID exileId = source.getSourceId(); Player controller = game.getPlayer(source.getControllerId());
ExileZone exile = game.getExile().getExileZone(exileId); MageObject sourceObject = source.getSourceObject(game);
if (exile != null) { if (sourceObject != null && controller != null) {
exile = exile.copy(); Permanent permanentLeftBattlefield = (Permanent) getValue("permanentLeftBattlefield");
for (UUID cardId : exile) { if (permanentLeftBattlefield == null) {
Card card = game.getCard(cardId); Logger.getLogger(ReturnFromExileForSourceEffect.class).error("Permanent not found: " + sourceObject.getName());
card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId()); return false;
}
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanentLeftBattlefield.getZoneChangeCounter(game)));
if (exile != null) {
controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
} }
game.getExile().getExileZone(exileId).clear();
return true; return true;
} }
return false; return false;
@ -161,4 +162,4 @@ class DetentionSphereLeavesEffect extends OneShotEffect {
public DetentionSphereLeavesEffect copy() { public DetentionSphereLeavesEffect copy() {
return new DetentionSphereLeavesEffect(this); return new DetentionSphereLeavesEffect(this);
} }
} }

View file

@ -68,11 +68,11 @@ public class PortalMage extends CardImpl {
// Flash // Flash
this.addAbility(FlashAbility.getInstance()); this.addAbility(FlashAbility.getInstance());
// If Portal Mage enters the battlefield during the declare attackers step, you may reselect the player or planeswalker that the target attacking creature attacks. // When Portal Mage enters the battlefield during the declare attackers step, you may reselect which player or planeswalker target attacking creature is attacking.
Ability ability = new ConditionalTriggeredAbility( Ability ability = new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new PortalMageEffect(), true), new EntersBattlefieldTriggeredAbility(new PortalMageEffect(), true),
new IsStepCondition(PhaseStep.DECLARE_ATTACKERS, false), new IsStepCondition(PhaseStep.DECLARE_ATTACKERS, false),
"If {this} enters the battlefield during the declare attackers step, you may reselect the player or planeswalker that the target attacking creature attacks. " "When {this} enters the battlefield during the declare attackers step, you may reselect which player or planeswalker target attacking creature is attacking. "
+ "<i>(It can't attack its controller or its controller's planeswalkers.)</i>"); + "<i>(It can't attack its controller or its controller's planeswalkers.)</i>");
ability.addTarget(new TargetCreaturePermanent(new FilterAttackingCreature())); ability.addTarget(new TargetCreaturePermanent(new FilterAttackingCreature()));
this.addAbility(ability); this.addAbility(ability);
@ -92,7 +92,7 @@ class PortalMageEffect extends OneShotEffect {
public PortalMageEffect() { public PortalMageEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "you may reselect the player or planeswalker that the target attacking creature attacks"; this.staticText = "you may reselect which player or planeswalker target attacking creature is attacking";
} }
public PortalMageEffect(final PortalMageEffect effect) { public PortalMageEffect(final PortalMageEffect effect) {
@ -147,7 +147,7 @@ class PortalMageEffect extends OneShotEffect {
attacked = permanent.getLogName(); attacked = permanent.getLogName();
} }
} }
game.informPlayers(attackingCreature.getLogName() + " attacks now " + attacked); game.informPlayers(attackingCreature.getLogName() + " now attacks " + attacked);
return true; return true;
} }
} }