use of mage.game.Controllable in project mage by magefree.
the class MartyrsCryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
Map<UUID, Integer> playerMap = permanents.stream().filter(Objects::nonNull).map(Controllable::getControllerId).collect(Collectors.toMap(Function.identity(), uuid -> 1, Integer::sum));
controller.moveCards(new CardsImpl(permanents), Zone.EXILED, source, game);
for (Map.Entry<UUID, Integer> entry : playerMap.entrySet()) {
Player player = game.getPlayer(entry.getKey());
if (player == null) {
continue;
}
player.drawCards(entry.getValue(), source, game);
}
return true;
}
Aggregations