use of mage.game.permanent.token.DwarfBerserkerToken in project mage by magefree.
the class RecklessCrewEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int equipCount = game.getBattlefield().count(filter1, source.getSourceId(), source.getControllerId(), game);
int vehicleCount = game.getBattlefield().count(filter2, source.getSourceId(), source.getControllerId(), game);
if (equipCount + vehicleCount < 1) {
return false;
}
Token token = new DwarfBerserkerToken();
token.putOntoBattlefield(equipCount + vehicleCount, game, source, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
if (equipCount < 1) {
return true;
}
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent permanent = game.getPermanent(tokenId);
if (permanent == null) {
continue;
}
TargetPermanent target = new TargetPermanent(0, 1, filter1, true);
target.withChooseHint("(to attach to " + permanent.getIdName() + ")");
player.choose(outcome, target, source.getSourceId(), game);
permanent.addAttachment(target.getFirstTarget(), source, game);
}
return true;
}
Aggregations