use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class ReyhanLastOfTheAbzanTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zcEvent = (ZoneChangeEvent) event;
// Dies or is put in the command zone
if (zcEvent.getFromZone() != Zone.BATTLEFIELD) {
return false;
}
if (zcEvent.getToZone() != Zone.GRAVEYARD && zcEvent.getToZone() != Zone.COMMAND) {
return false;
}
// A creature
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (permanent == null || !permanent.isCreature(game)) {
return false;
}
// You control
Player player = game.getPlayer(this.getControllerId());
if (player == null || !permanent.isControlledBy(getControllerId())) {
return false;
}
// If it had one or more +1/+1 counters on it
int countersOn = permanent.getCounters(game).getCount(CounterType.P1P1);
if (countersOn == 0) {
return false;
}
// You may put that may +1/+1 counters on target creature
this.getEffects().clear();
this.addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(countersOn)));
return true;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class StensiaMasqueradeTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent permanent = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && permanent != null && permanent.hasSubtype(SubType.VAMPIRE, game) && permanent.isControlledBy(controllerId)) {
this.getEffects().clear();
AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setTargetPointer(new FixedTarget(permanent, game));
this.addEffect(effect);
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class CocoonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (permanent != null) {
int amount = permanent.getCounters(game).getCount(CounterType.PUPA);
if (amount > 0) {
permanent.removeCounters(CounterType.PUPA.createInstance(), source, game);
} else {
Permanent enchantedPermanent = game.getPermanent(permanent.getAttachedTo());
permanent.sacrifice(source, game);
if (enchantedPermanent != null) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setTargetPointer(new FixedTarget(enchantedPermanent, game));
effect.apply(game, source);
ContinuousEffect effect2 = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.Custom);
effect2.setTargetPointer(new FixedTarget(enchantedPermanent, game));
game.addEffect(effect2, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class BiogenicUpgradeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent == null) {
continue;
}
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(permanent.getCounters(game).getCount(CounterType.P1P1)));
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
}
return true;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class DecimatorBeetleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null && targetCreature.getCounters(game).containsKey(CounterType.M1M1)) {
Effect effect = new RemoveCounterTargetEffect(CounterType.M1M1.createInstance(1));
effect.setTargetPointer(targetPointer);
effect.apply(game, source);
}
targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetCreature != null) {
Effect effect = new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget(), game));
effect.apply(game, source);
}
return true;
}
Aggregations