use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class TheAbyssTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact creature you control");
filter.add(Predicates.not(CardType.ARTIFACT.getPredicate()));
filter.add(new ControllerIdPredicate(player.getId()));
Target target = new TargetCreaturePermanent(filter);
target.setAbilityController(getControllerId());
target.setTargetController(player.getId());
this.getTargets().clear();
this.getTargets().add(target);
return true;
}
return false;
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class VesuvanShapeshifterFaceDownEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent copyToCreature = game.getPermanent(source.getSourceId());
if (copyToCreature != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
filter.add(AnotherPredicate.instance);
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, true);
if (controller != null && controller.chooseTarget(Outcome.BecomeCreature, target, source, game) && !target.getTargets().isEmpty()) {
Permanent copyFromCreature = game.getPermanentOrLKIBattlefield(target.getFirstTarget());
if (copyFromCreature != null) {
game.copyPermanent(Duration.Custom, copyFromCreature, copyToCreature.getId(), source, new VesuvanShapeShifterFaceUpCopyApplier());
source.getTargets().clear();
// needed to get effects ready if copy happens in replacment and the copied abilities react of the same event (e.g. turn face up)
game.getState().processAction(game);
return true;
}
}
}
return false;
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class DetainRestrictionEffect method getText.
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
Target target = mode.getTargets().get(0);
if (target.getMaxNumberOfTargets() == target.getNumberOfTargets()) {
if (target.getMaxNumberOfTargets() == 1) {
sb.append("detain target ").append(target.getTargetName());
} else {
sb.append("detain ").append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName());
}
} else {
sb.append("detain up to ").append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ").append(target.getTargetName());
}
sb.append(". <i>(Until your next turn, ");
if (target instanceof TargetCreaturePermanent) {
sb.append(target.getMaxNumberOfTargets() == 1 ? "that creature" : "those creatures");
} else {
sb.append(target.getMaxNumberOfTargets() == 1 ? "that permanent" : "those permanents");
}
sb.append(" can't attack or block and ");
sb.append(target.getMaxNumberOfTargets() == 1 ? "its" : "their");
sb.append(" activated abilities can't be activated.)</i>");
return sb.toString();
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class ForcefieldPreventionEffect 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) {
Target target = new TargetCreaturePermanent(1, 1, filter, true);
if (controller.choose(Outcome.PreventDamage, target, source.getSourceId(), game)) {
Permanent creature = game.getPermanent(target.getFirstTarget());
if (creature != null) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + creature.getLogName());
}
ContinuousEffect effect = new ForcefieldPreventionEffect();
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class GrimgrinCorpseBornAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId())) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
UUID defenderId = game.getCombat().getDefenderId(sourceId);
filter.add(new ControllerIdPredicate(defenderId));
this.getTargets().clear();
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
this.addTarget(target);
return true;
}
return false;
}
Aggregations