use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class TaintedAdversaryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Integer timesPaid = (Integer) getValue("timesPaid");
if (timesPaid == null || timesPaid <= 0) {
return false;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(timesPaid)), false, staticText);
ability.addEffect(new CreateTokenEffect(new ZombieDecayedToken(), 2 * timesPaid));
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class DescendantOfMasumaroEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller != null && sourcePermanent != null) {
if (!controller.getHand().isEmpty()) {
new AddCountersSourceEffect(CounterType.P1P1.createInstance(controller.getHand().size()), true).apply(game, source);
}
Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetOpponent != null && !targetOpponent.getHand().isEmpty()) {
sourcePermanent.removeCounters(CounterType.P1P1.getName(), targetOpponent.getHand().size(), source, game);
game.informPlayers(controller.getLogName() + " removes " + targetOpponent.getHand().size() + " +1/+1 counters from " + sourcePermanent.getLogName());
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class DrainingWhelkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell targetSpell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
if (targetSpell != null) {
int spellCMC = targetSpell.getManaValue();
super.apply(game, source);
new AddCountersSourceEffect(CounterType.P1P1.createInstance(spellCMC)).apply(game, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class DralnusPetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null && source.getAbilityType() == AbilityType.STATIC) {
permanent = game.getPermanentEntering(source.getSourceId());
}
if (controller != null && permanent != null) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null && spellAbility.getSourceId().equals(source.getSourceId()) && permanent.getZoneChangeCounter(game) == spellAbility.getSourceObjectZoneChangeCounter()) {
int cmc = 0;
for (Cost cost : spellAbility.getCosts()) {
if (cost instanceof DiscardCardCost && !((DiscardCardCost) cost).getCards().isEmpty()) {
cmc = ((DiscardCardCost) cost).getCards().get(0).getManaValue();
}
if (cmc > 0) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(cmc), true).apply(game, source);
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class SelflessSquireTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (isControlledBy(event.getTargetId())) {
getEffects().clear();
getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(event.getAmount())));
return true;
}
return false;
}
Aggregations