mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +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.common.OnEventTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.keyword.ChangelingAbility;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -66,7 +67,6 @@ public class CallToTheKindred extends CardImpl {
|
||||||
this.expansionSetCode = "DKA";
|
this.expansionSetCode = "DKA";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
@ -106,10 +106,10 @@ class CallToTheKindredEffect 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());
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||||
|
|
||||||
if (player == null || enchantment.getAttachedTo() == null) {
|
if (enchantment == null || controller == null || enchantment.getAttachedTo() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,38 +119,37 @@ class CallToTheKindredEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
int count = Math.min(player.getLibrary().size(), 5);
|
cards.addAll(controller.getLibrary().getTopCards(game, 5));
|
||||||
for (int i = 0; i < count; i++) {
|
controller.lookAtCards(enchantment.getIdName(), cards, game);
|
||||||
Card card = player.getLibrary().removeFromTop(game);
|
|
||||||
if (card != null) {
|
|
||||||
cards.add(card);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.lookAtCards("Call to the Kindred", cards, game);
|
|
||||||
|
|
||||||
FilterCreatureCard filter = new FilterCreatureCard();
|
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);
|
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);
|
Card card = cards.get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
cards.remove(card);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue