use of mage.game.permanent.token.CentaurToken in project mage by magefree.
the class RampageOfTheClansEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Map<UUID, Integer> playersWithPermanents = new HashMap<>();
for (Permanent p : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT, source.getControllerId(), source.getSourceId(), game)) {
UUID controllerId = p.getControllerId();
if (p.destroy(source, game, false)) {
playersWithPermanents.put(controllerId, playersWithPermanents.getOrDefault(controllerId, 0) + 1);
}
}
Token token = new CentaurToken();
for (Map.Entry<UUID, Integer> amountDestroyedByPlayer : playersWithPermanents.entrySet()) {
token.putOntoBattlefield(amountDestroyedByPlayer.getValue(), game, source, amountDestroyedByPlayer.getKey());
}
return true;
}