use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class ChemistersTrickEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source.getControllerId(), source.getSourceId(), game)) {
AttacksIfAbleTargetEffect effect = new AttacksIfAbleTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
}
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class ChaosMoonEvenReplacementEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = ((TappedForManaEvent) event).getPermanent();
if (land == null || !land.hasSubtype(SubType.MOUNTAIN, game)) {
return false;
}
this.getEffects().setTargetPointer(new FixedTarget(land.getControllerId()));
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class CharmingPrinceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
if (!controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
return false;
}
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
effect.setText("Return it to the battlefield under your control at the beginning of the next end step");
effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class DefiantVanguardEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent blocker = game.getPermanent(event.getSourceId());
Permanent blocked = game.getPermanent(event.getTargetId());
if (blocker != null && blocked != null) {
// in case the attacker changes zone
game.getState().setValue(blocked.toString(), blocked.getZoneChangeCounter(game));
// in case the blocker changes zone
game.getState().setValue(blocker.toString(), blocker.getZoneChangeCounter(game));
getAllEffects().setTargetPointer(new FixedTarget(blocked.getId()));
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class DiluvianPrimordialReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Target target : source.getTargets()) {
if (target instanceof TargetCardInOpponentsGraveyard) {
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) {
if (controller.chooseUse(Outcome.PlayForFree, "Cast " + targetCard.getLogName() + '?', source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(targetCard, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), null);
if (cardWasCast) {
ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
effect.setTargetPointer(new FixedTarget(targetCard.getId(), game.getState().getZoneChangeCounter(targetCard.getId())));
game.addEffect(effect, source);
}
}
}
}
}
return true;
}
return false;
}
Aggregations