use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class CryptoplasmEffect method apply.
@Override
public boolean apply(Game game, final Ability source) {
Permanent creatureToCopy = game.getPermanent(getTargetPointer().getFirst(game, source));
if (creatureToCopy != null) {
CopyApplier applier = new CopyApplier() {
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
blueprint.getAbilities().add(upkeepAbility);
return true;
}
};
game.copyPermanent(creatureToCopy, source.getSourceId(), source, applier);
}
return true;
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class EvilTwinPredicate method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(filter));
blueprint.getAbilities().add(ability);
return true;
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class EtrataTheSilencerEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
this.getTargets().clear();
this.addTarget(new TargetCreaturePermanent(filter));
return true;
}
}
return false;
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class FumbleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
if (player == null || permanent == null) {
return false;
}
List<Permanent> attachments = new ArrayList<>();
for (UUID permId : permanent.getAttachments()) {
Permanent attachment = game.getPermanent(permId);
if (attachment != null) {
if (attachment.hasSubtype(SubType.AURA, game) || attachment.hasSubtype(SubType.EQUIPMENT, game)) {
attachments.add(attachment);
}
}
}
new ReturnToHandTargetEffect().apply(game, source);
if (!attachments.isEmpty()) {
Target target = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true);
Permanent newCreature = null;
if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
newCreature = game.getPermanent(target.getFirstTarget());
}
for (Permanent attachment : attachments) {
if (!attachment.hasSubtype(SubType.AURA, game) && !attachment.hasSubtype(SubType.EQUIPMENT, game)) {
continue;
}
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, player.getId());
effect.setTargetPointer(new FixedTarget(attachment, game));
game.addEffect(effect, source);
if (newCreature != null) {
attachment.attachTo(newCreature.getId(), source, game);
}
}
}
return true;
}
use of mage.target.common.TargetCreaturePermanent in project mage by magefree.
the class JaddiLifestriderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int tappedAmount = 0;
Player you = game.getPlayer(source.getControllerId());
TargetCreaturePermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE, filter, true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) {
for (UUID creatureId : target.getTargets()) {
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
creature.tap(source, game);
tappedAmount++;
}
}
}
if (tappedAmount > 0 && you != null) {
you.gainLife(tappedAmount * 2, game, source);
return true;
}
return false;
}
Aggregations