* Descendants' Path - Fixed that it did not work with Chnagelling or Has all creature types abililities.

This commit is contained in:
LevelX2 2015-06-17 21:06:07 +02:00
parent 68a0782e30
commit 2d9e5a032e

View file

@ -27,7 +27,6 @@
*/ */
package mage.sets.avacynrestored; package mage.sets.avacynrestored;
import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType; import mage.constants.CardType;
@ -42,11 +41,10 @@ import mage.cards.CardsImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
/** /**
* *
@ -59,7 +57,6 @@ public class DescendantsPath extends CardImpl {
super(ownerId, 173, "Descendants' Path", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); super(ownerId, 173, "Descendants' Path", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}");
this.expansionSetCode = "AVR"; this.expansionSetCode = "AVR";
// At the beginning of your upkeep, reveal the top card of your library. If it's a creature card that shares a creature type with a creature you control, you may cast that card without paying its mana cost. Otherwise, put that card on the bottom of your library. // At the beginning of your upkeep, reveal the top card of your library. If it's a creature card that shares a creature type with a creature you control, you may cast that card without paying its mana cost. Otherwise, put that card on the bottom of your library.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new DescendantsPathEffect(), TargetController.YOU, false); Ability ability = new BeginningOfUpkeepTriggeredAbility(new DescendantsPathEffect(), TargetController.YOU, false);
this.addAbility(ability); this.addAbility(ability);
@ -93,36 +90,39 @@ class DescendantsPathEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player != null) { MageObject sourceObject = source.getSourceObject(game);
if (player.getLibrary().size() > 0) { if (controller != null && sourceObject != null) {
Card card = player.getLibrary().getFromTop(game); if (controller.getLibrary().size() > 0) {
player.revealCards("DescendantsPath", new CardsImpl(card), game); Card card = controller.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
if (card.getCardType().contains(CardType.CREATURE)) { if (card.getCardType().contains(CardType.CREATURE)) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
boolean found = false;
ArrayList<Predicate<MageObject>> subtypes = new ArrayList<>(); for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
for (String subtype: card.getSubtype()) { if (CardUtil.shareSubtypes(card, permanent)) {
subtypes.add(new SubtypePredicate(subtype)); found = true;
break;
} }
filter.add(Predicates.or(subtypes)); }
if (found) {
int count = game.getBattlefield().getAllActivePermanents(filter, player.getId(), game).size(); game.informPlayers(sourceObject.getLogName() + ": Found a creature that shares a creature type with the revealed card.");
if (count > 0) { if (controller.chooseUse(Outcome.Benefit, "Cast the card?", game)) {
game.informPlayers("DescendantsPath: Found a creature that shares a creature type with the revealed card."); controller.cast(card.getSpellAbility(), game, true);
if (player.chooseUse(Outcome.Benefit, "Cast the card?", game)) {
player.cast(card.getSpellAbility(), game, true);
} else { } else {
game.informPlayers("DescendantsPath: " + player.getLogName() + " canceled casting the card."); game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " canceled casting the card.");
player.getLibrary().putOnBottom(card, game); controller.getLibrary().putOnBottom(card, game);
} }
} else { } else {
game.informPlayers("DescendantsPath: No creature that shares a creature type with the revealed card."); game.informPlayers(sourceObject.getLogName() + ": No creature that shares a creature type with the revealed card.");
player.getLibrary().putOnBottom(card, game); controller.getLibrary().putOnBottom(card, game);
} }
} else { } else {
game.informPlayers("DescendantsPath: put " + card.getName() + " on the bottom."); game.informPlayers(sourceObject.getLogName() + ": Put " + card.getLogName() + " on the bottom.");
player.getLibrary().putOnBottom(card, game); controller.getLibrary().putOnBottom(card, game);
} }
return true; return true;