use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class CardUtil method moveCardWithCounter.
/**
* Move card or permanent to dest zone and add counter to it
*
* @param game
* @param source
* @param controller
* @param card can be card or permanent
* @param toZone
* @param counter
*/
public static boolean moveCardWithCounter(Game game, Ability source, Player controller, Card card, Zone toZone, Counter counter) {
if (toZone == Zone.BATTLEFIELD) {
throw new IllegalArgumentException("Wrong code usage - method doesn't support moving to battlefield zone");
}
// move to zone
if (!controller.moveCards(card, toZone, source, game)) {
return false;
}
// add counter
// after move it's a new object (not a permanent), so must work with main card
Effect effect = new AddCountersTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(card.getMainCard(), game));
effect.apply(game, source);
return true;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class FinalityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Target target = new TargetControlledCreaturePermanent(0, 1);
target.setNotTarget(true);
if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
effect.apply(game, source);
}
game.addEffect(new BoostAllEffect(-4, -4, Duration.EndOfTurn), source);
return true;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class FormlessNurturingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
new ManifestEffect(1).apply(game, source);
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setTargetPointer(new FixedTarget(card.getId()));
return effect.apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class GiantOysterLeaveUntapDelayedTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent oyster = game.getPermanent(source.getSourceId());
Permanent tappedCreature = game.getPermanent(source.getFirstTarget());
if (oyster != null && tappedCreature != null) {
Effect addCountersEffect = new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
addCountersEffect.setTargetPointer(getTargetPointer().getFixedTarget(game, source));
DelayedTriggeredAbility drawStepAbility = new AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility(addCountersEffect, Duration.Custom, false);
drawStepAbility.setControllerId(source.getControllerId());
UUID drawStepAbilityUUID = game.addDelayedTriggeredAbility(drawStepAbility, source);
DelayedTriggeredAbility leaveUntapDelayedTriggeredAbility = new GiantOysterLeaveUntapDelayedTriggeredAbility(drawStepAbilityUUID);
leaveUntapDelayedTriggeredAbility.getEffects().get(0).setTargetPointer(new FixedTarget(tappedCreature, game));
game.addDelayedTriggeredAbility(leaveUntapDelayedTriggeredAbility, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class NecropolisRegentTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedPlayerEvent) event).isCombatDamage()) {
Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null && creature.isControlledBy(controllerId)) {
this.getEffects().clear();
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(event.getAmount()));
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
this.addEffect(effect);
return true;
}
}
return false;
}
Aggregations