use of mage.counters.Counters in project mage by magefree.
the class CrystallineGiantEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
return false;
}
Counters counters = permanent.getCounters(game);
List<CounterType> counterTypes = new ArrayList();
counterTypes.addAll(counterTypeSet);
counterTypes.removeIf(counters::containsKey);
if (counterTypes.isEmpty()) {
return true;
}
return permanent.addCounters(counterTypes.get(RandomUtil.nextInt(counterTypes.size())).createInstance(), source.getControllerId(), source, game);
}
use of mage.counters.Counters in project mage by magefree.
the class BogardanPhoenixEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (permanent == null || controller == null || permanent.getZoneChangeCounter(game) + 1 != source.getSourceObjectZoneChangeCounter()) {
return false;
}
Card card = game.getCard(permanent.getId());
if (card == null || card.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter()) {
return false;
}
if (permanent.getCounters(game).containsKey(CounterType.DEATH)) {
return controller.moveCards(card, Zone.EXILED, source, game);
} else {
Counters countersToAdd = new Counters();
countersToAdd.addCounter(CounterType.DEATH.createInstance());
game.setEnterWithCounters(source.getSourceId(), countersToAdd);
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
Aggregations