Fixed some cards where it was possible to sacrifice not controlled permanents (e.g. Fireblast).

This commit is contained in:
LevelX2 2015-02-26 16:48:21 +01:00
parent 4a5140d0ab
commit 705debfe8a
34 changed files with 206 additions and 337 deletions

View file

@ -36,9 +36,8 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.MonocoloredPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -91,12 +90,11 @@ class DefilerOfSoulsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("monocolored creature");
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("monocolored creature");
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player == null) {
return false;
}
filter.add(new ControllerPredicate(TargetController.YOU));
filter.add(new MonocoloredPredicate());
int amount;

View file

@ -37,7 +37,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterControlledArtifactPermanent;
import mage.target.common.TargetControlledPermanent;
/**
@ -50,12 +50,9 @@ public class TimeSieve extends CardImpl {
super(ownerId, 31, "Time Sieve", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{U}{B}");
this.expansionSetCode = "ARB";
// {tap}, Sacrifice five artifacts: Take an extra turn after this one.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddExtraTurnControllerEffect(), new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(5, 5, new FilterArtifactPermanent("five artifacts"), true)));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(5, 5, new FilterControlledArtifactPermanent("five artifacts"), true)));
this.addAbility(ability);
}

View file

@ -37,7 +37,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterPermanentCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.mageobject.SupertypePredicate;
@ -70,7 +70,7 @@ public class Lifespinner extends CardImpl {
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)),
new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(3, 3, new FilterCreaturePermanent("Spirit", "three Spirits"), false)));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(3, 3, new FilterControlledCreaturePermanent("Spirit", "three Spirits"), false)));
this.addAbility(ability);
}

View file

@ -34,7 +34,7 @@ import mage.abilities.keyword.SpliceOntoArcaneAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -44,7 +44,7 @@ import mage.target.common.TargetCreaturePermanent;
* @author LevelX2
*/
public class TorrentOfStone extends CardImpl {
private static final FilterLandPermanent filterSacrifice = new FilterLandPermanent("two Mountains");
private static final FilterControlledLandPermanent filterSacrifice = new FilterControlledLandPermanent("two Mountains");
static {
filterSacrifice.add(new SubtypePredicate("Mountain"));

View file

@ -32,13 +32,12 @@ import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -93,22 +92,24 @@ class FeastOfWormsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
Player targetPlayer = game.getPlayer(permanent.getControllerId());
if (targetPlayer != null && permanent != null && (permanent.getSupertype().get(0).toString().equals("Legendary"))) {
FilterPermanent filter = new FilterLandPermanent("land to sacrifice");
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);
Permanent permanent = game.getPermanentOrLKIBattlefield(id);
Player targetPlayer = null;
if (permanent != null) {
targetPlayer = game.getPlayer(permanent.getControllerId());
}
if (targetPlayer != null && permanent != null && (permanent.getSupertype().get(0).equals("Legendary"))) {
FilterControlledPermanent filter = new FilterControlledLandPermanent("land to sacrifice");
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);
if (target.canChoose(targetPlayer.getId(), game)) {
targetPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent land = game.getPermanent(target.getFirstTarget());
if (land != null) {
return land.sacrifice(source.getSourceId(), game);
}
return true;
if (target.canChoose(targetPlayer.getId(), game)) {
targetPlayer.chooseTarget(Outcome.Sacrifice, target, source, game);
Permanent land = game.getPermanent(target.getFirstTarget());
if (land != null) {
land.sacrifice(source.getSourceId(), game);
}
}
return true;
}
return false;
}

View file

@ -36,7 +36,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
@ -106,7 +106,7 @@ class ShimatsuTheBloodcloakedEffect extends ReplacementEffectImpl {
Permanent creature = game.getPermanent(event.getTargetId());
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterPermanent(), true);
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledPermanent(), true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}

View file

@ -41,7 +41,7 @@ import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.target.TargetSpell;
@ -67,7 +67,7 @@ public class UyoSilentProphet extends CardImpl {
this.supertype.add("Legendary");
this.subtype.add("Moonfolk");
this.subtype.add("Wizard");
this.color.setBlue(true);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
@ -75,7 +75,7 @@ public class UyoSilentProphet extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// {2}, Return two lands you control to their owner's hand: Copy target instant or sorcery spell. You may choose new targets for the copy.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CopyTargetSpellEffect(), new GenericManaCost(2));
ability.addCost(new ReturnToHandTargetCost(new TargetControlledPermanent(2, 2, new FilterLandPermanent("lands"), false)));
ability.addCost(new ReturnToHandTargetCost(new TargetControlledPermanent(2, 2, new FilterControlledLandPermanent("lands"), false)));
ability.addTarget(new TargetSpell(filter));
this.addAbility(ability);
}

View file

@ -43,14 +43,12 @@ import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
import mage.abilities.effects.common.continious.GainControlTargetEffect;
import mage.abilities.keyword.HasteAbility;
import mage.cards.SplitCard;
import mage.constants.TargetController;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterPlaneswalkerPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.common.FilterControlledArtifactPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterControlledEnchantmentPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterControlledPlaneswalkerPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -70,13 +68,8 @@ public class CatchRelease extends SplitCard {
super(ownerId, 125, "Catch", "Release", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{U}{R}", "{4}{R}{W}",true);
this.expansionSetCode = "DGM";
this.color.setBlue(true);
this.color.setRed(true);
this.color.setWhite(true);
// Catch
// Gain control of target permanent until end of turn. Untap it. It gains haste until end of turn.
getLeftHalfCard().getColor().setRed(true);
getLeftHalfCard().getSpellAbility().addTarget(new TargetPermanent(new FilterPermanent()));
getLeftHalfCard().getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfTurn));
getLeftHalfCard().getSpellAbility().addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn));
@ -84,7 +77,6 @@ public class CatchRelease extends SplitCard {
// Release
// Each player sacrifices an artifact, a creature, an enchantment, a land, and a planeswalker.
getRightHalfCard().getColor().setGreen(true);
getRightHalfCard().getSpellAbility().addEffect(new ReleaseSacrificeEffect());
}
@ -101,20 +93,6 @@ public class CatchRelease extends SplitCard {
class ReleaseSacrificeEffect extends OneShotEffect {
private static final FilterArtifactPermanent filter1 = new FilterArtifactPermanent("artifact you control");
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature you control");
private static final FilterEnchantmentPermanent filter3 = new FilterEnchantmentPermanent("enchantment you control");
private static final FilterLandPermanent filter4 = new FilterLandPermanent("land you control");
private static final FilterPlaneswalkerPermanent filter5 = new FilterPlaneswalkerPermanent("planeswalker you control");
static {
filter1.add(new ControllerPredicate(TargetController.YOU));
filter2.add(new ControllerPredicate(TargetController.YOU));
filter3.add(new ControllerPredicate(TargetController.YOU));
filter4.add(new ControllerPredicate(TargetController.YOU));
filter5.add(new ControllerPredicate(TargetController.YOU));
}
public ReleaseSacrificeEffect() {
super(Outcome.DestroyPermanent);
staticText = "Each player sacrifices an artifact, a creature, an enchantment, a land, and a planeswalker";
@ -126,7 +104,7 @@ class ReleaseSacrificeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<UUID> chosen = new ArrayList<UUID>();
List<UUID> chosen = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
@ -134,18 +112,11 @@ class ReleaseSacrificeEffect extends OneShotEffect {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
Target target1 = new TargetControlledPermanent(1, 1, filter1, false);
Target target2 = new TargetControlledPermanent(1, 1, filter2, false);
Target target3 = new TargetControlledPermanent(1, 1, filter3, false);
Target target4 = new TargetControlledPermanent(1, 1, filter4, false);
Target target5 = new TargetControlledPermanent(1, 1, filter5, false);
target1.setNotTarget(false);
target2.setNotTarget(false);
target3.setNotTarget(false);
target4.setNotTarget(false);
target5.setNotTarget(false);
Target target1 = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true);
Target target2 = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true);
Target target3 = new TargetControlledPermanent(1, 1, new FilterControlledEnchantmentPermanent(), true);
Target target4 = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true);
Target target5 = new TargetControlledPermanent(1, 1, new FilterControlledPlaneswalkerPermanent(), true);
if (target1.canChoose(player.getId(), game)) {
while (player.isInGame() && !target1.isChosen() && target1.canChoose(player.getId(), game)) {

View file

@ -37,12 +37,10 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.common.FilterControlledArtifactPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterControlledEnchantmentPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -59,8 +57,6 @@ public class Cataclysm extends CardImpl {
super(ownerId, 3, "Cataclysm", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{W}{W}");
this.expansionSetCode = "EXO";
this.color.setWhite(true);
// Each player chooses from the permanents he or she controls an artifact, a creature, an enchantment, and a land, then sacrifices the rest.
this.getSpellAbility().addEffect(new CataclysmEffect());
}
@ -77,18 +73,6 @@ public class Cataclysm extends CardImpl {
class CataclysmEffect extends OneShotEffect {
private static final FilterArtifactPermanent filter1 = new FilterArtifactPermanent("artifact you control");
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature you control");
private static final FilterEnchantmentPermanent filter3 = new FilterEnchantmentPermanent("enchantment you control");
private static final FilterLandPermanent filter4 = new FilterLandPermanent("land you control");
static {
filter1.add(new ControllerPredicate(TargetController.YOU));
filter2.add(new ControllerPredicate(TargetController.YOU));
filter3.add(new ControllerPredicate(TargetController.YOU));
filter4.add(new ControllerPredicate(TargetController.YOU));
}
public CataclysmEffect() {
super(Outcome.DestroyPermanent);
staticText = "Each player chooses from among the permanents he or she controls an artifact, a creature, an enchantment, and a land, then sacrifices the rest";
@ -105,20 +89,14 @@ class CataclysmEffect extends OneShotEffect {
for (UUID playerId : game.getPlayerList()) {
Player player = game.getPlayer(playerId);
Target target1 = new TargetControlledPermanent(1, 1, filter1, false);
Target target2 = new TargetControlledPermanent(1, 1, filter2, false);
Target target3 = new TargetControlledPermanent(1, 1, filter3, false);
Target target4 = new TargetControlledPermanent(1, 1, filter4, false);
target1.setNotTarget(true);
target2.setNotTarget(true);
target3.setNotTarget(true);
target4.setNotTarget(true);
Target target1 = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true);
Target target2 = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true);
Target target3 = new TargetControlledPermanent(1, 1, new FilterControlledEnchantmentPermanent(), true);
Target target4 = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true);
if (target1.canChoose(player.getId(), game)) {
while (player.isInGame() && !target1.isChosen() && target1.canChoose(player.getId(), game)) {
player.choose(Outcome.Benefit, target1, source.getSourceId(), game);
player.chooseTarget(Outcome.Benefit, target1, source, game);
}
Permanent artifact = game.getPermanent(target1.getFirstTarget());
if (artifact != null) {
@ -129,7 +107,7 @@ class CataclysmEffect extends OneShotEffect {
if (target2.canChoose(player.getId(), game)) {
while (player.isInGame() && !target2.isChosen() && target2.canChoose(player.getId(), game)) {
player.choose(Outcome.Benefit, target2, source.getSourceId(), game);
player.chooseTarget(Outcome.Benefit, target2, source, game);
}
Permanent creature = game.getPermanent(target2.getFirstTarget());
if (creature != null) {
@ -140,7 +118,7 @@ class CataclysmEffect extends OneShotEffect {
if (target3.canChoose(player.getId(), game)) {
while (player.isInGame() && !target3.isChosen() && target3.canChoose(player.getId(), game)) {
player.choose(Outcome.Benefit, target3, source.getSourceId(), game);
player.chooseTarget(Outcome.Benefit, target3, source, game);
}
Permanent enchantment = game.getPermanent(target3.getFirstTarget());
if (enchantment != null) {
@ -151,7 +129,7 @@ class CataclysmEffect extends OneShotEffect {
if (target4.canChoose(player.getId(), game)) {
while (player.isInGame() && !target4.isChosen() && target4.canChoose(player.getId(), game)) {
player.choose(Outcome.Benefit, target4, source.getSourceId(), game);
player.chooseTarget(Outcome.Benefit, target4, source, game);
}
Permanent land = game.getPermanent(target4.getFirstTarget());
if (land != null) {

View file

@ -37,8 +37,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.target.common.TargetControlledPermanent;
/**
@ -59,7 +58,7 @@ public class CosmicLarva extends CardImpl {
// Trample
this.addAbility(TrampleAbility.getInstance());
// At the beginning of your upkeep, sacrifice Cosmic Larva unless you sacrifice two lands.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new SacrificeTargetCost(new TargetControlledPermanent(2, 2, new FilterLandPermanent("two lands"), true))), TargetController.YOU, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new SacrificeTargetCost(new TargetControlledPermanent(2, 2, new FilterControlledLandPermanent("two lands"), true))), TargetController.YOU, false));
}
public CosmicLarva(final CosmicLarva card) {

View file

@ -38,7 +38,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterControlledArtifactPermanent;
import mage.target.common.TargetArtifactPermanent;
import mage.target.common.TargetControlledPermanent;
@ -54,13 +54,12 @@ public class KrarkClanEngineers extends CardImpl {
this.subtype.add("Goblin");
this.subtype.add("Artificer");
this.color.setRed(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// {R}, Sacrifice two artifacts: Destroy target artifact.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{R}"));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(2, 2, new FilterArtifactPermanent("two artifacts"), true)));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(2, 2, new FilterControlledArtifactPermanent("two artifacts"), true)));
ability.addTarget(new TargetArtifactPermanent());
this.addAbility(ability);

View file

@ -39,7 +39,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterControlledArtifactPermanent;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -60,7 +60,7 @@ public class KrarkClanOgre extends CardImpl {
// {R}, Sacrifice an artifact: Target creature can't block this turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBlockTargetEffect(Duration.EndOfTurn), new ManaCostsImpl("{R}"));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, new FilterArtifactPermanent("an artifact"), true)));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent("an artifact"), true)));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}

View file

@ -35,10 +35,7 @@ import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.TargetController;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -52,17 +49,10 @@ import mage.target.common.TargetControlledPermanent;
*/
public class DevourFlesh extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
static{
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public DevourFlesh (UUID ownerId) {
super(ownerId, 63, "Devour Flesh", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{B}");
this.expansionSetCode = "GTC";
this.color.setBlack(true);
// Target player sacrifices a creature, then gains life equal to that creature's toughness.
this.getSpellAbility().addEffect(new DevourFleshSacrificeEffect());
this.getSpellAbility().addTarget(new TargetPlayer());
@ -100,13 +90,12 @@ class DevourFleshSacrificeEffect extends OneShotEffect {
if (player == null) {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(player.getId()));
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
if (realCount > 0) {
Target target = new TargetControlledPermanent(1, 1, filter, true);
while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
player.chooseTarget(Outcome.Sacrifice, target, source, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {

View file

@ -27,29 +27,23 @@
*/
package mage.sets.iceage;
import mage.abilities.Ability;
import java.util.UUID;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.PreventAllDamageToControllerEffect;
import mage.abilities.effects.common.SacrificeControllerEffect;
import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/**
*
@ -64,9 +58,11 @@ public class GlacialChasm extends CardImpl {
// Cumulative upkeep-Pay 2 life.
this.addAbility(new CumulativeUpkeepAbility(new PayLifeCost(2)));
// When Glacial Chasm enters the battlefield, sacrifice a land.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeControllerEffect(new FilterLandPermanent(), 1, "")));
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeControllerEffect(new FilterControlledLandPermanent(), 1, "")));
// Creatures you control can't attack.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackEffect()));
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control");
filter.add(new ControllerPredicate(TargetController.YOU));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter)));
// Prevent all damage that would be dealt to you.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToControllerEffect(Duration.WhileOnBattlefield)));
}
@ -80,108 +76,3 @@ public class GlacialChasm extends CardImpl {
return new GlacialChasm(this);
}
}
class SacrificeControllerEffect extends OneShotEffect{
private FilterPermanent filter;
private DynamicValue count;
public SacrificeControllerEffect ( FilterPermanent filter, DynamicValue count, String preText ) {
super(Outcome.Sacrifice);
this.filter = filter;
this.count = count;
staticText = "sacrifice a land";
}
public SacrificeControllerEffect ( FilterPermanent filter, int count, String preText ) {
this(filter, new StaticValue(count), preText);
}
public SacrificeControllerEffect ( SacrificeControllerEffect effect ) {
super(effect);
this.filter = effect.filter;
this.count = effect.count;
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
filter.add(new ControllerPredicate(TargetController.YOU));
int amount = count.calculate(game, source, this);
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
amount = Math.min(amount, realCount);
Target target = new TargetControlledPermanent(amount, amount, filter, false);
//A spell or ability could have removed the only legal target this player
//had, if thats the case this ability should fizzle.
if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
boolean abilityApplied = false;
while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for ( int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent((UUID)target.getTargets().get(idx));
if ( permanent != null ) {
abilityApplied |= permanent.sacrifice(source.getSourceId(), game);
}
}
return abilityApplied;
}
return false;
}
public void setAmount(DynamicValue amount) {
this.count = amount;
}
@Override
public SacrificeControllerEffect copy() {
return new SacrificeControllerEffect(this);
}
}
class CantAttackEffect extends ReplacementEffectImpl {
public CantAttackEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Creatures you control can't attack";
}
public CantAttackEffect(final CantAttackEffect effect) {
super(effect);
}
@Override
public CantAttackEffect copy() {
return new CantAttackEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER && source.getControllerId().equals(event.getPlayerId())) {
return true;
}
return false;
}
}

View file

@ -49,6 +49,7 @@ import mage.target.common.TargetControlledPermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.filter.common.FilterControlledCreaturePermanent;
/**
* @author nantuko
@ -59,8 +60,6 @@ public class DivineReckoning extends CardImpl {
super(ownerId, 10, "Divine Reckoning", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{W}{W}");
this.expansionSetCode = "ISD";
this.color.setWhite(true);
// Each player chooses a creature he or she controls. Destroy the rest.
this.getSpellAbility().addEffect(new DivineReckoningEffect());
@ -79,13 +78,7 @@ public class DivineReckoning extends CardImpl {
}
class DivineReckoningEffect extends OneShotEffect {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
}
public DivineReckoningEffect() {
super(Outcome.DestroyPermanent);
staticText = "Each player chooses a creature he or she controls. Destroy the rest";
@ -97,16 +90,16 @@ class DivineReckoningEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<Card> chosen = new ArrayList<Card>();
List<Card> chosen = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
Target target = new TargetControlledPermanent(1, 1, filter, false);
Target target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), false);
if (target.canChoose(player.getId(), game)) {
while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Outcome.Benefit, target, source.getSourceId(), game);
player.chooseTarget(Outcome.Benefit, target, source, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {

View file

@ -42,11 +42,8 @@ import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.WolfTokenWithDeathtouch;
@ -56,6 +53,7 @@ import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
import mage.filter.common.FilterControlledCreaturePermanent;
/**
* @author nantuko
@ -132,12 +130,7 @@ class GarrukTheVeilCursedValue implements DynamicValue {
class GarrukTheVeilCursedEffect extends OneShotEffect {
private static final FilterPermanent filterCreature = new FilterPermanent("a creature you control");
static {
filterCreature.add(new CardTypePredicate(CardType.CREATURE));
filterCreature.add(new ControllerPredicate(TargetController.YOU));
}
private static final FilterControlledCreaturePermanent filterCreature = new FilterControlledCreaturePermanent("a creature you control");
public GarrukTheVeilCursedEffect() {
super(Outcome.Benefit);
@ -150,22 +143,22 @@ class GarrukTheVeilCursedEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
if (player == null) {
if (controller == null) {
return false;
}
// sacrifice a creature
Target target = new TargetControlledPermanent(1, 1, filterCreature, false);
boolean sacrificed = false;
if (target.canChoose(player.getId(), game)) {
while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
if (target.canChoose(controller.getId(), game)) {
while (controller.isInGame() && !target.isChosen() && target.canChoose(controller.getId(), game)) {
controller.chooseTarget(Outcome.Sacrifice, target, source, game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent((UUID) target.getTargets().get(idx));
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
if (permanent != null) {
sacrificed |= permanent.sacrifice(source.getSourceId(), game);
}
@ -177,9 +170,9 @@ class GarrukTheVeilCursedEffect extends OneShotEffect {
FilterCreatureCard filter = new FilterCreatureCard();
TargetCardInLibrary targetInLibrary = new TargetCardInLibrary(filter);
Cards cards = new CardsImpl();
if (player.searchLibrary(targetInLibrary, game)) {
if (controller.searchLibrary(targetInLibrary, game)) {
for (UUID cardId : targetInLibrary.getTargets()) {
Card card = player.getLibrary().remove(cardId, game);
Card card = controller.getLibrary().remove(cardId, game);
if (card != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
cards.add(card);
@ -188,10 +181,10 @@ class GarrukTheVeilCursedEffect extends OneShotEffect {
}
// reveal
if (cards.size() > 0) {
player.revealCards("Garruk, the Veil-Cursed", cards, game);
controller.revealCards("Garruk, the Veil-Cursed", cards, game);
}
// shuffle
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
return false;

View file

@ -36,7 +36,7 @@ import mage.abilities.keyword.MorphAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.common.TargetControlledPermanent;
@ -46,7 +46,7 @@ import mage.target.common.TargetControlledPermanent;
*/
public class FathomSeer extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("Islands");
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Islands");
static {
filter.add(new SubtypePredicate("Island"));

View file

@ -34,8 +34,8 @@ import mage.abilities.effects.common.DestroyAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.common.TargetControlledPermanent;
@ -45,7 +45,7 @@ import mage.target.common.TargetControlledPermanent;
*/
public class Pulverize extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("two Mountains");
private static final FilterControlledPermanent filter = new FilterControlledPermanent("two Mountains");
static {
filter.add(new SubtypePredicate("Mountain"));
}

View file

@ -41,7 +41,9 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.Target;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetLandPermanent;
@ -57,7 +59,6 @@ public class Dreamwinder extends CardImpl {
this.expansionSetCode = "ODY";
this.subtype.add("Serpent");
this.color.setBlue(true);
this.power = new MageInt(4);
this.toughness = new MageInt(3);
@ -67,7 +68,9 @@ public class Dreamwinder extends CardImpl {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.EndOfTurn, "Island"), new ManaCostsImpl("{U}"));
Target target = new TargetLandPermanent();
ability.addTarget(target);
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, new FilterLandPermanent("Island","an Island"), true)));
FilterControlledLandPermanent filter = new FilterControlledLandPermanent("an Island");
filter.add(new SubtypePredicate("Island"));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, true)));
this.addAbility(ability);
}

View file

@ -34,7 +34,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -85,11 +85,11 @@ class ReadTheRunesEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int drawnCards = player.drawCards(source.getManaCostsToPay().getX(), game);
Target target = new TargetControlledPermanent(0, drawnCards, new FilterPermanent(), true);
target.choose(Outcome.Sacrifice, player.getId(), source.getSourceId(), game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int drawnCards = controller.drawCards(source.getManaCostsToPay().getX(), game);
Target target = new TargetControlledPermanent(0, drawnCards, new FilterControlledPermanent(), true);
controller.chooseTarget(Outcome.Sacrifice, target, source, game);
int sacrificedPermanents = 0;
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
@ -99,7 +99,7 @@ class ReadTheRunesEffect extends OneShotEffect {
}
}
}
player.discard(drawnCards - sacrificedPermanents, source, game);
controller.discard(drawnCards - sacrificedPermanents, false, source, game);
return true;
}
return false;

View file

@ -38,8 +38,7 @@ import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -97,10 +96,7 @@ class ReturnToHandEffect extends OneShotEffect {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerPredicate(TargetController.YOU));
Target target = new TargetControlledPermanent(1, 1, filter, true);
Target target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true);
if (target.canChoose(player.getId(), game)) {
while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
player.chooseTarget(Outcome.ReturnToHand, target, source, game);

View file

@ -36,6 +36,7 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -54,8 +55,6 @@ public class ChoiceOfDamnations extends CardImpl {
this.expansionSetCode = "SOK";
this.subtype.add("Arcane");
this.color.setBlack(true);
// Target opponent chooses a number. You may have that player lose that much life. If you don't, that player sacrifices all but that many permanents.
this.getSpellAbility().addEffect(new ChoiceOfDamnationsEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
@ -94,14 +93,14 @@ class ChoiceOfDamnationsEffect extends OneShotEffect {
int amount = targetPlayer.getAmount(0, Integer.MAX_VALUE, "Chooses a number", game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
StringBuilder sb = new StringBuilder("Shall ").append(targetPlayer.getName()).append(" lose ").append(amount).append(" life?");
if (controller.chooseUse(outcome, sb.toString(), game)) {
String sb = String.valueOf("Shall " + targetPlayer.getName() + " lose ") + Integer.toString(amount) + " life?";
if (controller.chooseUse(outcome, sb, game)) {
targetPlayer.loseLife(amount, game);
} else {
int numberPermanents = game.getState().getBattlefield().countAll(new FilterPermanent(), targetPlayer.getId(), game);
if (numberPermanents > amount) {
int numberToSacrifice = numberPermanents - amount;
Target target = new TargetControlledPermanent(numberToSacrifice, numberToSacrifice, new FilterPermanent(), false);
Target target = new TargetControlledPermanent(numberToSacrifice, numberToSacrifice, new FilterControlledPermanent(), false);
targetPlayer.chooseTarget(Outcome.Sacrifice, target, source, game);
for (UUID uuid : target.getTargets()) {
Permanent permanent = game.getPermanent(uuid);

View file

@ -38,7 +38,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterArtifactCard;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.common.FilterControlledArtifactPermanent;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetControlledPermanent;
@ -49,7 +49,7 @@ import mage.target.common.TargetControlledPermanent;
public class KuldothaForgemaster extends CardImpl {
private static final FilterArtifactCard filterArtifactCard = new FilterArtifactCard();
private static final FilterArtifactPermanent filterArtifactPermanent = new FilterArtifactPermanent();
private static final FilterControlledArtifactPermanent filterArtifactPermanent = new FilterControlledArtifactPermanent();
public KuldothaForgemaster(UUID ownerId) {
super(ownerId, 169, "Kuldotha Forgemaster", Rarity.RARE, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}");

View file

@ -36,7 +36,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.permanent.token.Token;
import mage.target.common.TargetControlledPermanent;
@ -59,7 +59,7 @@ public class AnthousaSetessanHero extends CardImpl {
// <i>Heroic</i> - Whenever you cast a spell that targets Anthousa, Setessan Hero, up to three target lands you control each become 2/2 Warrior creatures until end of turn. They're still lands.
Ability ability = new HeroicAbility(new BecomesCreatureTargetEffect(new AnthousaWarriorToken(), false, true, Duration.EndOfTurn));
ability.addTarget(new TargetControlledPermanent(0,3,new FilterLandPermanent("lands"), false));
ability.addTarget(new TargetControlledPermanent(0,3,new FilterControlledLandPermanent("lands"), false));
this.addAbility(ability);
}

View file

@ -36,7 +36,7 @@ import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.BuybackAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.turn.TurnMod;
@ -49,7 +49,7 @@ import mage.target.common.TargetControlledPermanent;
*/
public class WalkTheAeons extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent("three Islands");
private static final FilterControlledLandPermanent filter = new FilterControlledLandPermanent("three Islands");
static {
filter.add(new SubtypePredicate("Island"));

View file

@ -33,7 +33,7 @@ import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.common.FilterLandPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetLandPermanent;
@ -50,7 +50,7 @@ public class Raze extends CardImpl {
this.color.setRed(true);
// As an additional cost to cast Raze, sacrifice a land.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledPermanent(1,1, new FilterLandPermanent(), true)));
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledPermanent(1,1, new FilterControlledLandPermanent(), true)));
// Destroy target land.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new TargetLandPermanent());

View file

@ -39,7 +39,10 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterNonlandPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.target.common.TargetControlledPermanent;
/**
@ -65,7 +68,9 @@ public class BragoKingEternal extends CardImpl {
Effect effect = new ExileTargetEffect(this.getId(), this.getName(), Zone.BATTLEFIELD);
effect.setText("exile any number of target nonland permanents you control");
Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(effect, false);
ability.addTarget(new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterNonlandPermanent(), false));
FilterControlledPermanent filterControlledNonlandPermanent = new FilterControlledPermanent();
filterControlledNonlandPermanent.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
ability.addTarget(new TargetControlledPermanent(0, Integer.MAX_VALUE, filterControlledNonlandPermanent, false));
ability.addEffect(new ReturnFromExileEffect(this.getId(), Zone.BATTLEFIELD, ", then return those cards to the battlefield under their owner's control"));
this.addAbility(ability);
}

View file

@ -30,15 +30,12 @@ package mage.sets.visions;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreatureOrPlayer;
@ -49,7 +46,7 @@ import mage.target.common.TargetCreatureOrPlayer;
*/
public class Fireblast extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("Mountain");
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Mountain");
static {
filter.add(new SubtypePredicate("Mountain"));

View file

@ -143,7 +143,7 @@ class WorldQuellerEffect extends OneShotEffect {
type = CardType.TRIBAL;
}
if (type != null) {
FilterPermanent filter = new FilterControlledPermanent(new StringBuilder("permanent you control of type ").append(type.toString()).toString());
FilterControlledPermanent filter = new FilterControlledPermanent(new StringBuilder("permanent you control of type ").append(type.toString()).toString());
filter.add(new CardTypePredicate(type));
TargetPermanent target = new TargetControlledPermanent(1, 1, filter, false);
@ -168,7 +168,7 @@ class WorldQuellerEffect extends OneShotEffect {
Player player = game.getPlayer(playerId);
if (target.canChoose(playerId, game)) {
while (!target.isChosen() && target.canChoose(playerId, game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
player.chooseTarget(Outcome.Sacrifice, target, source, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {

View file

@ -39,9 +39,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
import mage.target.TargetPermanent;
import mage.util.CardUtil;
/**
@ -87,14 +85,14 @@ public class SacrificeEffect extends OneShotEffect{
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
amount = Math.min(amount, realCount);
Target target = new TargetControlledPermanent(amount, amount, filter, true);
Target target = new TargetPermanent(amount, amount, filter, true);
// A spell or ability could have removed the only legal target this player
// had, if thats the case this ability should fizzle.
if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
boolean abilityApplied = false;
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.isInGame()) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
player.chooseTarget(Outcome.Sacrifice, target, source, game);
}
for ( int idx = 0; idx < target.getTargets().size(); idx++) {

View file

@ -36,11 +36,13 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledPermanent;
import mage.target.TargetPermanent;
import mage.util.CardUtil;
/**
@ -81,15 +83,17 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<UUID> perms = new ArrayList<UUID>();
List<UUID> perms = new ArrayList<>();
filter.add(new ControllerPredicate(TargetController.YOU));
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false);
TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, false);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && player.isInGame()) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
player.chooseTarget(Outcome.Sacrifice, target, source, game);
}
perms.addAll(target.getTargets());
}

View file

@ -0,0 +1,58 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.filter.common;
import mage.constants.CardType;
import mage.filter.predicate.mageobject.CardTypePredicate;
/**
*
* @author LevelX2
*/
public class FilterControlledPlaneswalkerPermanent extends FilterControlledPermanent {
public FilterControlledPlaneswalkerPermanent() {
this("planeswalker you control");
}
public FilterControlledPlaneswalkerPermanent(String name) {
super(name);
this.add(new CardTypePredicate(CardType.PLANESWALKER));
}
public FilterControlledPlaneswalkerPermanent(final FilterControlledPlaneswalkerPermanent filter) {
super(filter);
}
@Override
public FilterControlledPlaneswalkerPermanent copy() {
return new FilterControlledPlaneswalkerPermanent(this);
}
}

View file

@ -52,14 +52,14 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
super("planeswalker or player");
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<Predicate<Permanent>>();
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<>();
for (UUID defenderId : defenders) {
permanentPredicates.add(new ControllerIdPredicate(defenderId));
}
planeswalkerFilter = new FilterPlaneswalkerPermanent();
planeswalkerFilter.add(Predicates.or(permanentPredicates));
ArrayList<Predicate<Player>> playerPredicates = new ArrayList<Predicate<Player>>();
ArrayList<Predicate<Player>> playerPredicates = new ArrayList<>();
for (UUID defenderId : defenders) {
playerPredicates.add(new PlayerIdPredicate(defenderId));
}

View file

@ -50,7 +50,7 @@ public class TargetControlledPermanent extends TargetPermanent {
this(1, 1, filter, false);
}
public TargetControlledPermanent(int minNumTargets, int maxNumTargets, FilterPermanent filter, boolean notTarget) {
public TargetControlledPermanent(int minNumTargets, int maxNumTargets, FilterControlledPermanent filter, boolean notTarget) {
super(minNumTargets, maxNumTargets, filter, notTarget);
this.targetName = filter.getMessage();
}