mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
fixed Blatant Thievery test failure
This commit is contained in:
parent
8699b847d8
commit
734bd6f118
4 changed files with 121 additions and 38 deletions
|
@ -1,20 +1,29 @@
|
|||
package mage.cards.b;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
import mage.target.targetpointer.FixedTargets;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author emerald000
|
||||
|
@ -25,8 +34,7 @@ public final class BlatantThievery extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}{U}");
|
||||
|
||||
// For each opponent, gain control of target permanent that player controls.
|
||||
this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfGame)
|
||||
.setText("for each opponent, gain control of target permanent that player controls"));
|
||||
this.getSpellAbility().addEffect(new BlatantThieveryEffect());
|
||||
this.getSpellAbility().setTargetAdjuster(BlatantThieveryAdjuster.instance);
|
||||
}
|
||||
|
||||
|
@ -61,3 +69,35 @@ enum BlatantThieveryAdjuster implements TargetAdjuster {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BlatantThieveryEffect extends OneShotEffect {
|
||||
|
||||
BlatantThieveryEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "for each opponent, gain control of target permanent that player controls";
|
||||
}
|
||||
|
||||
private BlatantThieveryEffect(final BlatantThieveryEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlatantThieveryEffect copy() {
|
||||
return new BlatantThieveryEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> permanents = source
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(Target::getTargets)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
game.addEffect(new GainControlTargetEffect(Duration.Custom, true)
|
||||
.setTargetPointer(new FixedTargets(permanents, game)), source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,31 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
import mage.target.targetpointer.FixedTargets;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
@ -27,10 +36,7 @@ public final class TemptedByTheOriq extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{U}{U}{U}");
|
||||
|
||||
// For each opponent, gain control of up to one target creature or planeswalker that player controls with mana value 3 or less.
|
||||
this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfGame).setText(
|
||||
"for each opponent, gain control of up to one target creature or planeswalker " +
|
||||
"that player controls with mana value 3 or less"
|
||||
));
|
||||
this.getSpellAbility().addEffect(new TemptedByTheOriqEffect());
|
||||
this.getSpellAbility().setTargetAdjuster(TemptedByTheOriqAdjuster.instance);
|
||||
}
|
||||
|
||||
|
@ -64,3 +70,36 @@ enum TemptedByTheOriqAdjuster implements TargetAdjuster {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TemptedByTheOriqEffect extends OneShotEffect {
|
||||
|
||||
TemptedByTheOriqEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "for each opponent, gain control of up to one target creature " +
|
||||
"or planeswalker that player controls with mana value 3 or less";
|
||||
}
|
||||
|
||||
private TemptedByTheOriqEffect(final TemptedByTheOriqEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemptedByTheOriqEffect copy() {
|
||||
return new TemptedByTheOriqEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> permanents = source
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(Target::getTargets)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
game.addEffect(new GainControlTargetEffect(Duration.Custom, true)
|
||||
.setTargetPointer(new FixedTargets(permanents, game)), source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,10 @@ public class BlatantThieveryTest extends CardTestMultiPlayerBase {
|
|||
addTarget(playerA, "Walking Corpse");
|
||||
addTarget(playerA, "Pillarfield Ox");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Blatant Thievery", 1);
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
|
@ -79,6 +81,7 @@ public class BlatantThieveryTest extends CardTestMultiPlayerBase {
|
|||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Blatant Thievery", 1);
|
||||
assertGraveyardCount(playerB, "Act of Aggression", 1);
|
||||
|
|
|
@ -9,7 +9,6 @@ import mage.constants.Layer;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
|
@ -76,13 +75,20 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (controller == null) {
|
||||
discard(); // controller no longer exists
|
||||
return false;
|
||||
}
|
||||
boolean oneTargetStillExists = false;
|
||||
for (UUID permanentId : getTargetPointer().getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
if (permanent == null) {
|
||||
continue;
|
||||
}
|
||||
oneTargetStillExists = true;
|
||||
if (!permanent.isControlledBy(controllingPlayerId)) {
|
||||
if (permanent.isControlledBy(controllingPlayerId)) {
|
||||
continue;
|
||||
}
|
||||
boolean controlChanged = false;
|
||||
if (controllingPlayerId != null) {
|
||||
if (permanent.changeControllerId(controllingPlayerId, game, source)) {
|
||||
|
@ -101,8 +107,6 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
|||
discard();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// no valid target exists and the controller is no longer in the game, effect can be discarded
|
||||
if (!oneTargetStillExists || !controller.isInGame()) {
|
||||
discard();
|
||||
|
@ -110,9 +114,6 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
|||
firstControlChange = false;
|
||||
return true;
|
||||
}
|
||||
discard(); // controller no longer exists
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
|
|
Loading…
Reference in a new issue