use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ScrapTrawlerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent != null && permanent.isControlledBy(this.getControllerId()) && permanent.isArtifact(game)) {
FilterCard filter = new FilterArtifactCard("artifact card in your graveyard with mana value less than " + permanent.getManaCost().manaValue());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, permanent.getManaCost().manaValue()));
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
getTargets().clear();
addTarget(target);
return true;
}
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ReturnFromGraveyardToBattlefieldTargetEffect method getText.
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
boolean yourGrave = !mode.getTargets().isEmpty() && mode.getTargets().get(0) instanceof TargetCardInYourGraveyard;
sb.append(yourGrave ? "return " : "put ");
if (mode.getTargets().isEmpty()) {
sb.append("target creature");
} else {
Target target = mode.getTargets().get(0);
if (target.getMaxNumberOfTargets() > 1) {
if (target.getMaxNumberOfTargets() != target.getNumberOfTargets()) {
sb.append("up to ");
}
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(' ');
}
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
}
sb.append(yourGrave ? " to" : " onto");
sb.append(" the battlefield");
if (tapped && attacking) {
sb.append(" tapped and attacking");
} else if (tapped) {
sb.append(" tapped");
} else if (attacking) {
sb.append(" attacking");
}
if (!yourGrave) {
sb.append(" under your control");
}
return sb.toString();
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class SearchLibraryGraveyardPutOntoBattlefieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
Card cardFound = null;
boolean needShuffle = false;
if (controller != null && sourceObject != null) {
if (forceToSearchBoth || controller.chooseUse(outcome, "Search your library for a " + filter.getMessage() + '?', source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
target.clearChosen();
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
cardFound = game.getCard(target.getFirstTarget());
}
}
needShuffle = true;
}
if (cardFound == null && controller.chooseUse(outcome, "Search your graveyard for a " + filter.getMessage() + '?', source, game)) {
TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true);
target.clearChosen();
if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
if (!target.getTargets().isEmpty()) {
cardFound = game.getCard(target.getFirstTarget());
}
}
}
if (cardFound != null) {
controller.moveCards(cardFound, Zone.BATTLEFIELD, source, game);
}
if (needShuffle) {
controller.shuffleLibrary(source, game);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class EdgarsAwakeningTriggeredAbility method makeAbility.
private static final ReflexiveTriggeredAbility makeAbility() {
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect(), false, "return target creature card from your graveyard to your hand");
ability.addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
return ability;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class GodPharaohsGiftEffect 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;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD, true);
controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
Card cardChosen = game.getCard(target.getFirstTarget());
if (cardChosen == null || !controller.moveCards(cardChosen, Zone.EXILED, source, game)) {
return false;
}
// create token and modify all attributes permanently (without game usage)
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(cardChosen, game);
token.removePTCDA();
token.getPower().modifyBaseValue(4);
token.getToughness().modifyBaseValue(4);
token.getColor().setColor(ObjectColor.BLACK);
token.removeAllCreatureTypes();
token.addSubType(SubType.ZOMBIE);
token.putOntoBattlefield(1, game, source, source.getControllerId());
List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
if (!permanents.isEmpty()) {
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(permanents, game)), source);
}
return true;
}
Aggregations