use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class ClockspinningAddOrRemoveCounterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (player != null && permanent != null) {
if (player.chooseUse(Outcome.Neutral, "Remove a counter?", source, game)) {
RemoveCounterTargetEffect effect = new RemoveCounterTargetEffect();
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source);
} else {
Counter counter = selectCounterType(game, source, permanent);
if (counter != null) {
AddCountersTargetEffect effect = new AddCountersTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source);
}
}
return true;
}
Card card = game.getCard(source.getFirstTarget());
if (player != null && card != null) {
if (player.chooseUse(Outcome.Neutral, "Remove a counter?", source, game)) {
Counter counter = selectCounterType(game, source, card);
RemoveCounterTargetEffect effect = new RemoveCounterTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source);
} else {
Counter counter = selectCounterType(game, source, card);
if (counter != null) {
AddCountersTargetEffect effect = new AddCountersTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class HankyuCost method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null) {
return false;
}
Permanent creature = game.getPermanent(permanent.getAttachedTo());
if (creature == null) {
return false;
}
creature.addAbility(new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.AIM.createInstance()).setTargetPointer(new FixedTarget(permanent, game)).setText("put an aim counter on " + permanent.getName()), new TapSourceCost()), source.getSourceId(), game);
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(HankyuValue.instance).setText("this creature deals damage to any target equal " + "to the number of aim counters removed this way"), new TapSourceCost());
ability.addCost(new HankyuCost().setMageObjectReference(source, game));
ability.addTarget(new TargetAnyTarget());
creature.addAbility(ability, source.getSourceId(), game);
return true;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class PyrrhicRevivalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Set<Card> toBattlefield = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card : player.getGraveyard().getCards(game)) {
if (card != null && card.isCreature(game)) {
toBattlefield.add(card);
ContinuousEffect effect = new EntersBattlefieldEffect(new AddCountersTargetEffect(CounterType.M1M1.createInstance()));
effect.setDuration(Duration.OneUse);
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}
use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.
the class WildcallEffect 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);
int xValue = source.getManaCostsToPay().getX();
if (xValue > 0) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(xValue));
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 DwarvenArmorerEffect 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 type of counter to add");
choice.setChoices(choices);
if (controller.choose(outcome, choice, game)) {
Counter counter = choice.getChoice().equals("+0/+1") ? CounterType.P0P1.createInstance() : CounterType.P1P0.createInstance();
Effect effect = new AddCountersTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source), game));
return effect.apply(game, source);
}
}
return false;
}
Aggregations