use of mage.watchers.common.AttackedThisTurnWatcher in project mage by magefree.
the class AngelsTrumpetTapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) {
int count = 0;
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
// Untapped creatures are safe.
if (creature.isTapped()) {
continue;
}
// Creatures that attacked are safe.
AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class);
if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game))) {
continue;
}
// Tap the rest.
creature.tap(source, game);
count++;
}
if (count > 0) {
player.damage(count, source.getSourceId(), source, game);
}
return true;
}
return false;
}
Aggregations