use of mage.target.TargetPermanent in project mage by magefree.
the class MindlinkMechApplier method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(getSourceId()) || !MindlinkMechWatcher.checkVehicle(this, game)) {
return false;
}
this.getTargets().clear();
this.addTarget(new TargetPermanent(MindlinkMechWatcher.makeFilter(this, game)));
return true;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class NettlevineBlightEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent nettlevineBlight = game.getPermanent(source.getSourceId());
Player newController = null;
if (controller != null && nettlevineBlight != null) {
Permanent enchantedPermanent = game.getPermanent(nettlevineBlight.getAttachedTo());
if (enchantedPermanent != null) {
newController = game.getPlayer(enchantedPermanent.getControllerId());
enchantedPermanent.sacrifice(source, game);
}
if (newController != null) {
FilterPermanent filter = new FilterPermanent("creature or land permanent you control");
filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.LAND.getPredicate()));
filter.add(new ControllerIdPredicate(newController.getId()));
filter.add(new CanBeEnchantedByPredicate(nettlevineBlight));
Target target = new TargetPermanent(filter);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), newController.getId(), game) && newController.choose(outcome, target, source.getSourceId(), game)) {
Permanent chosenPermanent = game.getPermanent(target.getFirstTarget());
if (chosenPermanent != null) {
Card nettlevineBlightCard = game.getCard(source.getSourceId());
if (nettlevineBlightCard != null) {
game.getState().setValue("attachTo:" + nettlevineBlight.getId(), chosenPermanent);
chosenPermanent.addAttachment(nettlevineBlight.getId(), source, game);
return true;
}
}
}
}
}
return false;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class SakashimasWillCopyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), player.getId(), game)) {
return false;
}
player.choose(outcome, target, source.getSourceId(), game);
Permanent chosenCreature = game.getPermanent(target.getFirstTarget());
if (chosenCreature == null) {
return false;
}
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, player.getId(), source.getSourceId(), game)) {
if (permanent == null || permanent.getId().equals(chosenCreature.getId())) {
continue;
}
game.copyPermanent(Duration.EndOfTurn, chosenCreature, permanent.getId(), source, new EmptyCopyApplier());
}
return true;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class DeadlyVanityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetPermanent target = new TargetCreatureOrPlaneswalker();
target.setNotTarget(true);
controller.choose(outcome, target, source.getId(), game);
FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent();
UUID targetId = target.getFirstTarget();
if (targetId != null) {
filter.add(Predicates.not(new PermanentIdPredicate(targetId)));
}
return new DestroyAllEffect(filter).apply(game, source);
}
use of mage.target.TargetPermanent in project mage by magefree.
the class StranglingGraspEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = source.getSourcePermanentOrLKI(game);
if (sourcePermanent == null) {
return false;
}
Permanent attachedTo = game.getPermanentOrLKIBattlefield(sourcePermanent.getAttachedTo());
if (attachedTo == null) {
return false;
}
Player player = game.getPlayer(attachedTo.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new TargetPermanent(filter);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.choose(outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
player.loseLife(1, game, source, false);
return true;
}
Aggregations