use of mage.abilities.effects.common.combat.CantBeBlockedSourceEffect in project mage by magefree.
the class OgreMarauderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game);
MageObject sourceObject = game.getObject(source.getSourceId());
Player defender = game.getPlayer(defendingPlayerId);
if (defender != null && sourceObject != null) {
Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT));
if (cost.canPay(source, source, defendingPlayerId, game) && defender.chooseUse(Outcome.LoseAbility, "Sacrifice a creature to prevent that " + sourceObject.getLogName() + " can't be blocked?", source, game)) {
if (!cost.pay(source, game, source, defendingPlayerId, false, null)) {
// cost was not payed - so source can't be blocked
ContinuousEffect effect = new CantBeBlockedSourceEffect(Duration.EndOfTurn);
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
Aggregations