* Some more rework of card mobement handling.

This commit is contained in:
LevelX2 2015-08-05 17:46:56 +02:00
parent 78ff4e58e7
commit 55fe68d718
18 changed files with 298 additions and 284 deletions

View file

@ -27,7 +27,7 @@
*/
package mage.sets.dragonsoftarkir;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
@ -94,14 +94,13 @@ class CommuneWithLavaEffect extends OneShotEffect {
Card sourceCard = game.getCard(source.getSourceId());
if (controller != null) {
int amount = source.getManaCostsToPay().getX();
List<Card> cards = controller.getLibrary().getTopCards(game, amount);
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
controller.moveCardsToExile(cards, source, game, true, CardUtil.getCardExileZoneId(game, source), sourceCard.getIdName());
for (Card card : cards) {
if (card != null) {
controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourceCard.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
ContinuousEffect effect = new CommuneWithLavaMayPlayEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
ContinuousEffect effect = new CommuneWithLavaMayPlayEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
return true;

View file

@ -27,6 +27,8 @@
*/
package mage.sets.eventide;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
@ -43,8 +45,6 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -56,7 +56,6 @@ public class SanityGrinding extends CardImpl {
super(ownerId, 29, "Sanity Grinding", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{U}{U}{U}");
this.expansionSetCode = "EVE";
// Chroma - Reveal the top ten cards of your library. For each blue mana symbol in the mana costs of the revealed cards, target opponent puts the top card of his or her library into his or her graveyard. Then put the cards you revealed this way on the bottom of your library in any order.
this.getSpellAbility().addEffect(new SanityGrindingEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
@ -86,18 +85,15 @@ class SanityGrindingEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player targetOpponent = game.getPlayer(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
Cards revealed = new CardsImpl();
int amount;
if (controller == null) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
amount = (Math.min(10, controller.getLibrary().size()));
for (int i = 0; i < amount; i++) {
revealed.add(controller.getLibrary().removeFromTop(game));
}
controller.revealCards("Sanity Grinding", revealed, game);
Cards revealed = new CardsImpl();
revealed.addAll(controller.getLibrary().getTopCards(game, 10));
controller.revealCards(sourceObject.getIdName(), revealed, game);
Player targetOpponent = game.getPlayer(source.getFirstTarget());
if (targetOpponent != null) {
targetOpponent.moveCards(targetOpponent.getLibrary().getTopCards(game, new ChromaSanityGrindingCount(revealed).calculate(game, source, this)),
Zone.LIBRARY, Zone.GRAVEYARD, source, game);

View file

@ -27,18 +27,18 @@
*/
package mage.sets.innistrad;
import java.util.List;
import java.util.Set;
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.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
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.game.permanent.Permanent;
import mage.players.Player;
@ -54,7 +54,6 @@ public class HereticsPunishment extends CardImpl {
super(ownerId, 147, "Heretic's Punishment", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{R}");
this.expansionSetCode = "ISD";
// {3}{R}: Choose target creature or player, then put the top three cards of your library into your graveyard. Heretic's Punishment deals damage to that creature or player equal to the highest converted mana cost among those cards.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HereticsPunishmentEffect(), new ManaCostsImpl("{3}{R}"));
ability.addTarget(new TargetCreatureOrPlayer());
@ -87,12 +86,12 @@ class HereticsPunishmentEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int maxCost = 0;
List<Card> cardList = controller.getLibrary().getTopCards(game, 3);
for (Card card: cardList) {
Set<Card> cardList = controller.getLibrary().getTopCards(game, 3);
for (Card card : cardList) {
int test = card.getManaCost().convertedManaCost();
if (test > maxCost) {
maxCost = test;
}
}
}
controller.moveCards(cardList, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
@ -114,4 +113,4 @@ class HereticsPunishmentEffect extends OneShotEffect {
return new HereticsPunishmentEffect(this);
}
}
}

View file

@ -27,7 +27,7 @@
*/
package mage.sets.khansoftarkir;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
@ -49,7 +49,6 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/**
*
@ -89,12 +88,12 @@ public class NarsetEnlightenedMaster extends CardImpl {
class NarsetEnlightenedMasterExileEffect extends OneShotEffect {
public NarsetEnlightenedMasterExileEffect() {
super(Outcome.Discard);
staticText = "exile the top four cards of your library. Until end of turn, you may cast noncreature cards exiled with {this} this turn without paying their mana costs";
super(Outcome.Discard);
staticText = "exile the top four cards of your library. Until end of turn, you may cast noncreature cards exiled with {this} this turn without paying their mana costs";
}
public NarsetEnlightenedMasterExileEffect(final NarsetEnlightenedMasterExileEffect effect) {
super(effect);
super(effect);
}
@Override
@ -102,16 +101,16 @@ class NarsetEnlightenedMasterExileEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && sourceObject != null) {
List<Card> cards = player.getLibrary().getTopCards(game, 4);
Set<Card> cards = player.getLibrary().getTopCards(game, 4);
player.moveCards(cards, Zone.LIBRARY, Zone.EXILED, source, game);
for (Card card : cards) {
if (game.getState().getZone(card.getId()) == Zone.EXILED &&
!card.getCardType().contains(CardType.CREATURE) &&
!card.getCardType().contains(CardType.LAND)) {
if (game.getState().getZone(card.getId()) == Zone.EXILED
&& !card.getCardType().contains(CardType.CREATURE)
&& !card.getCardType().contains(CardType.LAND)) {
ContinuousEffect effect = new NarsetEnlightenedMasterCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
}
return true;
}
@ -120,7 +119,7 @@ class NarsetEnlightenedMasterExileEffect extends OneShotEffect {
@Override
public NarsetEnlightenedMasterExileEffect copy() {
return new NarsetEnlightenedMasterExileEffect(this);
return new NarsetEnlightenedMasterExileEffect(this);
}
}

View file

@ -27,7 +27,7 @@
*/
package mage.sets.magic2014;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
@ -66,7 +66,7 @@ public class JacesMindseeker extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Jace's Mindseeker enters the battlefield, target opponent puts the top five cards of his or her library into his or her graveyard.
// When Jace's Mindseeker enters the battlefield, target opponent puts the top five cards of his or her library into his or her graveyard.
// You may cast an instant or sorcery card from among them without paying its mana cost.
Ability ability = new EntersBattlefieldTriggeredAbility(new JaceMindseekerEffect());
ability.addTarget(new TargetOpponent());
@ -106,17 +106,17 @@ class JaceMindseekerEffect extends OneShotEffect {
Cards cardsToCast = new CardsImpl();
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (targetOpponent != null) {
List<Card> allCards = targetOpponent.getLibrary().getTopCards(game, 5);
Set<Card> allCards = targetOpponent.getLibrary().getTopCards(game, 5);
targetOpponent.moveCards(allCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
for(Card card : allCards) {
for (Card card : allCards) {
if (filter.match(card, game)) {
Zone zone = game.getState().getZone(card.getId());
// If the five cards are put into a public zone such as exile instead of a graveyard (perhaps due to the ability of Rest in Peace),
// you can cast one of those instant or sorcery cards from that zone.
if (zone.equals(Zone.GRAVEYARD) || zone.equals(Zone.EXILED)) {
// If the five cards are put into a public zone such as exile instead of a graveyard (perhaps due to the ability of Rest in Peace),
// you can cast one of those instant or sorcery cards from that zone.
if (zone.equals(Zone.GRAVEYARD) || zone.equals(Zone.EXILED)) {
cardsToCast.add(card);
}
}
}
}
}
@ -127,14 +127,14 @@ class JaceMindseekerEffect extends OneShotEffect {
TargetCard target = new TargetCard(Zone.GRAVEYARD, filter); // zone should be ignored here
target.setNotTarget(true);
if (controller.chooseUse(outcome, "Cast an instant or sorcery card from among them for free?", source, game)
&& controller.choose(outcome, cardsToCast, target, game)) {
&& controller.choose(outcome, cardsToCast, target, game)) {
Card card = cardsToCast.get(target.getFirstTarget(), game);
if (card != null) {
controller.cast(card.getSpellAbility(), game, true);
}
}
}
}
return false;

View file

@ -98,28 +98,23 @@ class HushwingGryffEffect extends ContinuousRuleModifyingEffectImpl {
}
return null;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Ability ability = (Ability) getValue("targetAbility");
if (ability != null && AbilityType.TRIGGERED.equals(ability.getAbilityType())) {
Permanent p = game.getPermanent(event.getTargetId());
if (p != null && p.getCardType().contains(CardType.CREATURE)) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public HushwingGryffEffect copy() {

View file

@ -27,7 +27,7 @@
*/
package mage.sets.magicorigins;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
@ -100,7 +100,7 @@ class TalentOfTheTelepathEffect extends OneShotEffect {
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (targetOpponent != null && sourceObject != null) {
List<Card> allCards = targetOpponent.getLibrary().getTopCards(game, 7);
Set<Card> allCards = targetOpponent.getLibrary().getTopCards(game, 7);
Cards cards = new CardsImpl(Zone.LIBRARY, allCards);
targetOpponent.revealCards(sourceObject.getIdName() + " - " + targetOpponent.getName() + "'s top library cards", cards, game);
for (Card card : allCards) {

View file

@ -27,12 +27,10 @@
*/
package mage.sets.shadowmoor;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
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;
@ -95,12 +93,8 @@ class AdviceFromTheFaeEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null) {
List<Card> cardsFromTopLibrary = controller.getLibrary().getTopCards(game, 5);
Cards cards = new CardsImpl(Zone.LIBRARY);
for (Card card : cardsFromTopLibrary) {
cards.add(card);
}
controller.lookAtCards(mageObject.getIdName(), cards, game);
Cards cardsFromLibrary = new CardsImpl(Zone.LIBRARY, controller.getLibrary().getTopCards(game, 5));
controller.lookAtCards(mageObject.getIdName(), cardsFromLibrary, game);
int max = 0;
for (UUID playerId : controller.getInRange()) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
@ -113,11 +107,11 @@ class AdviceFromTheFaeEffect extends OneShotEffect {
}
boolean moreCreatures = game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), controller.getId(), game) > max;
TargetCard target = new TargetCard(moreCreatures ? 2 : 1, Zone.LIBRARY, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
cards.removeAll(target.getTargets());
if (controller.choose(Outcome.DrawCard, cardsFromLibrary, target, game)) {
cardsFromLibrary.removeAll(target.getTargets());
controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
controller.putCardsOnBottomOfLibrary(cardsFromLibrary, game, source, true);
return true;
}
return false;