mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Call to the Kindred - Fixed that it did not work correctly if the enchanted creatures had all creature types or changeling.
This commit is contained in:
parent
4ca5909840
commit
799b2434dd
1 changed files with 24 additions and 25 deletions
|
@ -34,6 +34,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.OnEventTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.keyword.ChangelingAbility;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -66,7 +67,6 @@ public class CallToTheKindred extends CardImpl {
|
|||
this.expansionSetCode = "DKA";
|
||||
this.subtype.add("Aura");
|
||||
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
|
@ -106,10 +106,10 @@ class CallToTheKindredEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
|
||||
if (player == null || enchantment.getAttachedTo() == null) {
|
||||
if (enchantment == null || controller == null || enchantment.getAttachedTo() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -119,38 +119,37 @@ class CallToTheKindredEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
Cards cards = new CardsImpl();
|
||||
int count = Math.min(player.getLibrary().size(), 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
player.lookAtCards("Call to the Kindred", cards, game);
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 5));
|
||||
controller.lookAtCards(enchantment.getIdName(), cards, game);
|
||||
|
||||
FilterCreatureCard filter = new FilterCreatureCard();
|
||||
StringBuilder sb = new StringBuilder("creature card with at least one subtype from: ");
|
||||
ArrayList<Predicate<MageObject>> subtypes = new ArrayList<Predicate<MageObject>>();
|
||||
for (String subtype : creature.getSubtype()) {
|
||||
subtypes.add(new SubtypePredicate(subtype));
|
||||
sb.append(subtype).append(", ");
|
||||
}
|
||||
filter.add(Predicates.or(subtypes));
|
||||
sb.delete(sb.length() - 2, sb.length());
|
||||
filter.setMessage(sb.toString());
|
||||
|
||||
if (cards.count(filter, game) > 0 && player.chooseUse(Outcome.DrawCard, "Do you wish to put a creature card onto the battlefield?", source, game)) {
|
||||
if (!creature.getAbilities().contains(ChangelingAbility.getInstance())) {
|
||||
StringBuilder sb = new StringBuilder("creature card with at least one subtype from: ");
|
||||
ArrayList<Predicate<MageObject>> subtypes = new ArrayList<>();
|
||||
for (String subtype : creature.getSubtype()) {
|
||||
subtypes.add(new SubtypePredicate(subtype));
|
||||
sb.append(subtype).append(", ");
|
||||
}
|
||||
filter.add(Predicates.or(subtypes));
|
||||
sb.delete(sb.length() - 2, sb.length());
|
||||
filter.setMessage(sb.toString());
|
||||
} else {
|
||||
filter.setMessage("creature card that shares a creature type with enchanted creature");
|
||||
}
|
||||
|
||||
if (cards.count(filter, game) > 0 && controller.chooseUse(Outcome.DrawCard, "Do you wish to put a creature card onto the battlefield?", source, game)) {
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
|
||||
|
||||
if (player.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
|
||||
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.putCardsOnBottomOfLibrary(cards, game, source, true);
|
||||
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue