use of mage.game.permanent.token.DragonToken in project mage by magefree.
the class DescentOfTheDragonsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Map<UUID, Integer> playersWithTargets = new HashMap<>();
for (Target target : source.getTargets()) {
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
UUID controllerOfTargetId = permanent.getControllerId();
if (permanent.destroy(source, game, false)) {
int count = playersWithTargets.getOrDefault(controllerOfTargetId, 0);
playersWithTargets.put(controllerOfTargetId, count + 1);
}
}
}
}
DragonToken dragonToken = new DragonToken();
for (Map.Entry<UUID, Integer> amountTokensPerPlayer : playersWithTargets.entrySet()) {
dragonToken.putOntoBattlefield(amountTokensPerPlayer.getValue(), game, source, amountTokensPerPlayer.getKey());
}
return true;
}
return false;
}
Aggregations