use of mage.counters.Counter in project mage by magefree.
the class SupremeLeaderSnokeCounterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
int amount = new OpponentNoncombatLostLifeCount().calculate(game, source, this);
if (amount > 0) {
Counter counterToAdd = counter.copy();
counterToAdd.add(amount - counter.getCount());
permanent.addCounters(counterToAdd, source.getControllerId(), source, game);
}
}
return true;
}
use of mage.counters.Counter in project mage by magefree.
the class TheOzolithMoveCountersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent creature = game.getPermanent(source.getFirstTarget());
if (permanent == null || creature == null) {
return false;
}
permanent.getCounters(game).copy().values().stream().filter(counter -> creature.addCounters(counter, source.getControllerId(), source, game)).forEach(counter -> permanent.removeCounters(counter, source, game));
return true;
}
use of mage.counters.Counter in project mage by magefree.
the class ThiefOfBloodEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int countersRemoved = 0;
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
permanent.removeCounters(counter.getName(), counter.getCount(), source, game);
countersRemoved += counter.getCount();
}
}
if (countersRemoved > 0) {
Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId());
if (sourcePermanent != null) {
sourcePermanent.addCounters(CounterType.P1P1.createInstance(countersRemoved), source.getControllerId(), source, game);
}
}
return true;
}
use of mage.counters.Counter in project mage by magefree.
the class AetherSnapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards tokens = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getSourceId(), game)) {
if (permanent instanceof PermanentToken) {
tokens.add(permanent);
}
if (permanent.getCounters(game).isEmpty()) {
continue;
}
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
permanent.removeCounters(counter, source, game);
}
}
controller.moveCards(tokens, Zone.EXILED, source, game);
return true;
}
use of mage.counters.Counter 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