use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class GatherThePackEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
int creatures = cards.count(StaticFilters.FILTER_CARD_CREATURE, source.getSourceId(), source.getControllerId(), game);
if (creatures > 0) {
int max = 1;
if (SpellMasteryCondition.instance.apply(game, source) && creatures > 1) {
max++;
}
TargetCard target = new TargetCard(0, max, Zone.LIBRARY, new FilterCreatureCard("creature card" + (max > 1 ? "s" : "") + " to put into your hand"));
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
Cards cardsToHand = new CardsImpl(target.getTargets());
if (!cardsToHand.isEmpty()) {
cards.removeAll(cardsToHand);
controller.moveCards(cardsToHand, Zone.HAND, source, game);
}
}
}
if (!cards.isEmpty()) {
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
}
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class GuildFeudEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
Permanent opponentCreature = null;
Permanent controllerCreature = null;
MageObject sourceObject = source.getSourceObject(game);
if (opponent != null && controller != null && sourceObject != null) {
for (int activePlayer = 0; activePlayer < 2; activePlayer++) {
Player player = (activePlayer == 0 ? opponent : controller);
Cards topThreeCards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
player.revealCards(source, player.getName() + " top library cards", topThreeCards, game);
Card creatureToBattlefield;
if (!topThreeCards.isEmpty()) {
if (player.chooseUse(Outcome.PutCreatureInPlay, "Put a creature card among them to the battlefield?", source, game)) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put on the battlefield"));
if (player.choose(Outcome.PutCreatureInPlay, topThreeCards, target, game)) {
creatureToBattlefield = topThreeCards.get(target.getFirstTarget(), game);
if (creatureToBattlefield != null) {
topThreeCards.remove(creatureToBattlefield);
if (player.moveCards(creatureToBattlefield, Zone.BATTLEFIELD, source, game)) {
if (activePlayer == 0) {
opponentCreature = game.getPermanent(creatureToBattlefield.getId());
} else {
controllerCreature = game.getPermanent(creatureToBattlefield.getId());
}
}
}
}
}
player.moveCards(topThreeCards, Zone.GRAVEYARD, source, game);
}
}
// If two creatures are put onto the battlefield this way, those creatures fight each other
if (opponentCreature != null && controllerCreature != null) {
opponentCreature.fight(controllerCreature, source, game);
}
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class MausoleumTurnkeyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = new TargetOpponent(true);
if (controller.chooseTarget(outcome, target, source, game)) {
opponentId = target.getFirstTarget();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterCreatureCard filter = new FilterCreatureCard("creature card from " + controller.getLogName() + " graveyard");
filter.add(new OwnerIdPredicate(controller.getId()));
Target target = new TargetCardInGraveyard(filter);
opponent.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class ToothAndNailPutCreatureOnBattlefieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInHand target = new TargetCardInHand(0, 2, new FilterCreatureCard("creature cards"));
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class GrimCaptainsCallEffect method returnToHand.
private void returnToHand(Game game, SubType subType, Player controller, Ability source) {
FilterCreatureCard filter = new FilterCreatureCard(subType.getDescription() + " card");
filter.add(subType.getPredicate());
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard(filter));
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
}
Aggregations