mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 13:19:18 -08:00
* Fixed some library search effects that didn't sort the library and didn't take search limitations into account (Aven Mindcensor)
This commit is contained in:
parent
dc6a4b07cd
commit
3b03a0500a
16 changed files with 104 additions and 89 deletions
|
|
@ -31,6 +31,7 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -55,11 +56,13 @@ public class RetractionHelix extends CardImpl<RetractionHelix> {
|
|||
this.color.setBlue(true);
|
||||
|
||||
// Until end of turn, target creature gains "{T}: Return target nonland permanent to its owner's hand."
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(), new TapSourceCost());
|
||||
Ability gainedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(), new TapSourceCost());
|
||||
Target target = new TargetNonlandPermanent();
|
||||
target.setRequired(true);
|
||||
ability.addTarget(target);
|
||||
this.getSpellAbility().addEffect(new GainAbilityTargetEffect(ability, Duration.EndOfTurn));
|
||||
gainedAbility.addTarget(target);
|
||||
Effect effect = new GainAbilityTargetEffect(gainedAbility, Duration.EndOfTurn);
|
||||
effect.setText("Until end of turn, target creature gains \"{T}: Return target nonland permanent to its owner's hand.\"");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(true));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,12 +35,11 @@ import mage.abilities.effects.Effect;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
|
|
@ -80,7 +79,14 @@ public class NightmareIncursion extends CardImpl<NightmareIncursion> {
|
|||
}
|
||||
|
||||
class NightmareIncursionEffect extends OneShotEffect<NightmareIncursionEffect> {
|
||||
|
||||
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent();
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
filter.add(new SubtypePredicate("Swamp"));
|
||||
}
|
||||
|
||||
boolean exiled = false;
|
||||
|
||||
public NightmareIncursionEffect() {
|
||||
|
|
@ -99,23 +105,19 @@ class NightmareIncursionEffect extends OneShotEffect<NightmareIncursionEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
boolean result = false;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
FilterLandPermanent filter = new FilterLandPermanent();
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
filter.add(new SubtypePredicate("Swamp"));
|
||||
int amount = new PermanentsOnBattlefieldCount(filter).calculate(game, source);
|
||||
if (you != null && targetPlayer != null) {
|
||||
Cards targetLibrary = new CardsImpl();
|
||||
targetLibrary.addAll(targetPlayer.getLibrary().getCardList());
|
||||
if (controller != null && targetPlayer != null) {
|
||||
int amount = new PermanentsOnBattlefieldCount(filter).calculate(game, source);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterCard());
|
||||
if (you.choose(Outcome.Benefit, targetLibrary, target, game)) {
|
||||
if (controller.searchLibrary(target, game, targetPlayer.getId())) {
|
||||
List<UUID> targetId = target.getTargets();
|
||||
for (UUID targetCard : targetId) {
|
||||
Card card = targetPlayer.getLibrary().remove(targetCard, game);
|
||||
if (card != null) {
|
||||
card.moveToExile(source.getSourceId(), "Nightmare Incursion", source.getSourceId(), game);
|
||||
exiled = true;
|
||||
controller.moveCardToExileWithInfo(card, null, null, source.getSourceId(), game, Zone.LIBRARY);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -123,6 +125,6 @@ class NightmareIncursionEffect extends OneShotEffect<NightmareIncursionEffect> {
|
|||
if (targetPlayer != null) {
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
}
|
||||
return exiled;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,15 +35,13 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
|||
import mage.abilities.condition.common.ProwlCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardControllerEffect;
|
||||
import mage.abilities.keyword.ProwlAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
|
@ -107,16 +105,13 @@ class EarwigSquadEffect extends OneShotEffect {
|
|||
Player opponent = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && opponent != null) {
|
||||
Cards opponentLibrary = new CardsImpl();
|
||||
opponentLibrary.addAll(opponent.getLibrary().getCardList());
|
||||
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCard("cards from opponents library to exile"));
|
||||
if (player.choose(Outcome.Benefit, opponentLibrary, target, game)) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCard("cards from opponents library to exile"));
|
||||
if (player.searchLibrary(target, game, opponent.getId())) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = opponent.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
card.moveToExile(null, null, source.getId(), game);
|
||||
player.moveCardToExileWithInfo(card, null, null, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,16 +99,13 @@ class LifesFinaleEffect extends OneShotEffect {
|
|||
Player opponent = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && opponent != null) {
|
||||
Cards opponentLibrary = new CardsImpl();
|
||||
opponentLibrary.addAll(opponent.getLibrary().getCardList());
|
||||
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCreatureCard("creature cards from his library to put in his graveyard"));
|
||||
if (player.choose(Outcome.Benefit, opponentLibrary, target, game)) {
|
||||
if (player.searchLibrary(target, game, opponent.getId())) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = opponent.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, false);
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import mage.target.common.TargetCardInLibrary;
|
|||
import mage.target.common.TargetOpponent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -90,18 +91,16 @@ class PraetorsGraspEffect extends OneShotEffect<PraetorsGraspEffect> {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player opponent = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && opponent != null) {
|
||||
Cards opponentLibrary = new CardsImpl();
|
||||
opponentLibrary.addAll(opponent.getLibrary().getCardList());
|
||||
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (player != null && opponent != null && sourcePermanent != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
if (player.choose(Outcome.Benefit, opponentLibrary, target, game)) {
|
||||
if (player.searchLibrary(target, game, opponent.getId())) {
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Card card = opponent.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
card.setFaceDown(true);
|
||||
card.setControllerId(player.getId());
|
||||
card.moveToExile(getId(), "Praetor's Grasp", source.getSourceId(), game);
|
||||
card.moveToExile(getId(), sourcePermanent.getName(), source.getSourceId(), game);
|
||||
game.addEffect(new PraetorsGraspPlayEffect(card.getId()), source);
|
||||
game.addEffect(new PraetorsGraspRevealEffect(card.getId()), source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,17 +27,15 @@
|
|||
*/
|
||||
package mage.sets.odyssey;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
|
@ -95,17 +93,16 @@ class ExtractEffect extends OneShotEffect<ExtractEffect> {
|
|||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && targetPlayer != null) {
|
||||
Cards targetLibrary = new CardsImpl();
|
||||
targetLibrary.addAll(targetPlayer.getLibrary().getCardList());
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(1, 1, filter);
|
||||
if (player.choose(Outcome.Benefit, targetLibrary, target, game)) {
|
||||
if (player.searchLibrary(target, game, targetPlayer.getId())) {
|
||||
Card card = targetPlayer.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
card.moveToExile(getId(), "Extract", source.getSourceId(), game);
|
||||
player.moveCardToExileWithInfo(card, null, null, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,21 +116,19 @@ class SupremeInquisitorEffect extends OneShotEffect<SupremeInquisitorEffect> {
|
|||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && targetPlayer != null) {
|
||||
Cards targetLibrary = new CardsImpl();
|
||||
targetLibrary.addAll(targetPlayer.getLibrary().getCardList());
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 5, filter);
|
||||
if (player.choose(Outcome.Benefit, targetLibrary, target, game)) {
|
||||
if (player.searchLibrary(target, game, targetPlayer.getId())) {
|
||||
List<UUID> targetId = target.getTargets();
|
||||
for (UUID targetCard : targetId) {
|
||||
Card card = targetPlayer.getLibrary().remove(targetCard, game);
|
||||
if (card != null) {
|
||||
card.moveToExile(getId(), "Supreme Inquisitor", source.getSourceId(), game);
|
||||
player.moveCardToExileWithInfo(card, null, null, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect<JaceArchitectOfThought
|
|||
for (UUID cardUuid : cardsToHand) {
|
||||
Card card = cardsToHand.get(cardUuid, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -310,13 +310,13 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect<JaceArchitectOfThought
|
|||
Card card = cardsToLibrary.get(targetCard.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
cardsToLibrary.remove(card);
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
if (cardsToLibrary.size() == 1) {
|
||||
Card card = cardsToLibrary.get(cardsToLibrary.iterator().next(), game);
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -343,24 +343,22 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect<JaceArchitectOfThought
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller == null || sourcePermanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
Cards playerLibrary = new CardsImpl();
|
||||
Player player = game.getPlayer(playerId);
|
||||
playerLibrary.addAll(player.getLibrary().getCardList());
|
||||
String playerName = new StringBuilder(player.getName()).append("'s").toString();
|
||||
if (source.getControllerId().equals(player.getId())) {
|
||||
playerName = "your";
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard(new StringBuilder("nonland card from ").append(playerName).append(" library").toString()));
|
||||
if (controller.choose(Outcome.Benefit, playerLibrary, target, game)) {
|
||||
if (controller.searchLibrary(target, game, playerId)) {
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Card card = player.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
card.moveToExile(CardUtil.getCardExileZoneId(game, source), "Jace, Architect of Thought", source.getSourceId(), game);
|
||||
controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getName(), source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
|
|
|
|||
|
|
@ -28,20 +28,18 @@
|
|||
package mage.sets.returntoravnica;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
|
@ -93,10 +91,10 @@ class PsychicSpiralEffect extends OneShotEffect<PsychicSpiralEffect> {
|
|||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
if (targetPlayer != null) {
|
||||
for (int i = 0; i<cardsInGraveyard ; i++) {
|
||||
if (!targetPlayer.getLibrary().getCardList().isEmpty()) {
|
||||
if (targetPlayer.getLibrary().size() > 0) {
|
||||
Card card = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, false);
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ class AltarOfDementiaEffect extends OneShotEffect<AltarOfDementiaEffect> {
|
|||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (player != null) {
|
||||
for (int i = 0; i<amount ; i++) {
|
||||
if (!player.getLibrary().getCardList().isEmpty()) {
|
||||
if (player.getLibrary().size() > 0) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, false);
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class DoomsdayEffect extends OneShotEffect<DoomsdayEffect> {
|
|||
int number = Math.min(5, allCards.size());
|
||||
TargetCard target = new TargetCard(number, number, Zone.PICK, new FilterCard());
|
||||
|
||||
if(player.choose(Outcome.Benefit, allCards, target, game)){
|
||||
if (player.choose(Outcome.Benefit, allCards, target, game)){
|
||||
// exile the rest
|
||||
for(UUID uuid : allCards){
|
||||
if(!target.getTargets().contains(uuid)){
|
||||
|
|
@ -117,7 +117,7 @@ class DoomsdayEffect extends OneShotEffect<DoomsdayEffect> {
|
|||
//Put the chosen cards on top of your library in any order
|
||||
target = new TargetCard(Zone.PICK, new FilterCard("Card to put on top"));
|
||||
target.setRequired(true);
|
||||
while (cards.size() > 1) {
|
||||
while (cards.size() > 1 && player.isInGame()) {
|
||||
player.choose(Outcome.Neutral, cards, target, game);
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue