use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class InfiniteAuthorityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (aura != null) {
Permanent enchantedCreature = game.getPermanentOrLKIBattlefield(aura.getAttachedTo());
if (enchantedCreature != null) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
if (permanent.destroy(source, game, false)) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(enchantedCreature, game));
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class ScavengeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
int count = card.getPower().getValue();
if (count > 0) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(count));
effect.setTargetPointer(getTargetPointer());
return effect.apply(game, source);
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class EdgeOfMalacolEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
// Prevent untap event of creatures of target player
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null) {
return false;
}
if (!cPlane.getPlaneType().equals(Planes.PLANE_EDGE_OF_MALACOL)) {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (filter.match(permanent, game) && Objects.equals(permanent.getControllerId(), game.getActivePlayerId())) {
UUID oldController = source.getControllerId();
source.setControllerId(game.getActivePlayerId());
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
source.setControllerId(oldController);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class MaintenanceDroidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose mode");
choice.setChoices(choices);
if (!controller.choose(outcome, choice, game)) {
return false;
}
String chosen = choice.getChoice();
switch(chosen) {
case "Remove a repair counter":
new RemoveCounterTargetEffect(CounterType.REPAIR.createInstance()).apply(game, source);
break;
default:
// "Add another repair counter"
new AddCountersTargetEffect(CounterType.REPAIR.createInstance()).apply(game, source);
break;
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class DreadWightCounterCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) {
// add paralyzation counter
Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance());
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
// tap permanent
permanent.tap(source, game);
// does not untap while paralyzation counter is on it
ContinuousRuleModifyingEffect effect2 = new DreadWightDoNotUntapEffect(Duration.WhileOnBattlefield, permanent.getId());
effect2.setText("This creature doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it");
Condition condition = new DreadWightCounterCondition(permanent.getId());
ConditionalContinuousRuleModifyingEffect conditionalEffect = new ConditionalContinuousRuleModifyingEffect(effect2, condition);
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, conditionalEffect);
ContinuousEffect effect3 = new GainAbilityTargetEffect(ability, Duration.WhileOnBattlefield);
ability.setRuleVisible(true);
effect3.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect3, source);
// each gains 4: remove paralyzation counter
Ability activatedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RemoveCounterSourceEffect(CounterType.PARALYZATION.createInstance()), new ManaCostsImpl("{4}"));
ContinuousEffect effect4 = new GainAbilityTargetEffect(activatedAbility, Duration.WhileOnBattlefield);
effect4.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect4, source);
return true;
}
return false;
}
Aggregations